This repository was archived by the owner on May 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public function enterNode(Node $node)
4040
4141 if ($ node instanceof Node \Stmt \Class_) {
4242 $ method = $ node ->getMethod ($ node ->name );
43- if ($ method instanceof Node \Stmt \ClassMethod) {
43+ if ($ method instanceof Node \Stmt \ClassMethod && count ( $ node -> namespacedName -> parts ) === 1 ) {
4444 $ this ->phpFileInfo ->addDeprecatedLanguageUsage (
4545 new DeprecatedLanguageUsage (
4646 'PHP4 constructor ' ,
Original file line number Diff line number Diff line change @@ -15,6 +15,62 @@ public function testAssignByReference()
1515
1616$foo =& $bar;
1717
18+ EOC;
19+ $ splFileInfo = $ this ->prophesize ('Symfony\Component\Finder\SplFileInfo ' );
20+ $ phpFileInfo = $ this ->parsePhpFileFromStringAndTraverseWithVisitor (
21+ $ file = PhpFileInfo::create ($ splFileInfo ->reveal ()),
22+ $ source ,
23+ new FindLanguageDeprecations ()
24+ );
25+
26+ $ this ->assertEquals (
27+ array (),
28+ $ phpFileInfo ->getDeprecatedLanguageUsages ()
29+ );
30+ }
31+
32+ public function testPHP4Constructors ()
33+ {
34+ $ source = <<<'EOC'
35+ <?php
36+
37+ class OddClass
38+ {
39+ public function oddClass()
40+ {
41+ return null;
42+ }
43+ }
44+
45+ EOC;
46+ $ splFileInfo = $ this ->prophesize ('Symfony\Component\Finder\SplFileInfo ' );
47+ $ phpFileInfo = $ this ->parsePhpFileFromStringAndTraverseWithVisitor (
48+ $ file = PhpFileInfo::create ($ splFileInfo ->reveal ()),
49+ $ source ,
50+ new FindLanguageDeprecations ()
51+ );
52+
53+ $ this ->assertInstanceOf (
54+ 'SensioLabs\DeprecationDetector\FileInfo\Usage\DeprecatedLanguageUsage ' ,
55+ $ phpFileInfo ->getDeprecatedLanguageUsages ()[0 ]
56+ );
57+ }
58+
59+ public function testNamespacedPHP4Constructors ()
60+ {
61+ $ source = <<<'EOC'
62+ <?php
63+
64+ namespace Name\Space;
65+
66+ class OddClass
67+ {
68+ public function oddClass()
69+ {
70+ return null;
71+ }
72+ }
73+
1874EOC;
1975 $ splFileInfo = $ this ->prophesize ('Symfony\Component\Finder\SplFileInfo ' );
2076 $ phpFileInfo = $ this ->parsePhpFileFromStringAndTraverseWithVisitor (
You can’t perform that action at this time.
0 commit comments