Skip to content

Commit

Permalink
PHP 8.0 | Generic/SAPIUsage: allow for nullsafe object operator
Browse files Browse the repository at this point in the history
Includes unit test.
  • Loading branch information
jrfnl committed Sep 1, 2020
1 parent 85f3521 commit 1124ec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public function process(File $phpcsFile, $stackPtr)
$tokens = $phpcsFile->getTokens();

$ignore = [
T_DOUBLE_COLON => true,
T_OBJECT_OPERATOR => true,
T_FUNCTION => true,
T_CONST => true,
T_DOUBLE_COLON => true,
T_OBJECT_OPERATOR => true,
T_NULLSAFE_OBJECT_OPERATOR => true,
T_FUNCTION => true,
T_CONST => true,
];

$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
Expand Down
1 change: 1 addition & 0 deletions src/Standards/Generic/Tests/PHP/SAPIUsageUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
if (php_sapi_name() !== 'cli') {}
if (PHP_SAPI !== 'cli') {}
if ($object->php_sapi_name() === true) {}
if ($object?->php_sapi_name() === true) {}

0 comments on commit 1124ec8

Please sign in to comment.