1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

[cs] use strict comparison where allowed

This commit is contained in:
TomasVotruba 2017-08-13 14:13:51 +02:00 committed by Nikita Popov
parent ec535ea14e
commit 05e6725b7a
4 changed files with 18 additions and 18 deletions

View File

@ -69,7 +69,7 @@ final class BuilderHelpers {
throw new \LogicException('Name cannot be empty');
}
if ($name[0] == '\\') {
if ($name[0] === '\\') {
return new Name\FullyQualified(substr($name, 1));
} elseif (0 === strpos($name, 'namespace\\')) {
return new Name\Relative(substr($name, strlen('namespace\\')));

View File

@ -50,7 +50,7 @@ class Name extends NodeAbstract
* @return bool Whether the name is unqualified
*/
public function isUnqualified() : bool {
return 1 == count($this->parts);
return 1 === count($this->parts);
}
/**

View File

@ -185,7 +185,7 @@ abstract class ParserAbstract implements Parser
for (;;) {
//$this->traceNewState($state, $symbol);
if ($this->actionBase[$state] == 0) {
if ($this->actionBase[$state] === 0) {
$rule = $this->actionDefault[$state];
} else {
if ($symbol === self::SYMBOL_NONE) {
@ -217,11 +217,11 @@ abstract class ParserAbstract implements Parser
}
$idx = $this->actionBase[$state] + $symbol;
if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] == $symbol)
if ((($idx >= 0 && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol)
|| ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] == $symbol))
&& ($action = $this->action[$idx]) != $this->defaultAction) {
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol))
&& ($action = $this->action[$idx]) !== $this->defaultAction) {
/*
* >= YYNLSTATES: shift and reduce
* > 0: shift
@ -285,7 +285,7 @@ abstract class ParserAbstract implements Parser
$stackPos -= $this->ruleToLength[$rule];
$nonTerminal = $this->ruleToNonTerminal[$rule];
$idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos];
if ($idx >= 0 && $idx < $this->gotoTableSize && $this->gotoCheck[$idx] == $nonTerminal) {
if ($idx >= 0 && $idx < $this->gotoTableSize && $this->gotoCheck[$idx] === $nonTerminal) {
$state = $this->goto[$idx];
} else {
$state = $this->gotoDefault[$nonTerminal];
@ -309,11 +309,11 @@ abstract class ParserAbstract implements Parser
// Pop until error-expecting state uncovered
while (!(
(($idx = $this->actionBase[$state] + $this->errorSymbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] == $this->errorSymbol)
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol)
|| ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $this->errorSymbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] == $this->errorSymbol)
) || ($action = $this->action[$idx]) == $this->defaultAction) { // Not totally sure about this
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol)
) || ($action = $this->action[$idx]) === $this->defaultAction) { // Not totally sure about this
if ($stackPos <= 0) {
// Could not recover from error
return null;
@ -395,11 +395,11 @@ abstract class ParserAbstract implements Parser
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol
) {
if ($this->action[$idx] != $this->unexpectedTokenRule
&& $this->action[$idx] != $this->defaultAction
&& $symbol != $this->errorSymbol
if ($this->action[$idx] !== $this->unexpectedTokenRule
&& $this->action[$idx] !== $this->defaultAction
&& $symbol !== $this->errorSymbol
) {
if (count($expected) == 4) {
if (count($expected) === 4) {
/* Too many expected tokens */
return [];
}
@ -569,7 +569,7 @@ abstract class ParserAbstract implements Parser
}
/* There may be a hashbang line at the very start of the file */
if ($i == 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) {
if ($i === 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) {
continue;
}
@ -844,7 +844,7 @@ abstract class ParserAbstract implements Parser
}
protected function checkUseUse(UseUse $node, $namePos) {
if ('self' == strtolower($node->alias) || 'parent' == strtolower($node->alias)) {
if ('self' === strtolower($node->alias) || 'parent' === strtolower($node->alias)) {
$this->emitError(new Error(
sprintf(
'Cannot use %s as %s because \'%2$s\' is a special class name',

View File

@ -301,7 +301,7 @@ abstract class PrettyPrinterAbstract
if (isset($this->precedenceMap[$type])) {
$childPrecedence = $this->precedenceMap[$type][0];
if ($childPrecedence > $parentPrecedence
|| ($parentPrecedence == $childPrecedence && $parentAssociativity != $childPosition)
|| ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition)
) {
return '(' . $this->p($node) . ')';
}
@ -468,7 +468,7 @@ abstract class PrettyPrinterAbstract
return $this->pFallback($node);
}
if (get_class($node) != get_class($origNode)) {
if (get_class($node) !== get_class($origNode)) {
// Shouldn't happen
return $this->pFallback($node);
}