Skip to content

Commit

Permalink
Merge branch 'release/5.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Naugrimm committed Jun 4, 2024
2 parents c5e2358 + 0323855 commit b3f9f22
Show file tree
Hide file tree
Showing 42 changed files with 748 additions and 66 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PHP

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- uses: php-actions/composer@v6
with:
args: --no-scripts
php_version: "8.3"
php_extensions: dom libxml
- name: Run PHPStan
run: ./vendor/bin/phpstan
- name: Run ECS
run: ./vendor/bin/ecs
- name: Run Rector
run: ./vendor/bin/rector --dry-run
- name: Run PHPUnit
run: ./vendor/bin/phpunit
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 5.x

## BREAKING CHANGES

Attribute names have been changed to camelCase. See commit 1ef916816b2fe07eaea3c0f64f9b0577e911d011.

## Development

To provide code completion in the IDEs, a new Rector has been added, that adds getter/setter method annotations for all serializable attributes: `\Utils\Rector\Rector\AddDocBlockWithMethodHintsToNodeInterfaceClassesRector`

# 4.x

## BREAKING CHANGES
Expand Down Expand Up @@ -73,4 +83,3 @@ Nearly all elements that are rendered as lists are not nullable anymore. They ar
Change all your `NodeInterface->setXyz(null)` calls to `NodeInterface->setXyz([])` when you want to clear these lists.

You are advised to always use the `NodeBuilder::fromArray(...)` to create new nodes instead of `new MyNodeClass`. Use the `\Utils\Rector\Rector\NodeInterfaceConstructorCallToNodeBuilderFromArrayRector` rule to automatically convert all these occurrences.

2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\JMSSetList;
use Utils\Rector\Rector\AddDocBlockWithMethodHintsToNodeInterfaceClassesRector;
use Utils\Rector\Rector\NodeInterfaceAddGenericImplementsAttributeRector;
use Utils\Rector\Rector\NodeInterfaceAddHasSerializableAttributesTraitRector;
use Utils\Rector\Rector\NodeInterfaceConstructorCallToNodeBuilderFromArrayRector;
Expand Down Expand Up @@ -33,6 +34,7 @@
NodeInterfaceRemoveSimpleGettersRector::class,
NodeInterfaceRemoveSimpleSettersRector::class,
NodeInterfaceAddGenericImplementsAttributeRector::class,
AddDocBlockWithMethodHintsToNodeInterfaceClassesRector::class,
])
->withSkip([
NullToStrictStringFuncCallArgRector::class,
Expand Down
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
Loading

0 comments on commit b3f9f22

Please sign in to comment.