Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

PHP4 style constructors are deprecated in PHP7 #18

Merged
merged 2 commits into from
Apr 26, 2016

Conversation

macbre
Copy link
Contributor

@macbre macbre commented Apr 26, 2016

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

@macbre macbre force-pushed the oldClassConstructors branch from 52b4676 to b3f890f Compare April 26, 2016 09:07
@Alexia Alexia merged commit 1fa5638 into Alexia:master Apr 26, 2016
@Alexia
Copy link
Owner

Alexia commented Apr 26, 2016

Tested and works perfectly. Thank you!

@macbre macbre deleted the oldClassConstructors branch April 26, 2016 15:55
@macbre
Copy link
Contributor Author

macbre commented Apr 26, 2016

Thank you as well for an extremely helpful tool.

@macbre macbre restored the oldClassConstructors branch April 28, 2016 09:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants