Skip to content

Commit

Permalink
Merge pull request #2565 from franmomu/doctrine_cs_12
Browse files Browse the repository at this point in the history
Doctrine CS 12
  • Loading branch information
malarzm authored Oct 29, 2023
2 parents 1fc5dd3 + 43063d6 commit 91539d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/coding-standard": "^11.0",
"doctrine/coding-standard": "^12.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0@dev",
"phpstan/phpstan": "^1.10.11",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5.5 || ^10.0.15",
"squizlabs/php_codesniffer": "^3.5",
"symfony/cache": "^4.4 || ^5.0 || ^6.0",
"vimeo/psalm": "^5.9.0"
},
Expand Down
28 changes: 14 additions & 14 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public function loadMetadataForClass($className, \Doctrine\Persistence\Mapping\C
$metadata->setDefaultDiscriminatorValue((string) $xmlRoot->{'default-discriminator-value'}['value']);
}

if (isset($xmlRoot->{'indexes'})) {
foreach ($xmlRoot->{'indexes'}->{'index'} as $index) {
if (isset($xmlRoot->indexes)) {
foreach ($xmlRoot->indexes->index as $index) {
$this->addIndex($metadata, $index);
}
}
Expand Down Expand Up @@ -474,15 +474,15 @@ private function addReferenceMapping(ClassMetadata $class, ?SimpleXMLElement $re
$mapping['defaultDiscriminatorValue'] = (string) $reference->{'default-discriminator-value'}['value'];
}

if (isset($reference->{'sort'})) {
foreach ($reference->{'sort'}->{'sort'} as $sort) {
if (isset($reference->sort)) {
foreach ($reference->sort->sort as $sort) {
$attr = $sort->attributes();
$mapping['sort'][(string) $attr['field']] = (string) ($attr['order'] ?? 'asc');
}
}

if (isset($reference->{'criteria'})) {
foreach ($reference->{'criteria'}->{'criteria'} as $criteria) {
if (isset($reference->criteria)) {
foreach ($reference->criteria->criteria as $criteria) {
$attr = $criteria->attributes();
$mapping['criteria'][(string) $attr['field']] = (string) $attr['value'];
}
Expand All @@ -496,8 +496,8 @@ private function addReferenceMapping(ClassMetadata $class, ?SimpleXMLElement $re
$mapping['alsoLoadFields'] = explode(',', (string) $attributes['also-load']);
}

if (isset($reference->{'prime'})) {
foreach ($reference->{'prime'}->{'field'} as $field) {
if (isset($reference->prime)) {
foreach ($reference->prime->field as $field) {
$attr = $field->attributes();
$mapping['prime'][] = (string) $attr['name'];
}
Expand All @@ -513,7 +513,7 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex): voi

$keys = [];

foreach ($xmlIndex->{'key'} as $key) {
foreach ($xmlIndex->key as $key) {
$keys[(string) $key['name']] = (string) ($key['order'] ?? 'asc');
}

Expand All @@ -535,8 +535,8 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex): voi
$options['unique'] = ((string) $attributes['unique'] === 'true');
}

if (isset($xmlIndex->{'option'})) {
foreach ($xmlIndex->{'option'} as $option) {
if (isset($xmlIndex->option)) {
foreach ($xmlIndex->option as $option) {
$options[(string) $option['name']] = $this->convertXMLElementValue((string) $option['value']);
}
}
Expand Down Expand Up @@ -635,7 +635,7 @@ private function setShardKey(ClassMetadata $class, SimpleXMLElement $xmlShardkey

$keys = [];
$options = [];
foreach ($xmlShardkey->{'key'} as $key) {
foreach ($xmlShardkey->key as $key) {
$keys[(string) $key['name']] = (string) ($key['order'] ?? 'asc');
}

Expand All @@ -647,8 +647,8 @@ private function setShardKey(ClassMetadata $class, SimpleXMLElement $xmlShardkey
$options['numInitialChunks'] = (int) $attributes['numInitialChunks'];
}

if (isset($xmlShardkey->{'option'})) {
foreach ($xmlShardkey->{'option'} as $option) {
if (isset($xmlShardkey->option)) {
foreach ($xmlShardkey->option as $option) {
$options[(string) $option['name']] = $this->convertXMLElementValue((string) $option['value']);
}
}
Expand Down
16 changes: 8 additions & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
<InvalidPropertyFetch>
<code><![CDATA[$xmlRoot->field]]></code>
<code><![CDATA[$xmlRoot->id]]></code>
<code><![CDATA[$xmlRoot->indexes]]></code>
<code><![CDATA[$xmlRoot->{'also-load-methods'}]]></code>
<code><![CDATA[$xmlRoot->{'default-discriminator-value'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-field'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-many'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-one'}]]></code>
<code><![CDATA[$xmlRoot->{'indexes'}]]></code>
<code><![CDATA[$xmlRoot->{'lifecycle-callbacks'}]]></code>
<code><![CDATA[$xmlRoot->{'read-preference'}]]></code>
<code><![CDATA[$xmlRoot->{'reference-many'}]]></code>
Expand All @@ -102,13 +102,13 @@
<NoInterfaceProperties>
<code><![CDATA[$xmlRoot->field]]></code>
<code><![CDATA[$xmlRoot->id]]></code>
<code><![CDATA[$xmlRoot->indexes]]></code>
<code><![CDATA[$xmlRoot->{'also-load-methods'}]]></code>
<code><![CDATA[$xmlRoot->{'default-discriminator-value'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-field'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-many'}]]></code>
<code><![CDATA[$xmlRoot->{'embed-one'}]]></code>
<code><![CDATA[$xmlRoot->{'indexes'}]]></code>
<code><![CDATA[$xmlRoot->{'lifecycle-callbacks'}]]></code>
<code><![CDATA[$xmlRoot->{'read-preference'}]]></code>
<code><![CDATA[$xmlRoot->{'reference-many'}]]></code>
Expand All @@ -130,30 +130,30 @@
<code><![CDATA[isset($field->{'generator-option'})]]></code>
<code><![CDATA[isset($partialFilterExpressionMapping->and)]]></code>
<code><![CDATA[isset($partialFilterExpressionMapping->field)]]></code>
<code><![CDATA[isset($reference->{'criteria'})]]></code>
<code><![CDATA[isset($reference->criteria)]]></code>
<code><![CDATA[isset($reference->prime)]]></code>
<code><![CDATA[isset($reference->sort)]]></code>
<code><![CDATA[isset($reference->{'default-discriminator-value'})]]></code>
<code><![CDATA[isset($reference->{'discriminator-field'})]]></code>
<code><![CDATA[isset($reference->{'discriminator-map'})]]></code>
<code><![CDATA[isset($reference->{'prime'})]]></code>
<code><![CDATA[isset($reference->{'sort'})]]></code>
<code><![CDATA[isset($xmlIndex->{'option'})]]></code>
<code><![CDATA[isset($xmlIndex->option)]]></code>
<code><![CDATA[isset($xmlIndex->{'partial-filter-expression'})]]></code>
<code><![CDATA[isset($xmlReadPreference->{'tag-set'})]]></code>
<code><![CDATA[isset($xmlRoot->field)]]></code>
<code><![CDATA[isset($xmlRoot->id)]]></code>
<code><![CDATA[isset($xmlRoot->indexes)]]></code>
<code><![CDATA[isset($xmlRoot->{'default-discriminator-value'})]]></code>
<code><![CDATA[isset($xmlRoot->{'discriminator-field'})]]></code>
<code><![CDATA[isset($xmlRoot->{'discriminator-map'})]]></code>
<code><![CDATA[isset($xmlRoot->{'embed-many'})]]></code>
<code><![CDATA[isset($xmlRoot->{'embed-one'})]]></code>
<code><![CDATA[isset($xmlRoot->{'indexes'})]]></code>
<code><![CDATA[isset($xmlRoot->{'lifecycle-callbacks'})]]></code>
<code><![CDATA[isset($xmlRoot->{'read-preference'})]]></code>
<code><![CDATA[isset($xmlRoot->{'reference-many'})]]></code>
<code><![CDATA[isset($xmlRoot->{'reference-one'})]]></code>
<code><![CDATA[isset($xmlRoot->{'schema-validation'})]]></code>
<code><![CDATA[isset($xmlRoot->{'shard-key'})]]></code>
<code><![CDATA[isset($xmlShardkey->{'option'})]]></code>
<code><![CDATA[isset($xmlShardkey->option)]]></code>
</RedundantCondition>
<TypeDoesNotContainType>
<code><![CDATA[$xmlRoot->getName() === 'document']]></code>
Expand Down

0 comments on commit 91539d8

Please sign in to comment.