Alexia / php7mar

PHP 7 Migration Assistant Report (MAR)
GNU General Public License v3.0
797 stars 133 forks source link

PHP4 style constructors are deprecated in PHP7 #18

Closed macbre closed 8 years ago

macbre commented 8 years ago

PHP 4 style constructors:

PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated, and will be removed in the future. PHP 7 will emit E_DEPRECATED if a PHP 4 constructor is the only constructor defined within a class. Classes that implement a __construct()method are unaffected.

// 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
        }
}

will be reported as follows:

* oldClassConstructors
 * Line 129: `  function FooBar() {`

and PHP7 will complain:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP

Alexia commented 8 years ago

Tested and works perfectly. Thank you!

macbre commented 8 years ago

Thank you as well for an extremely helpful tool.