-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Reflection: indicate final properties in string output #17827
base: PHP-8.4
Are you sure you want to change the base?
Reflection: indicate final properties in string output #17827
Conversation
CC @iluuu1994 - my understanding is that final properties was added as a part of property hooks |
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.
Thank you! Indeed, this was missed in the implementation. This should also add abstract
, which was added in the same PR. It should also target 8.4+.
@@ -931,6 +931,9 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha | |||
if (!prop) { | |||
smart_str_append_printf(str, "<dynamic> public $%s", prop_name); | |||
} else { | |||
if (prop->flags & ZEND_ACC_FINAL) { | |||
smart_str_appends(str, "final "); | |||
} |
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.
Can you move this down to ZEND_ACC_STATIC
? Granted, this is inconsistent with the order for methods, but final public static $prop;
is weird.
The order seems to be abstract
/final
/static
for other structures.
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.
For me public final
sounds odd, and public abstract
would sound even odder - https://www.php.net/manual/en/language.oop5.abstract.php put abstract before visibility for properties, I didn't see any examples of final properties to compare with.
I tried to do a code search in github but the regex wasn't cooperating with me to match property declarations. Looking through the property hooks implementation PR, I see
Zend/tests/property_hooks/final_private_prop.phpt
->final private ...
Zend/tests/property_hooks/final_prop.phpt
->public final ...
Zend/tests/property_hooks/final_prop_2.phpt
->public final ...
Zend/tests/property_hooks/final_prop_final_hook.phpt
->final public ...
in consecutive test files.
Without a standard practice one way or the other, I figured it was better to be consistent with methods
Add "final" to the result of `_property_string()` when outputting the string representation of a `ReflectionClass` or `ReflectionProperty` instance
Add "abstract" to the result of `_property_string()` when outputting the string representation of a `ReflectionClass` or `ReflectionProperty` instance
438de46
to
1334776
Compare
Added I didn't send this to 8.4 originally since it isn't really a bug, but retargeted. I was planning to also work on some kind of indication of property hooks in a follow-up, should that also go to 8.4? |
I would classify this as a bug. Whether your other PR should target 8.4 depends on whether it's a bug. 😄 |
Add "final" to the result of
_property_string()
when outputting the string representation of aReflectionClass
orReflectionProperty
instance