ReflectionClass::newInstanceWithoutConstructor() should be allowed to instantiate every class except those internal classes with a final __construct()

This commit is contained in:
Ferenc Kovacs 2014-07-23 07:45:02 +02:00
parent 43e956a9a1
commit d586441d90
3 changed files with 9 additions and 4 deletions

View file

@ -4308,8 +4308,8 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
METHOD_NOTSTATIC(reflection_class_ptr);
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->create_object != NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name);
if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class with a final __construct thus cannot be instantiated without invoking its constructor", ce->name);
}
object_init_ex(return_value, ce);