-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Cleanup argument handling in ext/reflection #5850
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
Conversation
kocsismate
commented
Jul 12, 2020
- Renamed a few arguments
- Converted a few PHPDoc types to type delcarations
- Added necessary macros for ZPP
ext/reflection/php_reflection.c
Outdated
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
if (closure_obj) { | ||
fptr = (zend_function*)zend_get_closure_method_def_from_obj(closure_obj); | ||
} else { | ||
ALLOCA_FLAG(use_heap) |
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.
I don't know what ALLOCA_FLAG
does :/ But I have a suspicion that it was intentionally used only for the string parameter.
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.
You can move it into the branch doing the ZSTR_ALLOCA_ALLOC (to be more obvious).
e795a78
to
bb2baaa
Compare
bb2baaa
to
1bb4364
Compare
/** @param object|string $class_or_method */ | ||
public function __construct($class_or_method, string $name = UNKNOWN) {} | ||
/** @param object|string $objectOrMethodName */ | ||
public function __construct($objectOrMethodName, string $methodName = UNKNOWN) {} |
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.
The behaviour of $objectOrMethodName
seems a bit crazy to me (it accepts either an object or a method name in the Object::method
format). Should we deprecate it in the PHP 8.1 deprecations? And we could add a static ReflectionMethod::fromMethodName(string $methodName)
method as a replacement. ping @Girgias @nikic
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.
That one seems pretty whack indeed, I think having the replacement method in PHP 8.0 would be ideal so that we can deprecate it in 8.1.
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.
Yes, exactly my thoughts too! I can provide it in a separate PR if it doesn't need any kind of "bureaucracy" ^^
1bb4364
to
72e1525
Compare
72e1525
to
fb65dbe
Compare
Same as in zend_builtin_functions.c, I'm not really convinced about treating class names as a weak string parameter. Do you think we could get away with using CLASS_NAME_OR_OBJ, with the corresponding change in exception type? |
The reason why I reverted those changes is that we can't express at the type system's level, that a valid, autoloadable class is expected, so throwing a But please correct me if you spot any issue with this reasoning. :) |
fb65dbe
to
4096327
Compare
ext/reflection/php_reflection.c
Outdated
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
if (closure_obj) { | ||
fptr = (zend_function*)zend_get_closure_method_def_from_obj(closure_obj); | ||
} else { | ||
ALLOCA_FLAG(use_heap) |
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.
You can move it into the branch doing the ZSTR_ALLOCA_ALLOC (to be more obvious).
Fair enough. I guess it's safer to keep the ReflectionException. And as non-string will always throw anyway ( |
4096327
to
5759fbf
Compare