mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
2042fd34e0
RFC: https://wiki.php.net/rfc/fcc_in_const_expr Co-authored-by: Volker Dusch <volker@tideways-gmbh.com>
29 lines
594 B
PHP
29 lines
594 B
PHP
--TEST--
|
|
FCC in attribute may access private methods
|
|
--EXTENSIONS--
|
|
reflection
|
|
--FILE--
|
|
<?php
|
|
|
|
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
|
|
class Attr {
|
|
public function __construct(public Closure $value) {}
|
|
}
|
|
|
|
#[Attr(C::myMethod(...))]
|
|
class C {
|
|
private static function myMethod(string $foo) {
|
|
echo "Called ", __METHOD__, PHP_EOL;
|
|
var_dump($foo);
|
|
}
|
|
}
|
|
|
|
foreach ((new ReflectionClass(C::class))->getAttributes() as $reflectionAttribute) {
|
|
($reflectionAttribute->newInstance()->value)('abc');
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Called C::myMethod
|
|
string(3) "abc"
|