mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
fc04a6ebdd
ReflectionAttribute::__construct() accepted any number of parameters until now, because parameter validation was missing. Even though this was unlikely to be an issue in practice (since the method is private), the problem is fixed by always throwing an exception.
26 lines
492 B
PHP
26 lines
492 B
PHP
--TEST--
|
|
ReflectionAttribute cannot be instantiated directly
|
|
--FILE--
|
|
<?php
|
|
#[Attribute]
|
|
class A {}
|
|
|
|
class Foo {
|
|
#[A]
|
|
public function bar() {}
|
|
}
|
|
|
|
$rm = new ReflectionMethod(Foo::class, "bar");
|
|
$attribute = $rm->getAttributes()[0];
|
|
|
|
$rm = new ReflectionMethod($attribute, "__construct");
|
|
|
|
try {
|
|
var_dump($rm->invoke($attribute, 0, 1, 2));
|
|
} catch (ReflectionException $exception) {
|
|
echo $exception->getMessage();
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Cannot directly instantiate ReflectionAttribute
|