-
-
Notifications
You must be signed in to change notification settings - Fork 76
Added support for TypedNoDefaultReflectionProperty class to RuntimeReflectionService #90
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
Changes from all commits
51d4e70
af5b007
e5091a3
4f33e08
a03660b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |
| "doctrine/cache": "^1.0", | ||
| "doctrine/collections": "^1.0", | ||
| "doctrine/event-manager": "^1.0", | ||
| "doctrine/reflection": "^1.0" | ||
| "doctrine/reflection": "^1.1" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the dependency change, this will only be in 1.4 which will not be released until we've fixed the deprecation warnings in ORM and other libraries. See my other comment for a suggestion on how to fix this. |
||
| }, | ||
| "require-dev": { | ||
| "phpstan/phpstan": "^0.11", | ||
|
|
@@ -44,7 +44,8 @@ | |
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "Doctrine\\Tests\\": "tests/Doctrine/Tests" | ||
| "Doctrine\\Tests\\": "tests/Doctrine/Tests", | ||
| "Doctrine\\Tests_PHP74\\": "tests/Doctrine/Tests_PHP74" | ||
| } | ||
| }, | ||
| "extra": { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,10 +5,12 @@ | |||||
| namespace Doctrine\Persistence\Mapping; | ||||||
|
|
||||||
| use Doctrine\Common\Reflection\RuntimePublicReflectionProperty; | ||||||
| use Doctrine\Common\Reflection\TypedNoDefaultReflectionProperty; | ||||||
| use ReflectionClass; | ||||||
| use ReflectionException; | ||||||
| use ReflectionMethod; | ||||||
| use ReflectionProperty; | ||||||
| use function array_key_exists; | ||||||
| use function class_exists; | ||||||
| use function class_parents; | ||||||
|
|
||||||
|
|
@@ -64,7 +66,9 @@ public function getAccessibleProperty(string $class, string $property) | |||||
| { | ||||||
| $reflectionProperty = new ReflectionProperty($class, $property); | ||||||
|
|
||||||
| if ($reflectionProperty->isPublic()) { | ||||||
| if (! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this change, you can avoid the dependency bump and target 1.3 to fix this bug in a patch release:
Suggested change
|
||||||
| $reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property); | ||||||
| } elseif ($reflectionProperty->isPublic()) { | ||||||
| $reflectionProperty = new RuntimePublicReflectionProperty($class, $property); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Doctrine\Tests_PHP74\Persistence\Mapping; | ||
|
|
||
| use Doctrine\Common\Reflection\TypedNoDefaultReflectionProperty; | ||
| use Doctrine\Persistence\Mapping\RuntimeReflectionService; | ||
| use PHPUnit\Framework\TestCase; | ||
| use ReflectionProperty; | ||
|
|
||
| /** | ||
| * @group DCOM-93 | ||
| */ | ||
| class RuntimeReflectionServiceTest extends TestCase | ||
| { | ||
| /** @var RuntimeReflectionService */ | ||
| private $reflectionService; | ||
|
|
||
| private string $typedNoDefaultProperty; | ||
| private string $typedDefaultProperty = ''; | ||
|
|
||
| protected function setUp() : void | ||
| { | ||
| $this->reflectionService = new RuntimeReflectionService(); | ||
| } | ||
|
|
||
| public function testGetTypedNoDefaultReflectionProperty() : void | ||
| { | ||
| $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'typedNoDefaultProperty'); | ||
| self::assertInstanceOf(TypedNoDefaultReflectionProperty::class, $reflProp); | ||
| } | ||
|
|
||
| public function testGetTypedDefaultReflectionProperty() : void | ||
| { | ||
| $reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'typedDefaultProperty'); | ||
| self::assertInstanceOf(ReflectionProperty::class, $reflProp); | ||
| self::assertNotInstanceOf(TypedNoDefaultReflectionProperty::class, $reflProp); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A stable image is out