diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0a4c0adcfc0..6fb85154a76 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -6395,6 +6395,7 @@ ZEND_METHOD(ReflectionReference, getId) ZEND_METHOD(ReflectionAttribute, __construct) { + _DO_THROW("Cannot directly instantiate ReflectionAttribute"); } ZEND_METHOD(ReflectionAttribute, __clone) diff --git a/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt b/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt new file mode 100644 index 00000000000..ad895dc4243 --- /dev/null +++ b/ext/reflection/tests/ReflectionAttribute_constructor_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +ReflectionAttribute cannot be instantiated directly +--FILE-- +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