Skip to content

Commit bb267bb

Browse files
authored
Merge pull request #466 from rodrigoprimo/improve-call-time-pass-by-reference-sniff
Generic/CallTimePassByReference: add support for self, parent and static
2 parents 538b96a + b7ec8bc commit bb267bb

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public function register()
2828
T_STRING,
2929
T_VARIABLE,
3030
T_ANON_CLASS,
31+
T_PARENT,
32+
T_SELF,
33+
T_STATIC,
3134
];
3235

3336
}//end register()

src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.1.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ $instance = new MyClass(&$a);
5252

5353
$anon = new class($a) {};
5454
$anon = new class(&$a) {};
55+
56+
class Foo extends Bar {
57+
function myMethod() {
58+
$a = new static($var);
59+
$b = new self($var);
60+
$c = new parent($var);
61+
62+
$d = new static(&$var);
63+
$e = new self(&$var);
64+
$f = new parent(&$var);
65+
}
66+
}

src/Standards/Generic/Tests/Functions/CallTimePassByReferenceUnitTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ public function getErrorList($testFile='CallTimePassByReferenceUnitTest.1.inc')
4545
50 => 1,
4646
51 => 1,
4747
54 => 1,
48+
62 => 1,
49+
63 => 1,
50+
64 => 1,
4851
];
4952

5053
default:
5154
return [];
52-
}
55+
}//end switch
5356

5457
}//end getErrorList()
5558

0 commit comments

Comments
 (0)