diff --git a/Zend/tests/009.phpt b/Zend/tests/009.phpt index ddf38e96f4e..f6dcbccb691 100644 --- a/Zend/tests/009.phpt +++ b/Zend/tests/009.phpt @@ -23,7 +23,16 @@ class foo2 extends foo { $f1 = new foo; $f2 = new foo2; -$f1->bar(); +set_error_handler(function ($severity, $message, $file, $line) { + throw new Exception($message); +}); +try { + $f1->bar(); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} +set_error_handler(null); + $f2->bar(); try { @@ -44,8 +53,10 @@ $f1->testNull(); echo "Done\n"; ?> ---EXPECT-- -string(3) "foo" +--EXPECTF-- +Calling get_class() without arguments is deprecated + +Deprecated: Calling get_class() without arguments is deprecated in %s on line %d string(3) "foo" get_class() without arguments must be called from within a class get_class(): Argument #1 ($object) must be of type object, string given diff --git a/Zend/tests/010.phpt b/Zend/tests/010.phpt index 467c7d9efc4..b439fbf9fb3 100644 --- a/Zend/tests/010.phpt +++ b/Zend/tests/010.phpt @@ -15,13 +15,23 @@ class foo implements i { class bar extends foo { function test_bar() { - var_dump(get_parent_class()); + var_dump(get_parent_class($this)); } } $bar = new bar; $foo = new foo; +set_error_handler(function ($severity, $message, $file, $line) { + throw new Exception($message); +}); +try { + $foo->test(); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} +set_error_handler(null); + $foo->test(); $bar->test(); $bar->test_bar(); @@ -66,8 +76,13 @@ try { echo "Done\n"; ?> ---EXPECT-- +--EXPECTF-- +Calling get_parent_class() without arguments is deprecated + +Deprecated: Calling get_parent_class() without arguments is deprecated in %s on line %d bool(false) + +Deprecated: Calling get_parent_class() without arguments is deprecated in %s on line %d bool(false) string(3) "foo" string(3) "foo" diff --git a/Zend/tests/class_alias_017.phpt b/Zend/tests/class_alias_017.phpt index bc2eaf54677..f07a1b5338a 100644 --- a/Zend/tests/class_alias_017.phpt +++ b/Zend/tests/class_alias_017.phpt @@ -26,8 +26,12 @@ baz::test(); bar::test(); ?> ---EXPECT-- +--EXPECTF-- foo baz + +Deprecated: Calling get_class() without arguments is deprecated in %s on line %d foo + +Deprecated: Calling get_class() without arguments is deprecated in %s on line %d foo diff --git a/Zend/tests/closure_058.phpt b/Zend/tests/closure_058.phpt index 5880492201d..8e4d9c5a2a1 100644 --- a/Zend/tests/closure_058.phpt +++ b/Zend/tests/closure_058.phpt @@ -4,10 +4,10 @@ Closure 058: Closure scope and object ---EXPECT-- +--EXPECTF-- +Deprecated: Calling get_class() without arguments is deprecated in %s on line %d string(4) "Test" string(12) "ExtendedTest" int(1) diff --git a/Zend/tests/get_parent_class_001.phpt b/Zend/tests/get_parent_class_001.phpt index fefcbeb6833..390073ad7a4 100644 --- a/Zend/tests/get_parent_class_001.phpt +++ b/Zend/tests/get_parent_class_001.phpt @@ -23,6 +23,9 @@ $a = new foo; $a->foo(); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Calling get_parent_class() without arguments is deprecated in %s on line %d string(3) "bar" + +Deprecated: Calling get_parent_class() without arguments is deprecated in %s on line %d bool(false) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 7e42226394f..35e69b4a25d 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -557,6 +557,10 @@ ZEND_FUNCTION(get_class) zend_class_entry *scope = zend_get_executed_scope(); if (scope) { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } RETURN_STR_COPY(scope->name); } else { zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); @@ -596,6 +600,10 @@ ZEND_FUNCTION(get_parent_class) ZEND_PARSE_PARAMETERS_END(); if (!ce) { + zend_error(E_DEPRECATED, "Calling get_parent_class() without arguments is deprecated"); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } ce = zend_get_executed_scope(); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 07784370dc1..b2e3e60a294 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -9355,13 +9355,17 @@ ZEND_VM_COLD_CONST_HANDLER(191, ZEND_GET_CLASS, UNUSED|CONST|TMPVAR|CV, UNUSED) USE_OPLINE if (OP1_TYPE == IS_UNUSED) { + SAVE_OPLINE(); if (UNEXPECTED(!EX(func)->common.scope)) { - SAVE_OPLINE(); zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); } else { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(func)->common.scope->name); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } ZEND_VM_NEXT_OPCODE(); } } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index eb7ef1624b9..1db9b06a178 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -10953,13 +10953,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_CLASS_SPEC_CO USE_OPLINE if (IS_CONST == IS_UNUSED) { + SAVE_OPLINE(); if (UNEXPECTED(!EX(func)->common.scope)) { - SAVE_OPLINE(); zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); } else { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(func)->common.scope->name); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } ZEND_VM_NEXT_OPCODE(); } } else { @@ -18217,13 +18221,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_CLASS_SPEC_TMPVAR_UNUSED_H USE_OPLINE if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + SAVE_OPLINE(); if (UNEXPECTED(!EX(func)->common.scope)) { - SAVE_OPLINE(); zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); } else { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(func)->common.scope->name); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } ZEND_VM_NEXT_OPCODE(); } } else { @@ -37032,13 +37040,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_CLASS_SPEC_UNUSED_UNUSED_H USE_OPLINE if (IS_UNUSED == IS_UNUSED) { + SAVE_OPLINE(); if (UNEXPECTED(!EX(func)->common.scope)) { - SAVE_OPLINE(); zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); } else { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(func)->common.scope->name); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } ZEND_VM_NEXT_OPCODE(); } } else { @@ -49848,13 +49860,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_CLASS_SPEC_CV_UNUSED_HANDL USE_OPLINE if (IS_CV == IS_UNUSED) { + SAVE_OPLINE(); if (UNEXPECTED(!EX(func)->common.scope)) { - SAVE_OPLINE(); zend_throw_error(NULL, "get_class() without arguments must be called from within a class"); ZVAL_UNDEF(EX_VAR(opline->result.var)); HANDLE_EXCEPTION(); } else { + zend_error(E_DEPRECATED, "Calling get_class() without arguments is deprecated"); ZVAL_STR_COPY(EX_VAR(opline->result.var), EX(func)->common.scope->name); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } ZEND_VM_NEXT_OPCODE(); } } else {