summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EXTENSIONS6
-rw-r--r--ext/reflection/php_reflection.c9
-rw-r--r--ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt24
3 files changed, 28 insertions, 11 deletions
diff --git a/EXTENSIONS b/EXTENSIONS
index 937aaf80ab..fff75c19b9 100644
--- a/EXTENSIONS
+++ b/EXTENSIONS
@@ -330,6 +330,7 @@ STATUS: Working
EXTENSION: gmp
PRIMARY MAINTAINER: Stanislav Malyshev <stas@php.net> (2000 - 2019)
Antony Dovgal <tony2001@php.net> (2005 - 2010)
+ Nikita Popov <nikic@php.net> (2013 - 2019)
MAINTENANCE: Maintained
STATUS: Working
SINCE: 4.0.4
@@ -378,12 +379,14 @@ STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: mbstring
PRIMARY MAINTAINER: Rui Hirokawa <hirokawa@php.net> (2001 - 2013)
+ Nikita Popov <nikic@php.net> (2017 - 2019)
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: opcache
PRIMARY MAINTAINER: Dmitry Stogov <dmitry@php.net> (2013 - 2018)
Xinchen Hui <laruence@php.net> (2013 - 2018)
+ Nikita Popov <nikic@php.net> (2016 - 2019)
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.5.0
@@ -500,7 +503,8 @@ STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: tokenizer
PRIMARY MAINTAINER: Andrei Zmievski <andrei@php.net> (2002 - 2002)
-MAINTENANCE: Unknown
+ Nikita Popov <nikic@php.net> (2013 - 2019)
+MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: zip
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index d6977a8a34..5f7dd80435 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4583,7 +4583,7 @@ ZEND_METHOD(reflection_class, isInstance)
}
/* }}} */
-/* {{{ proto public stdclass ReflectionClass::newInstance([mixed* args], ...)
+/* {{{ proto public object ReflectionClass::newInstance([mixed* args], ...)
Returns an instance of this class */
ZEND_METHOD(reflection_class, newInstance)
{
@@ -4657,7 +4657,7 @@ ZEND_METHOD(reflection_class, newInstance)
}
/* }}} */
-/* {{{ proto public stdclass ReflectionClass::newInstanceWithoutConstructor()
+/* {{{ proto public object ReflectionClass::newInstanceWithoutConstructor()
Returns an instance of this class without invoking its constructor */
ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
{
@@ -4666,7 +4666,8 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
GET_REFLECTION_OBJECT_PTR(ce);
- if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL) {
+ if (ce->type == ZEND_INTERNAL_CLASS
+ && ce->create_object != NULL && (ce->ce_flags & ZEND_ACC_FINAL)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ZSTR_VAL(ce->name));
return;
}
@@ -4675,7 +4676,7 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
}
/* }}} */
-/* {{{ proto public stdclass ReflectionClass::newInstanceArgs([array args])
+/* {{{ proto public object ReflectionClass::newInstanceArgs([array args])
Returns an instance of this class */
ZEND_METHOD(reflection_class, newInstanceArgs)
{
diff --git a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
index 334efc3a50..59337f09e8 100644
--- a/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
+++ b/ext/reflection/tests/ReflectionClass_newInstanceWithoutConstructor.phpt
@@ -22,7 +22,19 @@ $class = new ReflectionClass('DateTime');
var_dump($class->newInstanceWithoutConstructor());
$class = new ReflectionClass('Generator');
+try {
+ var_dump($class->newInstanceWithoutConstructor());
+} catch (ReflectionException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+final class Bar extends ArrayObject {
+}
+
+$class = new ReflectionClass('Bar');
var_dump($class->newInstanceWithoutConstructor());
+
+?>
--EXPECTF--
object(Foo)#%d (0) {
}
@@ -30,9 +42,9 @@ object(stdClass)#%d (0) {
}
object(DateTime)#%d (0) {
}
-
-Fatal error: Uncaught ReflectionException: Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor in %sReflectionClass_newInstanceWithoutConstructor.php:%d
-Stack trace:
-#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
-#1 {main}
- thrown in %sReflectionClass_newInstanceWithoutConstructor.php on line %d
+Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor
+object(Bar)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}