Skip to content

Added support for TypedNoDefaultReflectionProperty class to RuntimeReflectionService#90

Closed
sspat wants to merge 5 commits intodoctrine:masterfrom
sspat:add_typed_no_default_reflection_property_class_usage
Closed

Added support for TypedNoDefaultReflectionProperty class to RuntimeReflectionService#90
sspat wants to merge 5 commits intodoctrine:masterfrom
sspat:add_typed_no_default_reflection_property_class_usage

Conversation

@sspat
Copy link

@sspat sspat commented Jan 9, 2020

Implementation for issue #89
See discussion in doctrine/orm#7857

As suggested by @beberlei, the Doctrine\Common\Reflection\TypedNoDefaultReflectionProperty class was introduced and the Doctrine\Persistence\Mapping\RuntimeReflectionService::getAccessibleProperty returns an instance of this class if the property is typed and has no default value.

@sspat
Copy link
Author

sspat commented Jan 9, 2020

Also updated phpunit config to allow running tests with php 7.4 syntax.

script: ./vendor/bin/phpcs

- stage: Code Quality
php: 7.4snapshot
Copy link
Member

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

Suggested change
php: 7.4snapshot
php: 7.4

"doctrine/collections": "^1.0",
"doctrine/event-manager": "^1.0",
"doctrine/reflection": "^1.0"
"doctrine/reflection": "^1.1"
Copy link
Member

Choose a reason for hiding this comment

The 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.

$reflectionProperty = new ReflectionProperty($class, $property);

if ($reflectionProperty->isPublic()) {
if (! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) {
Copy link
Member

Choose a reason for hiding this comment

The 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
if (! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) {
if (class_exists(TypedNoDefaultReflectionProperty::class) && ! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) {

@beberlei
Copy link
Member

Closed in favor of #94

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