From: Nikita Popov Date: Tue, 29 Jan 2019 11:14:54 +0000 (+0100) Subject: Remove support for legacy constructors X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=682b54f68748715f85e9ac4a267477d9ac61918a;p=php Remove support for legacy constructors This has been deprecated in PHP 7.0 by https://wiki.php.net/rfc/remove_php4_constructors. --- diff --git a/UPGRADING b/UPGRADING index 2087adb715..9333a94dd7 100644 --- a/UPGRADING +++ b/UPGRADING @@ -21,6 +21,8 @@ PHP 8.0 UPGRADE NOTES ======================================== - Core: + . Methods with the same name as the class are no longer interpreted as + constructors. The __construct() method should be used instead. . Removed (unset) cast. . Removed track_errors ini directive. This means that $php_errormsg is no longer available. The error_get_last() function may be used instead. diff --git a/Zend/tests/bug38942.phpt b/Zend/tests/bug38942.phpt deleted file mode 100644 index d0335b1071..0000000000 --- a/Zend/tests/bug38942.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -Bug #38942 (Double old-style-ctor inheritance) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d -Array -( - [0] => foo -) diff --git a/Zend/tests/bug39127.phpt b/Zend/tests/bug39127.phpt deleted file mode 100644 index 31fb6d27d5..0000000000 --- a/Zend/tests/bug39127.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Bug #39127 (Old-style constructor fallbacks produce strange results) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; a has a deprecated constructor in %s on line %d -string(13) "a::a() called" -bool(true) -bool(false) -bool(false) -Done diff --git a/Zend/tests/bug40784.phpt b/Zend/tests/bug40784.phpt deleted file mode 100644 index ac2b2331b2..0000000000 --- a/Zend/tests/bug40784.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Bug #40784 (Case sensivity in constructor's fallback) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -I'm A -I'm A -Done diff --git a/Zend/tests/bug43323.phpt b/Zend/tests/bug43323.phpt deleted file mode 100644 index 74abe766e5..0000000000 --- a/Zend/tests/bug43323.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -Bug #43323 (Wrong count abstract methods) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; testClass has a deprecated constructor in %s on line %d -testClass::testClass (1) -testClass::testClass (2) -testClass::testClass (3) -testClass::testClass (4) -testClass::testClass (5) diff --git a/Zend/tests/bug52051.phpt b/Zend/tests/bug52051.phpt deleted file mode 100644 index acfddbc36d..0000000000 --- a/Zend/tests/bug52051.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Bug #52051 (handling of case sensitivity of old-style constructors changed in 5.3+) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; AA has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; CC has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in %s on line %d -foo -bar diff --git a/Zend/tests/bug52160.phpt b/Zend/tests/bug52160.phpt deleted file mode 100644 index a0e5a9d7ae..0000000000 --- a/Zend/tests/bug52160.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Bug #52160 (Invalid E_STRICT redefined constructor error) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; baz has a deprecated constructor in %s on line %d - -Fatal error: Constructor baz::baz() cannot be static in %s on line %d diff --git a/Zend/tests/dynamic_call_001.phpt b/Zend/tests/dynamic_call_001.phpt deleted file mode 100644 index 7f8a6c0b3d..0000000000 --- a/Zend/tests/dynamic_call_001.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Testing dynamic call to constructor (old-style) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d - -Fatal error: Uncaught Error: Non-static method foo::foo() cannot be called statically in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d diff --git a/Zend/tests/return_types/023.phpt b/Zend/tests/return_types/023.phpt deleted file mode 100644 index e8e8732ef1..0000000000 --- a/Zend/tests/return_types/023.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -PHP 4 Constructors cannot declare a return type ---FILE-- -isConstructor()); - -$rbarfoo = new ReflectionMethod('Bar::Foo'); -var_dump($rbarfoo->isConstructor()); - -$rbarbar = new ReflectionMethod('Bar::Bar'); -var_dump($rbarbar->isConstructor()); -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Bar has a deprecated constructor in %s on line %d -bool(false) -bool(false) -bool(true) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index a6aa4e5837..2ec6d34145 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2262,13 +2262,8 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } if (scope) { - /* Look for ctor, dtor, clone - * If it's an old-style constructor, store it only if we don't have - * a constructor already. - */ - if ((fname_len == class_name_len) && !ctor && !memcmp(ZSTR_VAL(lowercase_name), lc_class_name, class_name_len+1)) { - ctor = reg_function; - } else if (ZSTR_VAL(lowercase_name)[0] != '_' || ZSTR_VAL(lowercase_name)[1] != '_') { + /* Look for ctor, dtor, clone */ + if (ZSTR_VAL(lowercase_name)[0] != '_' || ZSTR_VAL(lowercase_name)[1] != '_') { reg_function = NULL; } else if (zend_string_equals_literal(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME)) { ctor = reg_function; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cfe03e71f9..0d7f8b1b25 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5539,7 +5539,6 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo { zend_class_entry *ce = CG(active_class_entry); zend_bool in_interface = (ce->ce_flags & ZEND_ACC_INTERFACE) != 0; - zend_bool in_trait = (ce->ce_flags & ZEND_ACC_TRAIT) != 0; zend_bool is_public = (op_array->fn_flags & ZEND_ACC_PUBLIC) != 0; zend_bool is_static = (op_array->fn_flags & ZEND_ACC_STATIC) != 0; @@ -5631,11 +5630,7 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo } } } else { - if (!in_trait && zend_string_equals_ci(lcname, ce->name)) { - if (!ce->constructor) { - ce->constructor = (zend_function *) op_array; - } - } else if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { + if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { if (!is_static) { op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC; } @@ -6253,11 +6248,6 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ /* Reset lineno for final opcodes and errors */ CG(zend_lineno) = ast->lineno; - if (!(ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS)) { - /* For traits this check is delayed until after trait binding */ - zend_check_deprecated_constructor(ce); - } - if (ce->constructor) { if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 9dc26088f7..804e16dda6 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1287,14 +1287,11 @@ static void zend_do_implement_interfaces(zend_class_entry *ce) /* {{{ */ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */ { - if (ZSTR_LEN(ce->name) != ZSTR_LEN(mname) && (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_')) { + if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') { /* pass */ } else if (zend_string_equals_literal(mname, ZEND_CLONE_FUNC_NAME)) { ce->clone = fe; } else if (zend_string_equals_literal(mname, ZEND_CONSTRUCTOR_FUNC_NAME)) { - if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { - zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name)); - } ce->constructor = fe; } else if (zend_string_equals_literal(mname, ZEND_DESTRUCTOR_FUNC_NAME)) { ce->destructor = fe; @@ -1318,16 +1315,6 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen ce->__tostring = fe; } else if (zend_string_equals_literal(mname, ZEND_DEBUGINFO_FUNC_NAME)) { ce->__debugInfo = fe; - } else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) { - zend_string *lowercase_name = zend_string_tolower(ce->name); - lowercase_name = zend_new_interned_string(lowercase_name); - if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) { - if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { - zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name)); - } - ce->constructor = fe; - } - zend_string_release_ex(lowercase_name, 0); } } /* }}} */ @@ -1934,32 +1921,6 @@ static void zend_do_bind_traits(zend_class_entry *ce) /* {{{ */ zend_do_traits_property_binding(ce, traits); efree(traits); - - /* Emit E_DEPRECATED for PHP 4 constructors */ - zend_check_deprecated_constructor(ce); -} -/* }}} */ - - -static zend_bool zend_has_deprecated_constructor(const zend_class_entry *ce) /* {{{ */ -{ - const zend_string *constructor_name; - if (!ce->constructor) { - return 0; - } - constructor_name = ce->constructor->common.function_name; - return !zend_binary_strcasecmp( - ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), - ZSTR_VAL(constructor_name), ZSTR_LEN(constructor_name) - ); -} -/* }}} */ - -void zend_check_deprecated_constructor(const zend_class_entry *ce) /* {{{ */ -{ - if (zend_has_deprecated_constructor(ce)) { - zend_error(E_DEPRECATED, "Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor", ZSTR_VAL(ce->name)); - } } /* }}} */ diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h index a882f6461f..341edbeab9 100644 --- a/Zend/zend_inheritance.h +++ b/Zend/zend_inheritance.h @@ -30,7 +30,6 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent ZEND_API void zend_do_link_class(zend_class_entry *ce, zend_class_entry *parent_ce); void zend_verify_abstract_class(zend_class_entry *ce); -void zend_check_deprecated_constructor(const zend_class_entry *ce); void zend_build_properties_info_table(zend_class_entry *ce); END_EXTERN_C() diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt index 36ae406b43..924c3fe283 100644 --- a/ext/reflection/tests/004.phpt +++ b/ext/reflection/tests/004.phpt @@ -4,7 +4,7 @@ ReflectionMethod::invoke() with non object or null value getMethod("a"); +$m=$a->getMethod("__construct"); try { $m->invoke(null); @@ -35,9 +35,7 @@ try { echo $E->getMessage()."\n"; } -echo "===DONE===\n";?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; a has a deprecated constructor in %s on line %d -Trying to invoke non static method a::a() without an object +?> +--EXPECT-- +Trying to invoke non static method a::__construct() without an object Given object is not an instance of the class this method was declared in -===DONE=== diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt index 5db9d8f3d3..df6880aedb 100644 --- a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt @@ -9,48 +9,7 @@ class NewCtor { class ExtendsNewCtor extends NewCtor { } -class OldCtor { - function OldCtor() {} -} - -class ExtendsOldCtor extends OldCtor { -} - - -class X { - function Y() {} -} - -class Y extends X { -} - -class OldAndNewCtor { - function OldAndNewCtor() {} - function __construct() {} -} - -class NewAndOldCtor { - function __construct() {} - function NewAndOldCtor() {} -} -class B { - function B() {} -} - -class C extends B { - function C() {} -} - -class D1 extends C { - function __construct() {} -} - -class D2 extends C { -} - -$classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', - 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); - +$classes = array('NewCtor', 'ExtendsNewCtor'); foreach ($classes as $class) { $rc = new ReflectionClass($class); $rm = $rc->getConstructor(); @@ -63,21 +22,6 @@ foreach ($classes as $class) { } ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in %s on line %d +--EXPECT-- Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct -Constructor of OldCtor: OldCtor -Constructor of ExtendsOldCtor: OldCtor -Constructor of OldAndNewCtor: __construct -Constructor of NewAndOldCtor: __construct -Constructor of B: B -Constructor of C: C -Constructor of D1: __construct -Constructor of D2: C -No constructor for X -No constructor for Y diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt index 5263643023..e192e436f0 100644 --- a/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt +++ b/ext/reflection/tests/ReflectionClass_isInstantiable_error.phpt @@ -2,18 +2,16 @@ ReflectionClass::IsInstantiable() --FILE-- IsInstantiable('X')); var_dump($reflectionClass->IsInstantiable(0, null)); ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d - Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt index 1378edd3d2..e688b40f46 100644 --- a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt +++ b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt @@ -17,39 +17,16 @@ class privateCtorNew { private function __construct() {} } -class publicCtorOld { - public function publicCtorOld() {} -} - -class protectedCtorOld { - protected function protectedCtorOld() {} -} - -class privateCtorOld { - private function privateCtorOld() {} -} - - -$classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew", - "publicCtorOld", "protectedCtorOld", "privateCtorOld"); - -foreach($classes as $class ) { +$classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew"); +foreach ($classes as $class) { $reflectionClass = new ReflectionClass($class); echo "Is $class instantiable? "; var_dump($reflectionClass->IsInstantiable()); } ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d +--EXPECT-- Is noCtor instantiable? bool(true) Is publicCtorNew instantiable? bool(true) Is protectedCtorNew instantiable? bool(false) Is privateCtorNew instantiable? bool(false) -Is publicCtorOld instantiable? bool(true) -Is protectedCtorOld instantiable? bool(false) -Is privateCtorOld instantiable? bool(false) diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt index 068710311d..11bd44077f 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt @@ -5,11 +5,6 @@ Robin Fernandes Steve Seear --FILE-- newInstanceArgs()); -} catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; -} -try { - var_dump($rcA->newInstanceArgs(array('x'))); -} catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; -} - try { var_dump($rcB->newInstanceArgs()); } catch (Throwable $e) { echo "Exception: " . $e->getMessage() . "\n"; } + try { var_dump($rcB->newInstanceArgs(array('x', 123))); } catch (Throwable $e) { @@ -85,13 +69,6 @@ try { } ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -In constructor of class A -object(A)#%d (0) { -} -In constructor of class A -object(A)#%d (0) { -} Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected In constructor of class B with args x, 123 object(B)#%d (0) { diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt index c91d2ee958..bf68098a7d 100644 --- a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt @@ -5,11 +5,6 @@ Robin Fernandes Steve Seear --FILE-- newInstance(); -$a2 = $rcA->newInstance('x'); -var_dump($a1, $a2); - try { var_dump($rcB->newInstance()); } catch (Throwable $e) { @@ -78,13 +68,6 @@ try { } ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -In constructor of class A -In constructor of class A -object(A)#%d (0) { -} -object(A)#%d (0) { -} Exception: Too few arguments to function B::__construct(), 0 passed and exactly 2 expected In constructor of class B with args x, 123 object(B)#%d (0) { diff --git a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt index 243c59504b..da108d258d 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt @@ -19,21 +19,6 @@ echo "\nInherited new-style constructor\n"; $methodInfo = new ReflectionMethod("ExtendsNewCtor::__construct"); var_dump($methodInfo->isConstructor()); -class OldCtor { - function OldCtor() { - echo "In " . __METHOD__ . "\n"; - } -} -echo "\nOld-style constructor:\n"; -$methodInfo = new ReflectionMethod("OldCtor::OldCtor"); -var_dump($methodInfo->isConstructor()); - -class ExtendsOldCtor extends OldCtor { -} -echo "\nInherited old-style constructor:\n"; -$methodInfo = new ReflectionMethod("ExtendsOldCtor::OldCtor"); -var_dump($methodInfo->isConstructor()); - class X { function Y() { echo "In " . __METHOD__ . "\n"; @@ -49,69 +34,16 @@ echo "\nInherited method of the same name as the class:\n"; $methodInfo = new ReflectionMethod("Y::Y"); var_dump($methodInfo->isConstructor()); -class OldAndNewCtor { - function OldAndNewCtor() { - echo "In " . __METHOD__ . "\n"; - } - - function __construct() { - echo "In " . __METHOD__ . "\n"; - } -} -echo "\nOld-style constructor:\n"; -$methodInfo = new ReflectionMethod("OldAndNewCtor::OldAndNewCtor"); -var_dump($methodInfo->isConstructor()); - -echo "\nRedefined constructor:\n"; -$methodInfo = new ReflectionMethod("OldAndNewCtor::__construct"); -var_dump($methodInfo->isConstructor()); - -class NewAndOldCtor { - function __construct() { - echo "In " . __METHOD__ . "\n"; - } - - function NewAndOldCtor() { - echo "In " . __METHOD__ . "\n"; - } -} -echo "\nNew-style constructor:\n"; -$methodInfo = new ReflectionMethod("NewAndOldCtor::__construct"); -var_dump($methodInfo->isConstructor()); - -echo "\nRedefined old-style constructor:\n"; -$methodInfo = new ReflectionMethod("NewAndOldCtor::NewAndOldCtor"); -var_dump($methodInfo->isConstructor()); - ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d +--EXPECT-- New-style constructor: bool(true) Inherited new-style constructor bool(true) -Old-style constructor: -bool(true) - -Inherited old-style constructor: -bool(true) - Not a constructor: bool(false) Inherited method of the same name as the class: bool(false) - -Old-style constructor: -bool(false) - -Redefined constructor: -bool(true) - -New-style constructor: -bool(true) - -Redefined old-style constructor: -bool(false) diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt index aecc9b97d2..fee873fe01 100644 --- a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt @@ -9,14 +9,6 @@ class NewCtor { class ExtendsNewCtor extends NewCtor { } -class OldCtor { - function OldCtor() {} -} - -class ExtendsOldCtor extends OldCtor { -} - - class X { function Y() {} } @@ -24,15 +16,6 @@ class X { class Y extends X { } -class OldAndNewCtor { - function OldAndNewCtor() {} - function __construct() {} -} - -class NewAndOldCtor { - function __construct() {} - function NewAndOldCtor() {} -} class B { function B() {} } @@ -48,8 +31,8 @@ class D1 extends C { class D2 extends C { } -$classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor', - 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y'); +$classes = array('NewCtor', 'ExtendsNewCtor', + 'B', 'C', 'D1', 'D2', 'X', 'Y'); foreach ($classes as $class) { $rc = new ReflectionObject(new $class); @@ -63,21 +46,12 @@ foreach ($classes as $class) { } ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; C has a deprecated constructor in %s on line %d +--EXPECT-- Constructor of NewCtor: __construct Constructor of ExtendsNewCtor: __construct -Constructor of OldCtor: OldCtor -Constructor of ExtendsOldCtor: OldCtor -Constructor of OldAndNewCtor: __construct -Constructor of NewAndOldCtor: __construct -Constructor of B: B -Constructor of C: C +No constructor for B +No constructor for C Constructor of D1: __construct -Constructor of D2: C +No constructor for D2 No constructor for X No constructor for Y diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt index f6d4c9d3d2..f24958421f 100644 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstantiable_error.phpt @@ -2,21 +2,19 @@ ReflectionObject::IsInstantiable() - invalid params --FILE-- IsInstantiable('X')); var_dump($reflectionObject->IsInstantiable(0, null)); ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d - Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d NULL diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt index 675bbdde8d..3baa8a0950 100644 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt @@ -30,54 +30,21 @@ class privateCtorNew { } } -class publicCtorOld { - public function publicCtorOld() {} - public static function reflectionObjectFactory() { - return new ReflectionObject(new self); - } -} - -class protectedCtorOld { - protected function protectedCtorOld() {} - public static function reflectionObjectFactory() { - return new ReflectionObject(new self); - } -} - -class privateCtorOld { - private function privateCtorOld() {} - public static function reflectionObjectFactory() { - return new ReflectionObject(new self); - } -} - - $reflectionObjects = array( noCtor::reflectionObjectFactory(), publicCtorNew::reflectionObjectFactory(), protectedCtorNew::reflectionObjectFactory(), privateCtorNew::reflectionObjectFactory(), - publicCtorOld::reflectionObjectFactory(), - protectedCtorOld::reflectionObjectFactory(), - privateCtorOld::reflectionObjectFactory() ); -foreach($reflectionObjects as $reflectionObject ) { +foreach ($reflectionObjects as $reflectionObject) { $name = $reflectionObject->getName(); echo "Is $name instantiable? "; var_dump($reflectionObject->IsInstantiable()); } ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d +--EXPECT-- Is noCtor instantiable? bool(true) Is publicCtorNew instantiable? bool(true) Is protectedCtorNew instantiable? bool(false) Is privateCtorNew instantiable? bool(false) -Is publicCtorOld instantiable? bool(true) -Is protectedCtorOld instantiable? bool(false) -Is privateCtorOld instantiable? bool(false) diff --git a/ext/reflection/tests/bug30148.phpt b/ext/reflection/tests/bug30148.phpt deleted file mode 100644 index 27c31ca6ae..0000000000 --- a/ext/reflection/tests/bug30148.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Reflection Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes) ---FILE-- -isConstructor()); -var_dump($b->isConstructor()); -var_dump($c->isConstructor()); -var_dump($d->isConstructor()); -var_dump($e->isConstructor()); -?> -===DONE=== ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Root has a deprecated constructor in %s on line %d -bool(true) -bool(false) -bool(true) -bool(false) -bool(true) -===DONE=== diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt deleted file mode 100644 index 59666607cb..0000000000 --- a/ext/reflection/tests/bug38942.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -Bug #38942 (Double old-style-ctor inheritance) ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d -Class [ class bar extends foo ] { - @@ %sbug38942.php 6-7 - - - Constants [0] { - } - - - Static properties [0] { - } - - - Static methods [0] { - } - - - Properties [0] { - } - - - Methods [1] { - Method [ public method foo ] { - @@ %sbug38942.php 3 - 3 - } - } -} diff --git a/ext/reflection/tests/bug47254.phpt b/ext/reflection/tests/bug47254.phpt index e3ce114c9c..b6f33fcfc6 100644 --- a/ext/reflection/tests/bug47254.phpt +++ b/ext/reflection/tests/bug47254.phpt @@ -23,10 +23,7 @@ $m = $R->getMethods(); print_r($m); ?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d +--EXPECT-- Array ( [0] => ReflectionMethod Object diff --git a/tests/classes/ctor_name_clash.phpt b/tests/classes/ctor_name_clash.phpt deleted file mode 100644 index e6518775ff..0000000000 --- a/tests/classes/ctor_name_clash.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ZE2 The child class can re-use the parent class name for a function member ---FILE-- -base(); -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; base has a deprecated constructor in %s on line %d -base::base -derived::base diff --git a/tests/classes/final_ctor1.phpt b/tests/classes/final_ctor1.phpt index acf20918fd..33fcbe6bd8 100644 --- a/tests/classes/final_ctor1.phpt +++ b/tests/classes/final_ctor1.phpt @@ -16,15 +16,11 @@ class Works extends Base class Extended extends Base { - public function Extended() + public function __construct() { } } -ReflectionClass::export('Extended'); - ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Extended has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final Base::__construct() with Extended::Extended() in %sfinal_ctor1.php on line %d +Fatal error: Cannot override final method Base::__construct() in %s on line %d diff --git a/tests/classes/final_ctor2.phpt b/tests/classes/final_ctor2.phpt deleted file mode 100644 index 37fcac29a9..0000000000 --- a/tests/classes/final_ctor2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -ZE2 cannot override final old style ctor ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Base has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final Base::Base() with Extended::__construct() in %sfinal_ctor2.php on line %d diff --git a/tests/classes/final_ctor3.phpt b/tests/classes/final_ctor3.phpt deleted file mode 100644 index b34996c979..0000000000 --- a/tests/classes/final_ctor3.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Ensure implicit final inherited old-style constructor cannot be overridden. ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final method A::A() in %s on line %d diff --git a/tests/classes/inheritance_002.phpt b/tests/classes/inheritance_002.phpt deleted file mode 100644 index f88c0996bd..0000000000 --- a/tests/classes/inheritance_002.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -ZE2 Constructor precedence ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Base_php4 has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_php4 has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_mx2 has a deprecated constructor in %s on line %d -### PHP 4 style -string(17) "Child constructor" -string(16) "Base constructor" -### PHP 5 style -string(17) "Child constructor" -string(16) "Base constructor" -### Mixed style 1 -string(17) "Child constructor" -string(16) "Base constructor" -### Mixed style 2 -string(17) "Child constructor" -string(16) "Base constructor" diff --git a/tests/classes/inheritance_005.phpt b/tests/classes/inheritance_005.phpt deleted file mode 100644 index 8c5167f4bf..0000000000 --- a/tests/classes/inheritance_005.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -Check for inherited old-style constructor. ---FILE-- - ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -About to construct new B: -In A::A -Is B::B() callable? -bool(false) -Is B::A() callable? -bool(true) -About to construct new C: -In A::A -Is C::A() callable? -bool(true) -Is C::B() callable? -bool(false) -Is C::C() callable? -bool(false) diff --git a/tests/classes/inheritance_007.phpt b/tests/classes/inheritance_007.phpt deleted file mode 100644 index c87fbde344..0000000000 --- a/tests/classes/inheritance_007.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Ensure inherited old-style constructor doesn't block other methods ---FILE-- -getMethods()); - - -$b = new B(); -$b->a(); -$b->b(); - -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -array(2) { - [0]=> - object(ReflectionMethod)#%d (2) { - ["name"]=> - string(1) "B" - ["class"]=> - string(1) "A" - } - [1]=> - object(ReflectionMethod)#%d (2) { - ["name"]=> - string(1) "A" - ["class"]=> - string(1) "A" - } -} -In A::A -In A::A -In A::B