Skip to content

Commit

Permalink
Merge pull request pdepend#775 from AJenbo/null
Browse files Browse the repository at this point in the history
Use null coalescing
  • Loading branch information
kylekatarnls committed May 2, 2024
2 parents 08d2095 + 39664cb commit 013685e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ private function consumeNonePhpTokens(array &$tokens)
while ($token[0] !== T_OPEN_TAG_WITH_ECHO &&
$token[0] !== T_OPEN_TAG &&
$token[0] !== false) {
$content .= (isset($token[1]) ? $token[1] : $token[0]);
$content .= ($token[1] ?? $token[0]);

$token = (array) next($tokens);
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/php/PDepend/Source/Parser/SymbolTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ public function lookup($key)

$normalizedKey = $this->normalizeKey($key);

return isset($this->scope[$normalizedKey])
? $this->scope[$normalizedKey]
: null;
return $this->scope[$normalizedKey] ?? null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testTypedProperties()
array('false', '$falsy'),
) as $index => $expected) {
list($expectedType, $expectedVariable) = $expected;
$expectedTypeClass = isset($expected[2]) ? $expected[2] : 'PDepend\\Source\\AST\\ASTScalarType';
$expectedTypeClass = $expected[2] ?? 'PDepend\\Source\\AST\\ASTScalarType';
list($type, $variable) = $declarations[$index];

$this->assertInstanceOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testTypedProperties()
array('true', '$truthy'),
) as $index => $expected) {
list($expectedType, $expectedVariable) = $expected;
$expectedTypeClass = isset($expected[2]) ? $expected[2] : 'PDepend\\Source\\AST\\ASTScalarType';
$expectedTypeClass = $expected[2] ?? 'PDepend\\Source\\AST\\ASTScalarType';
list($type, $variable) = $declarations[$index];

$this->assertInstanceOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function testTypedProperties()
array('?Role', '$roleN', 'PDepend\\Source\\AST\\ASTClassOrInterfaceReference'),
) as $index => $expected) {
list($expectedType, $expectedVariable) = $expected;
$expectedTypeClass = isset($expected[2]) ? $expected[2] : 'PDepend\\Source\\AST\\ASTScalarType';
$expectedTypeClass = $expected[2] ?? 'PDepend\\Source\\AST\\ASTScalarType';
list($type, $variable) = $declarations[$index];

$this->assertInstanceOf(
Expand Down

0 comments on commit 013685e

Please sign in to comment.