Merge branch 'PHP-8.0'

* PHP-8.0:
  Fixed bug #81208
This commit is contained in:
Nikita Popov 2021-07-01 13:37:53 +02:00
commit adfa585109
2 changed files with 29 additions and 1 deletions

View file

@ -6623,7 +6623,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
for (uint32_t i = 0; i < attr->data->argc; i++) {
zval val;
if (FAILURE == zend_get_attribute_value(&val, attr->data, i, attr->scope)) {
attribute_ctor_cleanup(&obj, args, i, named_params);
attribute_ctor_cleanup(&obj, args, argc, named_params);
RETURN_THROWS();
}
if (attr->data->args[i].name) {

View file

@ -0,0 +1,28 @@
--TEST--
Bug #81208: Segmentation fault while create newInstance from attribute
--FILE--
<?php
#[Attribute(Attribute::TARGET_PROPERTY)]
class MyAnnotation
{
public function __construct(public bool $nullable = false) {}
}
class MyClass {
#[MyAnnotation(name: "my_name", type: "integer", nullable: asdasdasd)]
public $property;
}
$z = new ReflectionClass(MyClass::class);
foreach ($z->getProperty("property")->getAttributes() as $attribute) {
try {
$attribute->newInstance();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
}
?>
--EXPECT--
Undefined constant "asdasdasd"