From eb31c2d4b497407d83550ec11a84c3ce6d10df70 Mon Sep 17 00:00:00 2001 From: macbre Date: Tue, 26 Apr 2016 10:35:35 +0200 Subject: [PATCH 1/2] oldClassConstructors: add a test case --- testcases.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testcases.php b/testcases.php index b3d7131..d97ca77 100644 --- a/testcases.php +++ b/testcases.php @@ -127,3 +127,14 @@ trait numeric { /*...*/ } class C {} $c =& new C; $c =&new C; + +// Methods with the same name as their class will not be constructors in a future version of PHP +class FooBar { + var $test = 42; + + function set() {} + + function FooBar() { + // NOP + } +} From b3f890fbcb752a9edc1dc68415b5fbef68245e3e Mon Sep 17 00:00:00 2001 From: macbre Date: Tue, 26 Apr 2016 10:36:06 +0200 Subject: [PATCH 2/2] oldClassConstructors: implement a checker --- classes/tests/critical.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/classes/tests/critical.php b/classes/tests/critical.php index c441a49..c6e9311 100644 --- a/classes/tests/critical.php +++ b/classes/tests/critical.php @@ -29,6 +29,7 @@ class critical { 'reservedNames', 'deprecatedFunctions', 'newOperatorWithReference', + 'oldClassConstructors', ]; /** @@ -133,5 +134,30 @@ public function _newOperatorWithReference($line) { } return false; } + + public function _oldClassConstructors($line) { + static $lastClassName = false; + + // reset the name of the class that we've seen + if ($line === '