Skip to content

Commit fd8dcd6

Browse files
committed
Merge branch 'php-8.0/psr12-classinstantiation-support-nullsafe-operator' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 908b5ce + 877e89f commit fd8dcd6

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ public function process(File $phpcsFile, $stackPtr)
4444

4545
// Find the class name.
4646
$allowed = [
47-
T_STRING => T_STRING,
48-
T_NS_SEPARATOR => T_NS_SEPARATOR,
49-
T_SELF => T_SELF,
50-
T_STATIC => T_STATIC,
51-
T_VARIABLE => T_VARIABLE,
52-
T_DOLLAR => T_DOLLAR,
53-
T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
54-
T_DOUBLE_COLON => T_DOUBLE_COLON,
47+
T_STRING => T_STRING,
48+
T_NS_SEPARATOR => T_NS_SEPARATOR,
49+
T_SELF => T_SELF,
50+
T_STATIC => T_STATIC,
51+
T_VARIABLE => T_VARIABLE,
52+
T_DOLLAR => T_DOLLAR,
53+
T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
54+
T_NULLSAFE_OBJECT_OPERATOR => T_NULLSAFE_OBJECT_OPERATOR,
55+
T_DOUBLE_COLON => T_DOUBLE_COLON,
5556
];
5657

5758
$allowed += Tokens::$emptyTokens;

src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ $foo = new $bar['a'] [$baz['a']/* comment */ ['b']]['b'];
3232
$a = new self::$transport[$cap_string];
3333
$renderer = new $this->inline_diff_renderer;
3434
$a = new ${$varHoldingClassName};
35+
36+
$class = new $obj?->classname();
37+
$class = new $obj?->classname;
38+
$class = new ${$obj?->classname};

src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ $foo = new $bar['a'] [$baz['a']/* comment */ ['b']]['b']();
3232
$a = new self::$transport[$cap_string]();
3333
$renderer = new $this->inline_diff_renderer();
3434
$a = new ${$varHoldingClassName}();
35+
36+
$class = new $obj?->classname();
37+
$class = new $obj?->classname();
38+
$class = new ${$obj?->classname}();

src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function getErrorList()
4141
32 => 1,
4242
33 => 1,
4343
34 => 1,
44+
37 => 1,
45+
38 => 1,
4446
];
4547

4648
}//end getErrorList()

0 commit comments

Comments
 (0)