Skip to content

Commit bee824b

Browse files
committed
Use Null Coalesce Operator
1 parent 10e901a commit bee824b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/DiagnosticsProvider.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public static function checkDiagnostics($node) {
3333
return new Diagnostic(
3434
DiagnosticKind::Error,
3535
"Unexpected '" .
36-
(isset(self::$tokenKindToText[$node->kind])
37-
? self::$tokenKindToText[$node->kind]
38-
: Token::getTokenKindNameFromValue($node->kind)) .
36+
(self::$tokenKindToText[$node->kind]
37+
?? Token::getTokenKindNameFromValue($node->kind)) .
3938
"'",
4039
$node->start,
4140
$node->getEndPosition() - $node->start
@@ -44,9 +43,8 @@ public static function checkDiagnostics($node) {
4443
return new Diagnostic(
4544
DiagnosticKind::Error,
4645
"'" .
47-
(isset(self::$tokenKindToText[$node->kind])
48-
? self::$tokenKindToText[$node->kind]
49-
: Token::getTokenKindNameFromValue($node->kind)) .
46+
(self::$tokenKindToText[$node->kind]
47+
?? Token::getTokenKindNameFromValue($node->kind)) .
5048
"' expected.",
5149
$node->start,
5250
$node->getEndPosition() - $node->start

src/PhpTokenizer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public static function getTokensArrayFromContent(
107107
continue;
108108
}
109109

110-
$newTokenKind = isset(self::TOKEN_MAP[$tokenKind])
111-
? self::TOKEN_MAP[$tokenKind]
112-
: $newTokenKind = TokenKind::Unknown;
110+
$newTokenKind = self::TOKEN_MAP[$tokenKind] ?? TokenKind::Unknown;
113111
$arr[] = new Token($newTokenKind, $fullStart, $start, $pos - $fullStart);
114112
$start = $fullStart = $pos;
115113
continue;

0 commit comments

Comments
 (0)