Skip to content

ReflectionParameter::__construct(): switch @param to typehint #16216

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ class ReflectionParameter implements Reflector
/** @implementation-alias ReflectionClass::__clone */
private function __clone(): void {}

/** @param string|array|object $function */
public function __construct($function, int|string $param) {}
public function __construct(string|array|object $function, int|string $param) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is

zend_argument_error(reflection_exception_ptr, 1, "must be a string, an array(class, method), or a callable object, %s given", zend_zval_value_name(reference));
dead code then?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, since it is still reached in

try {
new ReflectionParameter(0, 0);
}
catch(ReflectionException $e) {
printf( "Ok - %s\n", $e->getMessage());
}
echo "Done.\n";
?>
--EXPECT--
Class "A" does not exist
Method C::b() does not exist
Method C::b() does not exist
Ok - ReflectionParameter::__construct() expects exactly 2 arguments, 1 given
Ok - ReflectionParameter::__construct(): Argument #1 ($function) must be a string, an array(class, method), or a callable object, int given

The parameter is still parsed via Z_PARAM_ZVAL, rather than enforcing the types as part of the parsing


public function __toString(): string {}

Expand Down
4 changes: 2 additions & 2 deletions ext/reflection/php_reflection_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.