Closed
Description
Description
The following code:
<?php
#[Attribute(Random\IntervalBoundary::ClosedOpen)]
class Foo {
}
#[Foo]
function test1() {
}
$reflection = new ReflectionFunction('test1');
var_dump($reflection->getAttributes()[0]->newInstance());
?>
Resulted in this output:
Fatal error: Uncaught Error: Attribute "Foo" cannot target function (allowed targets: ) in php-src/test.php:13
Stack trace:
#0 php-src/test.php(13): ReflectionAttribute->newInstance()
#1 {main}
thrown in php-src/test.php on line 13
[Mon Apr 15 15:49:24 2024] Script: 'php-src/test.php'
php-src/Zend/zend_objects.c(189) : Freeing 0x000073dc9105c780 (56 bytes), script=php-src/test.php
=== Total 1 memory leaks detected ===
But I expected this output instead:
- No memory leak.
- Something related to the argument not being a correct integer.
PHP Version
git master
Operating System
Ubuntu 23.10