From 114838f33a1737e1f4fed92fcbf8d0727d4e1722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Grundko=CC=88tter?= Date: Wed, 6 Mar 2024 14:41:19 +0100 Subject: [PATCH 1/2] [BUGFIX] possible fix for new version of xsd parser --- build/config/phpstan-baseline.neon | 19 +++++++++++++++++-- composer.json | 6 ++++-- src/Generator/ApiGenerator.php | 11 +++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/build/config/phpstan-baseline.neon b/build/config/phpstan-baseline.neon index 8134908..3e0d228 100644 --- a/build/config/phpstan-baseline.neon +++ b/build/config/phpstan-baseline.neon @@ -1,12 +1,17 @@ parameters: ignoreErrors: - - message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Type\\\\Type\\:\\:getElements\\(\\)\\.$#" + message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Element\\\\ElementItem\\:\\:getMax\\(\\)\\.$#" count: 1 path: ../../src/Generator/ApiGenerator.php - - message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Type\\\\Type\\:\\:getAttributes\\(\\)\\.$#" + message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Element\\\\ElementItem\\:\\:getMin\\(\\)\\.$#" + count: 1 + path: ../../src/Generator/ApiGenerator.php + + - + message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Element\\\\ElementItem\\:\\:getType\\(\\)\\.$#" count: 2 path: ../../src/Generator/ApiGenerator.php @@ -15,3 +20,13 @@ parameters: count: 1 path: ../../src/Generator/ApiGenerator.php + - + message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Type\\\\Type\\:\\:getAttributes\\(\\)\\.$#" + count: 2 + path: ../../src/Generator/ApiGenerator.php + + - + message: "#^Call to an undefined method GoetasWebservices\\\\XML\\\\XSDReader\\\\Schema\\\\Type\\\\Type\\:\\:getElements\\(\\)\\.$#" + count: 1 + path: ../../src/Generator/ApiGenerator.php + diff --git a/composer.json b/composer.json index 0f69512..35d4ba7 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ujamii/openimmo", - "description": "OpenImmo library for PHP7/8. Read and write OpenImmo xml format with JMS Serializer.", + "description": "OpenImmo library for PHP8. Read and write OpenImmo xml format with JMS Serializer.", "type": "library", "license": "GPL-3.0-only", "authors": [ @@ -15,7 +15,8 @@ "php": ">=8.1", "ext-dom": "*", "ext-simplexml": "*", - "jms/serializer": "^2.1 || ^3.5" + "jms/serializer": "^2.1 || ^3.5", + "doctrine/annotations": "^2.0" }, "extra": { "platform": { @@ -52,6 +53,7 @@ ], "phpunit": "vendor/bin/phpunit -c build/config/phpunit.xml.dist", "phpstan": "vendor/bin/phpstan --memory-limit=1G analyse -c build/config/phpstan.neon", + "phpstan-baseline": "vendor/bin/phpstan --memory-limit=1G analyse -c build/config/phpstan.neon -b build/config/phpstan-baseline.neon", "rector": "vendor/bin/rector process src tests -c build/config/rector.php --xdebug", "php-cs-fixer": "vendor/bin/php-cs-fixer fix --config build/config/cs.php", "infection": "vendor/bin/infection --only-covered --configuration=./build/config/infection.json.dist --threads=8 --min-msi=99", diff --git a/src/Generator/ApiGenerator.php b/src/Generator/ApiGenerator.php index d1b2054..21efde4 100644 --- a/src/Generator/ApiGenerator.php +++ b/src/Generator/ApiGenerator.php @@ -8,6 +8,7 @@ use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementItem; use GoetasWebservices\XML\XSDReader\Schema\Element\ElementRef; +use GoetasWebservices\XML\XSDReader\Schema\Element\Sequence; use GoetasWebservices\XML\XSDReader\Schema\Inheritance\Extension; use GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction; use GoetasWebservices\XML\XSDReader\Schema\Item; @@ -182,14 +183,20 @@ private function generateConstructor(ClassType $class): void } /** - * @param Element|ElementRef|ElementDef $property + * @param Element|ElementRef|ElementDef|Sequence|ElementItem $property */ - private function parseProperty(ElementItem $property, ClassType $class, PhpNamespace $namespace): void + private function parseProperty(Element|ElementRef|ElementDef|Sequence|ElementItem $property, ClassType $class, PhpNamespace $namespace): void { $propertyName = TypeUtil::camelize($property->getName(), true); if (array_key_exists($propertyName, $class->getProperties())) { return; } + if ($property instanceof Sequence) { + foreach ($property->getElements() as $sequenceProperty) { + $this->parseProperty($sequenceProperty, $class, $namespace); + } + return; + } $classProperty = $class->addProperty($propertyName) ->setVisibility(ClassType::VisibilityProtected); $xsdType = $this->getPhpPropertyTypeFromXsdElement($property); From 0d158ed77cbd40a24f8341dbf3202355a178d35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Grundko=CC=88tter?= Date: Wed, 6 Mar 2024 14:42:42 +0100 Subject: [PATCH 2/2] removed platform setting --- composer.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/composer.json b/composer.json index 35d4ba7..1a9781f 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,6 @@ "jms/serializer": "^2.1 || ^3.5", "doctrine/annotations": "^2.0" }, - "extra": { - "platform": { - "php": "8.1" - } - }, "require-dev": { "ext-json": "*", "goetas-webservices/xsd-reader": "^0.4",