Skip to content

Commit

Permalink
PSR12/NullableTypeDeclaration: allow for static return type
Browse files Browse the repository at this point in the history
PHP 8.0 introduces `static` as a valid return type. This adds support for handling this to the `PSR12.Functions.NullableTypeDeclaration` sniff.

Includes unit test.
  • Loading branch information
jrfnl committed Aug 31, 2020
1 parent d33a6a9 commit 945ea76
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NullableTypeDeclarationSniff implements Sniff
T_CALLABLE => true,
T_SELF => true,
T_PARENT => true,
T_STATIC => true,
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ class testInstanceOf() {
$bal = $value instanceof static ? CONSTANT_NAME : $value;
}
}

// PHP 8.0: static return type.
function testStatic() : ? static {}
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ class testInstanceOf() {
$bal = $value instanceof static ? CONSTANT_NAME : $value;
}
}

// PHP 8.0: static return type.
function testStatic() : ?static {}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function getErrorList()
57 => 2,
58 => 2,
59 => 2,
87 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 945ea76

Please sign in to comment.