Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik commented Aug 20, 2022

Int key "1" unordered key defined is valid in Doctrine\ORM\Mapping\DiscriminatorMap per issue

that was resolved at:

It changed to string in latest PR:

This PR rollback the transformation fixture for integer unorder key fixture to avoid regression.

@samsonasik samsonasik changed the title [Php80] Rollback preserver int key defined Fixture on AnnotationToAttributeRector [Php80] Rollback preserve int key defined Fixture on AnnotationToAttributeRector Aug 20, 2022
@samsonasik samsonasik force-pushed the rollback-preserve-int-key-defined-fixture branch from 997f2b5 to a07b46e Compare August 20, 2022 20:51
@samsonasik
Copy link
Member Author

rebased.

@samsonasik samsonasik changed the title [Php80] Rollback preserve int key defined Fixture on AnnotationToAttributeRector [Php80] Rollback preserve int key defined not start from 0 Fixture on AnnotationToAttributeRector Aug 20, 2022
@samsonasik
Copy link
Member Author

It seems cause error:

There was 1 failure:

1) Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\AnnotationToAttributeRectorTest::test with data set #14 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
rules-tests/Php80/Rector/Class_/AnnotationToAttributeRector/Fixture/Doctrine/preserve_int_key_defined.php.inc
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 
 use Doctrine\ORM\Mapping as ORM;
 
-#[ORM\DiscriminatorMap([1 => 'CostDetailEntity'])]
+#[ORM\DiscriminatorMap(['1' => 'CostDetailEntity'])]

@samsonasik
Copy link
Member Author

@TomasVotruba the Doctrine\ORM\Mapping\DiscriminatorMap is allow @param array<int|string, string> $value ref

https://github.com/doctrine/orm/blob/5283e1441cc020d526d4842c6bfa21c1a500886d/lib/Doctrine/ORM/Mapping/DiscriminatorMap.php#L22

the change seems make it single quoted to make CI green now e0f9d16 , compared to real integer on original PR :

#2735

@samsonasik
Copy link
Member Author

Fixed 🎉 by update CurlyListNodeAnnotationToAttributeMapper 34f87fe with the following summary:

  • the values of CurlyListNode are always integer keyed ordered from 0, so no need to check $key
  • per-each data is an ArrayItemNode object, that has key property
  • that key property need to be checked against ordered key order from 0, if it is numeric and not ordered, then create ArrayItem using its key property.

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 790ca8c into main Aug 20, 2022
@TomasVotruba TomasVotruba deleted the rollback-preserve-int-key-defined-fixture branch August 20, 2022 21:53
@TomasVotruba
Copy link
Member

Thank you ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants