Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle PHP 8.1 types in proxies #949

Merged
merged 1 commit into from
Dec 22, 2021
Merged

Handle PHP 8.1 types in proxies #949

merged 1 commit into from
Dec 22, 2021

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Dec 21, 2021

This allows using never and intersection types in proxied classes. Fixes #948

@malarzm malarzm changed the base branch from 3.1.x to 3.2.x December 21, 2021 21:44
@malarzm malarzm force-pushed the php-8-1-types branch 3 times, most recently from 3176eac to 603ba0d Compare December 21, 2021 21:51
@@ -121,6 +121,8 @@ public function testDisablesOutput()
* @param array<string, int> $expected
*
* @dataProvider provideAttributesCases
*
* @requires PHP < 8.1.0
Copy link
Member Author

@malarzm malarzm Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow PHP 8.1 changed return order of stuff that Debug is returning. Given Debug is deprecated I'm not going to invest time in fixing its tests for newer PHP versions.

For the record, test fails with:
1) Doctrine\Tests\Common\Util\DebugTest::testExportParentAttributes with data set "different-attributes" (Doctrine\Tests\Common\Util\TestAsset\ChildClass Object (...), array(4, 5, 6, 1, 2, 3))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 '(
+    [childPublicAttribute] => 4
+    [childProtectedAttribute:protected] => 5
+    [childPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ChildClass:private] => 6
     [parentPublicAttribute] => 1
     [parentProtectedAttribute:protected] => 2
     [parentPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ParentClass:private] => 3
-    [childPublicAttribute] => 4
-    [childProtectedAttribute:protected] => 5
-    [childPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ChildClass:private] => 6
 )
 '

/home/runner/work/common/common/tests/Doctrine/Tests/Common/Util/DebugTest.php:133

2) Doctrine\Tests\Common\Util\DebugTest::testExportParentAttributes with data set "same-attributes" (Doctrine\Tests\Common\Util\TestAsset\ChildWithSameAttributesClass Object (...), array(4, 5, 6, 3))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 '(
     [parentPublicAttribute] => 4
     [parentProtectedAttribute:protected] => 5
+    [parentPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ChildWithSameAttributesClass:private] => 6
     [parentPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ParentClass:private] => 3
-    [parentPrivateAttribute:Doctrine\Tests\Common\Util\TestAsset\ChildWithSameAttributesClass:private] => 6
 )
 '

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 8.1 changed the order in which class memebers appear if an object is cast to an array.

@derrabus derrabus added the Bug label Dec 21, 2021
@derrabus derrabus added this to the 3.2.1 milestone Dec 21, 2021
@malarzm malarzm merged commit f3d530b into 3.2.x Dec 22, 2021
@malarzm malarzm deleted the php-8-1-types branch December 22, 2021 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempted to call an undefined method named "getName" of class "ReflectionIntersectionType"
2 participants