Skip to content

Commit

Permalink
feat: add getter/setter annotations
Browse files Browse the repository at this point in the history
refs #0 @0m
  • Loading branch information
Naugrimm committed Jun 4, 2024
1 parent 1d9335f commit 0323855
Show file tree
Hide file tree
Showing 35 changed files with 345 additions and 41 deletions.
40 changes: 40 additions & 0 deletions src/Nodes/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,46 @@

/**
* @implements \Naugrim\BMEcat\Nodes\Contracts\NodeInterface<Address>
* @method self setName(string|null $name)
* @method string|null getName()
* @method self setName2(string|null $name2)
* @method string|null getName2()
* @method self setName3(string|null $name3)
* @method string|null getName3()
* @method self setDepartment(string|null $department)
* @method string|null getDepartment()
* @method self setContactDetails(\Naugrim\BMEcat\Nodes\Contact\Details[]|array $contactDetails)
* @method \Naugrim\BMEcat\Nodes\Contact\Details[]|array getContactDetails()
* @method self setStreet(string|null $street)
* @method string|null getStreet()
* @method self setZip(string|null $zip)
* @method string|null getZip()
* @method self setBoxno(string|null $boxno)
* @method string|null getBoxno()
* @method self setZipbox(string|null $zipbox)
* @method string|null getZipbox()
* @method self setCity(string|null $city)
* @method string|null getCity()
* @method self setState(string|null $state)
* @method string|null getState()
* @method self setCountry(string|null $country)
* @method string|null getCountry()
* @method self setCountryCoded(string|null $countryCoded)
* @method string|null getCountryCoded()
* @method self setVatId(string|null $vatId)
* @method string|null getVatId()
* @method self setPhone(null|array|\Naugrim\BMEcat\Nodes\Phone $phone)
* @method \Naugrim\BMEcat\Nodes\Phone|null getPhone()
* @method self setFax(null|array|\Naugrim\BMEcat\Nodes\Fax $fax)
* @method \Naugrim\BMEcat\Nodes\Fax|null getFax()
* @method self setEmail(string|null $email)
* @method string|null getEmail()
* @method self setPublicKey(null|array|\Naugrim\BMEcat\Nodes\Crypto\PublicKey $publicKey)
* @method \Naugrim\BMEcat\Nodes\Crypto\PublicKey|null getPublicKey()
* @method self setUrl(string|null $url)
* @method string|null getUrl()
* @method self setAddressRemarks(string|null $addressRemarks)
* @method string|null getAddressRemarks()
*/
class Address implements NodeInterface
{
Expand Down
8 changes: 8 additions & 0 deletions src/Nodes/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

/**
* @implements NodeInterface<self>
* @method self setLanguage(\Naugrim\BMEcat\Nodes\Language[]|array $language)
* @method \Naugrim\BMEcat\Nodes\Language[]|array getLanguage()
* @method self setId(string $id)
* @method string getId()
* @method self setVersion(string $version)
* @method string getVersion()
* @method self setDateTime(null|array|\Naugrim\BMEcat\Nodes\DateTime $dateTime)
* @method \Naugrim\BMEcat\Nodes\DateTime|null getDateTime()
*/
#[Serializer\XmlRoot('CATALOG')]
class Catalog implements Contracts\NodeInterface
Expand Down
10 changes: 5 additions & 5 deletions src/Nodes/Concerns/HasSerializableAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ private function handleDateTimeInterfaceSetter(
return $this;
}

$this->{$propertyName} = DateTime::createFromFormat(
$matches['format'],
$valueToSet
); // @phpstan-ignore property.dynamicName
// @phpstan-ignore property.dynamicName
$this->{$propertyName} = DateTime::createFromFormat($matches['format'], $valueToSet);
return $this;
}

Expand All @@ -169,7 +167,9 @@ private function getTypeAnnotationFromProperty(ReflectionProperty $property): st
$typeName = $typeAttribute->newInstance()
->name;
if ($typeName === null) {
throw new RuntimeException('Could not get the type ' . Type::class . ' for the property ' . $property->name);
throw new RuntimeException(
'Could not get the type ' . Type::class . ' for the property ' . $property->name
);
}

return $typeName;
Expand Down
22 changes: 22 additions & 0 deletions src/Nodes/Contact/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@

/**
* @implements NodeInterface<self>
* @method self setId(string|null $id)
* @method string|null getId()
* @method self setName(string $name)
* @method string getName()
* @method self setFirstName(string|null $firstName)
* @method string|null getFirstName()
* @method self setTitle(string|null $title)
* @method string|null getTitle()
* @method self setAcademicTitle(string|null $academicTitle)
* @method string|null getAcademicTitle()
* @method self setRole(array|\Naugrim\BMEcat\Nodes\Contact\Role $role)
* @method \Naugrim\BMEcat\Nodes\Contact\Role getRole()
* @method self setDescription(string|null $description)
* @method string|null getDescription()
* @method self setPhone(array|\Naugrim\BMEcat\Nodes\Phone $phone)
* @method \Naugrim\BMEcat\Nodes\Phone getPhone()
* @method self setFax(array|\Naugrim\BMEcat\Nodes\Fax $fax)
* @method \Naugrim\BMEcat\Nodes\Fax getFax()
* @method self setUrl(string|null $url)
* @method string|null getUrl()
* @method self setEmails(array|\Naugrim\BMEcat\Nodes\Emails $emails)
* @method \Naugrim\BMEcat\Nodes\Emails getEmails()
*/
class Details implements NodeInterface
{
Expand Down
8 changes: 8 additions & 0 deletions src/Nodes/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

/**
* @implements NodeInterface<self>
* @method self setType(string $type)
* @method string getType()
* @method self setDate(string $date)
* @method string getDate()
* @method self setTime(string $time)
* @method string getTime()
* @method self setTimezone(string $timezone)
* @method string getTimezone()
*/
#[Serializer\XmlRoot('DATETIME')]
class DateTime implements Contracts\NodeInterface
Expand Down
6 changes: 6 additions & 0 deletions src/Nodes/DeliveryTimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

/**
* @implements NodeInterface<self>
* @method self setTerritories(string $territories)
* @method string getTerritories()
* @method self setTimeSpans(\Naugrim\BMEcat\Nodes\TimeSpan[]|array $timeSpans)
* @method \Naugrim\BMEcat\Nodes\TimeSpan[]|array getTimeSpans()
* @method self setLeadTime(float|null $leadTime)
* @method float|null getLeadTime()
*/
#[Serializer\XmlRoot('DELIVERY_TIMES')]
class DeliveryTimes implements Contracts\NodeInterface
Expand Down
8 changes: 8 additions & 0 deletions src/Nodes/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

/**
* @implements NodeInterface<self>
* @method self setVersion(string $version)
* @method string getVersion()
* @method self setNamespace(string $namespace)
* @method string getNamespace()
* @method self setHeader(array|\Naugrim\BMEcat\Nodes\Header $header)
* @method \Naugrim\BMEcat\Nodes\Header getHeader()
* @method self setNewCatalog(array|\Naugrim\BMEcat\Nodes\NewCatalog $newCatalog)
* @method \Naugrim\BMEcat\Nodes\NewCatalog getNewCatalog()
*/
#[Serializer\XmlRoot('BMECAT')]
#[Serializer\ExclusionPolicy('all')]
Expand Down
4 changes: 4 additions & 0 deletions src/Nodes/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

/**
* @implements NodeInterface<self>
* @method self setEmail(string $email)
* @method string getEmail()
* @method self setPublicKeys(\Naugrim\BMEcat\Nodes\Crypto\PublicKey[]|array $publicKeys)
* @method \Naugrim\BMEcat\Nodes\Crypto\PublicKey[]|array getPublicKeys()
*/
class Emails implements NodeInterface
{
Expand Down
10 changes: 10 additions & 0 deletions src/Nodes/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

/**
* @implements NodeInterface<self>
* @method self setGeneratorInfo(string|null $generatorInfo)
* @method string|null getGeneratorInfo()
* @method self setCatalog(array|\Naugrim\BMEcat\Nodes\Catalog $catalog)
* @method \Naugrim\BMEcat\Nodes\Catalog getCatalog()
* @method self setBuyerIdRef(null|array|\Naugrim\BMEcat\Nodes\BuyerIdRef $buyerIdRef)
* @method \Naugrim\BMEcat\Nodes\BuyerIdRef|null getBuyerIdRef()
* @method self setSupplierIdRef(null|array|\Naugrim\BMEcat\Nodes\SupplierIdRef $supplierIdRef)
* @method \Naugrim\BMEcat\Nodes\SupplierIdRef|null getSupplierIdRef()
* @method self setParties(\Naugrim\BMEcat\Nodes\Party[]|array $parties)
* @method \Naugrim\BMEcat\Nodes\Party[]|array getParties()
*/
#[Serializer\XmlRoot('HEADER')]
class Header implements Contracts\NodeInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* @implements NodeInterface<self>
* @method self setType(bool|null $type)
* @method bool|null getType()
*/
class Language implements NodeInterface
{
Expand Down
4 changes: 4 additions & 0 deletions src/Nodes/Logistic/MeansOfTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

/**
* @implements NodeInterface<self>
* @method self setId(string|null $id)
* @method string|null getId()
* @method self setName(string|null $name)
* @method string|null getName()
*/
final class MeansOfTransport implements NodeInterface
{
Expand Down
6 changes: 6 additions & 0 deletions src/Nodes/Logistic/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

/**
* @implements NodeInterface<Transport>
* @method self setIncoterm(string $incoterm)
* @method string getIncoterm()
* @method self setLocation(string|null $location)
* @method string|null getLocation()
* @method self setTransportRemark(string|null $transportRemark)
* @method string|null getTransportRemark()
*/
final class Transport implements NodeInterface
{
Expand Down
12 changes: 12 additions & 0 deletions src/Nodes/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

/**
* @implements NodeInterface<self>
* @method self setType(string|null $type)
* @method string|null getType()
* @method self setSource(string $source)
* @method string getSource()
* @method self setDescription(string|null $description)
* @method string|null getDescription()
* @method self setAlt(string|null $alt)
* @method string|null getAlt()
* @method self setPurpose(string|null $purpose)
* @method string|null getPurpose()
* @method self setOrder(int|null $order)
* @method int|null getOrder()
*/
#[Serializer\XmlRoot('MIME')]
class Mime implements Contracts\NodeInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/NewCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* @implements NodeInterface<self>
* @method self setProducts(\Naugrim\BMEcat\Nodes\Product[]|array $products)
* @method \Naugrim\BMEcat\Nodes\Product[]|array getProducts()
*/
#[Serializer\XmlRoot('T_NEW_CATALOG')]
class NewCatalog implements Contracts\NodeInterface
Expand Down
8 changes: 8 additions & 0 deletions src/Nodes/Party.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

/**
* @implements NodeInterface<self>
* @method self setId(string $id)
* @method string getId()
* @method self setRole(string $role)
* @method string getRole()
* @method self setAddress(\Naugrim\BMEcat\Nodes\Address[]|array $address)
* @method \Naugrim\BMEcat\Nodes\Address[]|array getAddress()
* @method self setMimes(\Naugrim\BMEcat\Nodes\Mime[]|array $mimes)
* @method \Naugrim\BMEcat\Nodes\Mime[]|array getMimes()
*/
class Party implements NodeInterface
{
Expand Down
18 changes: 18 additions & 0 deletions src/Nodes/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@

/**
* @implements NodeInterface<self>
* @method self setMode(string $mode)
* @method string getMode()
* @method self setId(null|array|\Naugrim\BMEcat\Nodes\SupplierPid $id)
* @method \Naugrim\BMEcat\Nodes\SupplierPid|null getId()
* @method self setDetails(array|\Naugrim\BMEcat\Nodes\Product\Details $details)
* @method \Naugrim\BMEcat\Nodes\Product\Details getDetails()
* @method self setFeatures(\Naugrim\BMEcat\Nodes\Product\Features[]|array $features)
* @method \Naugrim\BMEcat\Nodes\Product\Features[]|array getFeatures()
* @method self setOrderDetails(array|\Naugrim\BMEcat\Nodes\Product\OrderDetails $orderDetails)
* @method \Naugrim\BMEcat\Nodes\Product\OrderDetails getOrderDetails()
* @method self setPriceDetails(\Naugrim\BMEcat\Nodes\Product\PriceDetails[]|array $priceDetails)
* @method \Naugrim\BMEcat\Nodes\Product\PriceDetails[]|array getPriceDetails()
* @method self setMimes(\Naugrim\BMEcat\Nodes\Mime[]|array $mimes)
* @method \Naugrim\BMEcat\Nodes\Mime[]|array getMimes()
* @method self setLogisticDetails(array|\Naugrim\BMEcat\Nodes\Product\LogisticDetails $logisticDetails)
* @method \Naugrim\BMEcat\Nodes\Product\LogisticDetails getLogisticDetails()
* @method self setConfigDetails(array|\Naugrim\BMEcat\Nodes\Product\ConfigDetails $configDetails)
* @method \Naugrim\BMEcat\Nodes\Product\ConfigDetails getConfigDetails()
*/
#[Serializer\XmlRoot('PRODUCT')]
class Product implements Contracts\NodeInterface
Expand Down
46 changes: 13 additions & 33 deletions src/Nodes/Product/Config/PartAlternative.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@

/**
* @implements NodeInterface<self>
* @method self setSupplierPidRef(string $supplierPidRef)
* @method string getSupplierPidRef()
* @method self setSupplierIdRef(string|null $supplierIdRef)
* @method string|null getSupplierIdRef()
* @method self setOrder(int $order)
* @method int getOrder()
* @method self setDefaultFlag(bool|null $defaultFlag)
* @method bool|null getDefaultFlag()
* @method self setCode(string|null $code)
* @method string|null getCode()
* @method self setPriceDetails(null|array|\Naugrim\BMEcat\Nodes\Product\PriceDetails $priceDetails)
* @method \Naugrim\BMEcat\Nodes\Product\PriceDetails|null getPriceDetails()
*/
#[Serializer\XmlRoot('PART_ALTERNATIVE')]
class PartAlternative implements Contracts\NodeInterface
{
use \Naugrim\BMEcat\Nodes\Concerns\HasSerializableAttributes;

#[Serializer\Expose]
#[Serializer\Type('string')]
#[Serializer\SerializedName('SUPPLIER_PIDREF')]
Expand Down Expand Up @@ -44,37 +57,4 @@ class PartAlternative implements Contracts\NodeInterface
#[Serializer\SerializedName('PRODUCT_PRICE_DETAILS')]
#[Serializer\Type(PriceDetails::class)]
protected ?PriceDetails $priceDetails = null;

public function setSupplierPidRef(string $supplier_pid_ref): self
{
$this->supplier_pid_ref = $supplier_pid_ref;
return $this;
}

public function getSupplierPidRef(): string
{
return $this->supplier_pid_ref;
}

public function setSupplierIdRef(?string $supplier_id_ref): self
{
$this->supplier_id_ref = $supplier_id_ref;
return $this;
}

public function getSupplierIdRef(): ?string
{
return $this->supplier_id_ref;
}

public function setDefaultFlag(?bool $default_flag): self
{
$this->default_flag = $default_flag;
return $this;
}

public function getDefaultFlag(): ?bool
{
return $this->default_flag;
}
}
4 changes: 4 additions & 0 deletions src/Nodes/Product/Config/Parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

/**
* @implements NodeInterface<self>
* @method self setAlternatives(\Naugrim\BMEcat\Nodes\Product\Config\PartAlternative[]|array $alternatives)
* @method \Naugrim\BMEcat\Nodes\Product\Config\PartAlternative[]|array getAlternatives()
* @method self setSelectionType(string|null $selectionType)
* @method string|null getSelectionType()
*/
#[Serializer\XmlRoot('CONFIG_PARTS')]
class Parts implements Contracts\NodeInterface
Expand Down
20 changes: 20 additions & 0 deletions src/Nodes/Product/Config/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@

/**
* @implements NodeInterface<self>
* @method self setId(string $id)
* @method string getId()
* @method self setHeader(string $header)
* @method string getHeader()
* @method self setDescriptionShort(string $descriptionShort)
* @method string getDescriptionShort()
* @method self setDescriptionLong(string $descriptionLong)
* @method string getDescriptionLong()
* @method self setOrder(int $order)
* @method int getOrder()
* @method self setCode(string|null $code)
* @method string|null getCode()
* @method self setPriceDetails(null|array|\Naugrim\BMEcat\Nodes\Product\PriceDetails $priceDetails)
* @method \Naugrim\BMEcat\Nodes\Product\PriceDetails|null getPriceDetails()
* @method self setParts(array|\Naugrim\BMEcat\Nodes\Product\Config\Parts $parts)
* @method \Naugrim\BMEcat\Nodes\Product\Config\Parts getParts()
* @method self setMinOccurrence(int $minOccurrence)
* @method int getMinOccurrence()
* @method self setMaxOccurrence(int $maxOccurrence)
* @method int getMaxOccurrence()
*/
#[Serializer\XmlRoot('CONFIG_STEP')]
class Step implements Contracts\NodeInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Nodes/Product/ConfigDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* @implements NodeInterface<self>
* @method self setSteps(\Naugrim\BMEcat\Nodes\Product\Config\Step[]|array $steps)
* @method \Naugrim\BMEcat\Nodes\Product\Config\Step[]|array getSteps()
*/
#[Serializer\XmlRoot('PRODUCT_CONFIG_DETAILS')]
class ConfigDetails implements Contracts\NodeInterface
Expand Down
Loading

0 comments on commit 0323855

Please sign in to comment.