-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeAnalysis/ConstructorDestructorReturn: correctly ignore PHP-4-styl…
…e constructors in namespaced classes Methods with the same name as a class are not recognized as PHP4-style constructors in namespaced classes. This was so far not taken into account in this sniff, leading to false positives. A better solution, with a lower performance impact is expected at a later point in time (namespace tracker), however, as my time is limited, it may still be a while before that solution is available. In the mean time, let's just fix it. Includes test.
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
14 changes: 14 additions & 0 deletions
14
Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.5.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* The PHP4-style constructors are not constructors in namespaced files. | ||
* No errors should be thrown for it, nor any auto-fixes made. | ||
*/ | ||
namespace Some\Name; | ||
|
||
class ReturnsAValue { | ||
function returnsAValue(): string | ||
{ | ||
return 'php4style'; | ||
} | ||
} |