Skip to content

Commit 3dda2d4

Browse files
committed
Throw the exception inside the non instantiable constructor
1 parent 55a88af commit 3dda2d4

3 files changed

Lines changed: 9 additions & 49 deletions

File tree

Zend/zend_compile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9531,6 +9531,8 @@ static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_
95319531

95329532
static ZEND_FUNCTION(non_instantiable_constructor)
95339533
{
9534+
ZEND_ASSERT(hasThis());
9535+
zend_cannot_instantiate_class(Z_OBJCE_P(ZEND_THIS), NULL);
95349536
}
95359537

95369538
static zend_arg_info zend_non_instantiable_constructor_arg_info[1] = {0};

Zend/zend_vm_def.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,13 +6002,7 @@ ZEND_VM_HANDLER(68, ZEND_NEW, UNUSED|CLASS_FETCH|CONST|VAR, UNUSED|CACHE_SLOT, N
60026002
}
60036003

60046004
result = EX_VAR(opline->result.var);
6005-
const zend_class_entry *scope = EX(func)->op_array.scope;
6006-
if (UNEXPECTED(!zend_check_class_is_instantiable_or_throw(ce, scope))) {
6007-
ZVAL_UNDEF(result);
6008-
HANDLE_EXCEPTION();
6009-
}
6010-
6011-
if (UNEXPECTED(object_init_instantiable_class(result, ce) != SUCCESS)) {
6005+
if (UNEXPECTED(object_init_ex(result, ce) != SUCCESS)) {
60126006
ZVAL_UNDEF(result);
60136007
HANDLE_EXCEPTION();
60146008
}

Zend/zend_vm_execute.h

Lines changed: 6 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)