[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'); throw new \LogicException('Name cannot be empty');
} }
if ($name[0] == '\\') { if ($name[0] === '\\') {
return new Name\FullyQualified(substr($name, 1)); return new Name\FullyQualified(substr($name, 1));
} elseif (0 === strpos($name, 'namespace\\')) { } elseif (0 === strpos($name, 'namespace\\')) {
return new Name\Relative(substr($name, strlen('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 * @return bool Whether the name is unqualified
*/ */
public function isUnqualified() : bool { 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 (;;) { for (;;) {
//$this->traceNewState($state, $symbol); //$this->traceNewState($state, $symbol);
if ($this->actionBase[$state] == 0) { if ($this->actionBase[$state] === 0) {
$rule = $this->actionDefault[$state]; $rule = $this->actionDefault[$state];
} else { } else {
if ($symbol === self::SYMBOL_NONE) { if ($symbol === self::SYMBOL_NONE) {
@ -217,11 +217,11 @@ abstract class ParserAbstract implements Parser
} }
$idx = $this->actionBase[$state] + $symbol; $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 || ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] == $symbol)) && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol))
&& ($action = $this->action[$idx]) != $this->defaultAction) { && ($action = $this->action[$idx]) !== $this->defaultAction) {
/* /*
* >= YYNLSTATES: shift and reduce * >= YYNLSTATES: shift and reduce
* > 0: shift * > 0: shift
@ -285,7 +285,7 @@ abstract class ParserAbstract implements Parser
$stackPos -= $this->ruleToLength[$rule]; $stackPos -= $this->ruleToLength[$rule];
$nonTerminal = $this->ruleToNonTerminal[$rule]; $nonTerminal = $this->ruleToNonTerminal[$rule];
$idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos]; $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]; $state = $this->goto[$idx];
} else { } else {
$state = $this->gotoDefault[$nonTerminal]; $state = $this->gotoDefault[$nonTerminal];
@ -309,11 +309,11 @@ abstract class ParserAbstract implements Parser
// Pop until error-expecting state uncovered // Pop until error-expecting state uncovered
while (!( while (!(
(($idx = $this->actionBase[$state] + $this->errorSymbol) >= 0 (($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 || ($state < $this->YY2TBLSTATE
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $this->errorSymbol) >= 0 && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $this->errorSymbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] == $this->errorSymbol) && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $this->errorSymbol)
) || ($action = $this->action[$idx]) == $this->defaultAction) { // Not totally sure about this ) || ($action = $this->action[$idx]) === $this->defaultAction) { // Not totally sure about this
if ($stackPos <= 0) { if ($stackPos <= 0) {
// Could not recover from error // Could not recover from error
return null; return null;
@ -395,11 +395,11 @@ abstract class ParserAbstract implements Parser
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0 && ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol && $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol
) { ) {
if ($this->action[$idx] != $this->unexpectedTokenRule if ($this->action[$idx] !== $this->unexpectedTokenRule
&& $this->action[$idx] != $this->defaultAction && $this->action[$idx] !== $this->defaultAction
&& $symbol != $this->errorSymbol && $symbol !== $this->errorSymbol
) { ) {
if (count($expected) == 4) { if (count($expected) === 4) {
/* Too many expected tokens */ /* Too many expected tokens */
return []; return [];
} }
@ -569,7 +569,7 @@ abstract class ParserAbstract implements Parser
} }
/* There may be a hashbang line at the very start of the file */ /* 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; continue;
} }
@ -844,7 +844,7 @@ abstract class ParserAbstract implements Parser
} }
protected function checkUseUse(UseUse $node, $namePos) { 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( $this->emitError(new Error(
sprintf( sprintf(
'Cannot use %s as %s because \'%2$s\' is a special class name', '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])) { if (isset($this->precedenceMap[$type])) {
$childPrecedence = $this->precedenceMap[$type][0]; $childPrecedence = $this->precedenceMap[$type][0];
if ($childPrecedence > $parentPrecedence if ($childPrecedence > $parentPrecedence
|| ($parentPrecedence == $childPrecedence && $parentAssociativity != $childPosition) || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition)
) { ) {
return '(' . $this->p($node) . ')'; return '(' . $this->p($node) . ')';
} }
@ -468,7 +468,7 @@ abstract class PrettyPrinterAbstract
return $this->pFallback($node); return $this->pFallback($node);
} }
if (get_class($node) != get_class($origNode)) { if (get_class($node) !== get_class($origNode)) {
// Shouldn't happen // Shouldn't happen
return $this->pFallback($node); return $this->pFallback($node);
} }