Skip to content

Commit ad51b46

Browse files
committed
Merge branch 'php-8.0/psr12-nullabletype-allow-for-static-returntype' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents c7b6dac + 945ea76 commit ad51b46

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class NullableTypeDeclarationSniff implements Sniff
2626
T_CALLABLE => true,
2727
T_SELF => true,
2828
T_PARENT => true,
29+
T_STATIC => true,
2930
];
3031

3132

src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ class testInstanceOf() {
8282
$bal = $value instanceof static ? CONSTANT_NAME : $value;
8383
}
8484
}
85+
86+
// PHP 8.0: static return type.
87+
function testStatic() : ? static {}

src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.inc.fixed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ class testInstanceOf() {
8080
$bal = $value instanceof static ? CONSTANT_NAME : $value;
8181
}
8282
}
83+
84+
// PHP 8.0: static return type.
85+
function testStatic() : ?static {}

src/Standards/PSR12/Tests/Functions/NullableTypeDeclarationUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ protected function getErrorList()
4040
57 => 2,
4141
58 => 2,
4242
59 => 2,
43+
87 => 1,
4344
];
4445

4546
}//end getErrorList()

0 commit comments

Comments
 (0)