Files
php-src/ext/reflection/tests/ReflectionFunction_isDeprecated_magic_call.phpt
Tim Düsterhus 2e999bad34 Fix ReflectionFunction::isDeprecated() for materialized __call() (#17914)
* Fix `ReflectionFunction::isDeprecated()` for materialized `__call()`

Fixes php/php-src#17913

* NEWS
2025-02-27 14:48:08 +01:00

71 lines
1.3 KiB
PHP

--TEST--
GH-17913: ReflectionClassConstant::isDeprecated() with __call() and __callStatic()
--FILE--
<?php
class Clazz {
#[\Deprecated]
function __call(string $name, array $params) {
}
#[\Deprecated("due to some reason")]
static function __callStatic(string $name, array $params) {
}
}
$foo = new Clazz;
$closure = Closure::fromCallable([$foo, 'test']);
$rc = new ReflectionFunction($closure);
var_dump($rc->getAttributes()[0]->newInstance());
var_dump($rc->isDeprecated());
$closure = $foo->test(...);
$rc = new ReflectionFunction($closure);
var_dump($rc->getAttributes()[0]->newInstance());
var_dump($rc->isDeprecated());
$closure = Closure::fromCallable('Clazz::test');
$rc = new ReflectionFunction($closure);
var_dump($rc->getAttributes()[0]->newInstance());
var_dump($rc->isDeprecated());
$closure = Clazz::test(...);
$rc = new ReflectionFunction($closure);
var_dump($rc->getAttributes()[0]->newInstance());
var_dump($rc->isDeprecated());
?>
--EXPECTF--
object(Deprecated)#%d (2) {
["message"]=>
NULL
["since"]=>
NULL
}
bool(true)
object(Deprecated)#%d (2) {
["message"]=>
NULL
["since"]=>
NULL
}
bool(true)
object(Deprecated)#%d (2) {
["message"]=>
string(18) "due to some reason"
["since"]=>
NULL
}
bool(true)
object(Deprecated)#%d (2) {
["message"]=>
string(18) "due to some reason"
["since"]=>
NULL
}
bool(true)