Skip to content

Commit

Permalink
Merge pull request #85 from ujamii/bugfix/xsd-parser-sequence
Browse files Browse the repository at this point in the history
Bugfix/xsd parser sequence
  • Loading branch information
mgrundkoetter authored Mar 6, 2024
2 parents c423190 + 0d158ed commit f189b0b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
19 changes: 17 additions & 2 deletions build/config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

11 changes: 4 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -15,12 +15,8 @@
"php": ">=8.1",
"ext-dom": "*",
"ext-simplexml": "*",
"jms/serializer": "^2.1 || ^3.5"
},
"extra": {
"platform": {
"php": "8.1"
}
"jms/serializer": "^2.1 || ^3.5",
"doctrine/annotations": "^2.0"
},
"require-dev": {
"ext-json": "*",
Expand Down Expand Up @@ -52,6 +48,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",
Expand Down
11 changes: 9 additions & 2 deletions src/Generator/ApiGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f189b0b

Please sign in to comment.