PHP4 style constructor test#109
Merged
wimg merged 2 commits intoPHPCompatibility:php70from Jun 23, 2016
grubolsch:php70
Merged
Conversation
Member
|
Thank you for your contribution ! Great job ! |
Contributor
|
This sniff is not quite correct. PHP4-style constructors are only deprecated if there is no PHP5-style constructor. Therefore the following code is fine in PHP 7 and the sniff should not emit an error: class foo {
function __construct() {
echo 'I am the constructor';
}
function foo() {
echo 'I am NOT the constructor';
}
}Reference: http://php.net/manual/en/migration70.deprecated.php |
Member
|
Thanks for mentioning it. We'll get it fixed ;-) |
Contributor
|
Cool. When adding the unit tests, as well as the example above, I would add a test to cover those two functions in the opposite order (as the implementation should not care about the order of class methods). It would also be good to have a test that tests the case-insensitivity of the constructor name, e.g. class foo {
function FOO() {
echo 'I am the constructor';
}
}I'm not sure if this would currently trigger a sniff error (as it should) or not. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.