Skip to content

Commit b91a18b

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/CallTimePassByReference: support anonymous classes
This commit changes the sniff to flag call-time pass-by-reference arguments when instantiating an anonymous class.
1 parent 7030f03 commit b91a18b

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function register()
2727
return [
2828
T_STRING,
2929
T_VARIABLE,
30+
T_ANON_CLASS,
3031
];
3132

3233
}//end register()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ $instance = new $var($a);
4949
$instance = new MyClass($a);
5050
$instance = new $var(&$a);
5151
$instance = new MyClass(&$a);
52+
53+
$anon = new class($a) {};
54+
$anon = new class(&$a) {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function getErrorList($testFile='CallTimePassByReferenceUnitTest.1.inc')
4444
41 => 1,
4545
50 => 1,
4646
51 => 1,
47+
54 => 1,
4748
];
4849

4950
default:

0 commit comments

Comments
 (0)