Skip to content

Conversation

iluuu1994
Copy link
Member

Fixes GH-15309
Fixes GH-16175

Targetting 8.4 because of GH-16175, I'm aware this will probably not make it.


public function isReadable(?string $scope = 'static'): bool {}

public function isWritable(object $object, ?string $scope = 'static'): bool {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that object should be a nullable optional second parameter, because a property might be static. Also non-readonly properties can be checked without an object.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

--FILE--
<?php

class A {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have added some tests for traits. For example, a test ensuring that protected properties from a shared trait are not accessible (https://3v4l.org/hM5TM). Also a trait must not be accepted as a scope.

This comment was marked as duplicate.

@@ -569,6 +569,10 @@ public function hasHook(PropertyHookType $type): bool {}
public function getHook(PropertyHookType $type): ?ReflectionMethod {}

public function isFinal(): bool {}

public function isReadable(?string $scope = 'static'): bool {}
Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about this some more, it would likely be beneficial to also accept the object here and check it for IS_UNDEF.

Copy link
Contributor

Choose a reason for hiding this comment

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

What IS_UNDEF means in userland?

Copy link
Member Author

Choose a reason for hiding this comment

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

unset() properties or typed properties that have not been assigned to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then yes, it would be great to have an object parameter here.

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

Successfully merging this pull request may close these issues.

ReflectionProperty::isPrivateSet() not working as expected ReflectionClass can't detect readonly properties for mysqli
3 participants