diff --git a/lib/PhpParser/Builder/Interface_.php b/lib/PhpParser/Builder/Interface_.php index 611f92f..057894f 100644 --- a/lib/PhpParser/Builder/Interface_.php +++ b/lib/PhpParser/Builder/Interface_.php @@ -50,7 +50,7 @@ class Interface_ extends Declaration if ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; - } else if ($stmt instanceof Stmt\ClassMethod) { + } elseif ($stmt instanceof Stmt\ClassMethod) { // we erase all statements in the body of an interface method $stmt->stmts = null; $this->methods[] = $stmt; diff --git a/lib/PhpParser/Builder/Trait_.php b/lib/PhpParser/Builder/Trait_.php index 8e9f430..a836d40 100644 --- a/lib/PhpParser/Builder/Trait_.php +++ b/lib/PhpParser/Builder/Trait_.php @@ -34,9 +34,9 @@ class Trait_ extends Declaration if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; - } else if ($stmt instanceof Stmt\ClassMethod) { + } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; - } else if ($stmt instanceof Stmt\TraitUse) { + } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); diff --git a/lib/PhpParser/BuilderHelpers.php b/lib/PhpParser/BuilderHelpers.php index fe22cd7..dc0bb19 100644 --- a/lib/PhpParser/BuilderHelpers.php +++ b/lib/PhpParser/BuilderHelpers.php @@ -184,7 +184,7 @@ final class BuilderHelpers { public static function normalizeDocComment($docComment) : Comment\Doc { if ($docComment instanceof Comment\Doc) { return $docComment; - } else if (is_string($docComment)) { + } elseif (is_string($docComment)) { return new Comment\Doc($docComment); } else { throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc'); diff --git a/lib/PhpParser/Lexer.php b/lib/PhpParser/Lexer.php index 4f96ecc..f7da2d2 100644 --- a/lib/PhpParser/Lexer.php +++ b/lib/PhpParser/Lexer.php @@ -255,7 +255,7 @@ class Lexer $id = $this->tokenMap[$token[0]]; if (\T_CLOSE_TAG === $token[0]) { $this->prevCloseTagHasNewline = false !== strpos($token[1], "\n"); - } else if (\T_INLINE_HTML === $token[0]) { + } elseif (\T_INLINE_HTML === $token[0]) { $startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline; } @@ -357,7 +357,7 @@ class Lexer if ('T_HASHBANG' === $name) { // HHVM uses a special token for #! hashbang lines $tokenMap[$i] = Tokens::T_INLINE_HTML; - } else if (defined($name = Tokens::class . '::' . $name)) { + } elseif (defined($name = Tokens::class . '::' . $name)) { // Other tokens can be mapped directly $tokenMap[$i] = constant($name); } diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index 4d78081..5d923d0 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -199,7 +199,7 @@ class Name extends NodeAbstract return null; } elseif (null === $name1) { return new static(self::prepareName($name2), $attributes); - } else if (null === $name2) { + } elseif (null === $name2) { return new static(self::prepareName($name1), $attributes); } else { return new static( diff --git a/lib/PhpParser/NodeDumper.php b/lib/PhpParser/NodeDumper.php index b08f85e..197ebc1 100644 --- a/lib/PhpParser/NodeDumper.php +++ b/lib/PhpParser/NodeDumper.php @@ -65,9 +65,9 @@ class NodeDumper } elseif (is_scalar($value)) { if ('flags' === $key || 'newModifier' === $key) { $r .= $this->dumpFlags($value); - } else if ('type' === $key && $node instanceof Include_) { + } elseif ('type' === $key && $node instanceof Include_) { $r .= $this->dumpIncludeType($value); - } else if ('type' === $key + } elseif ('type' === $key && ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) { $r .= $this->dumpUseType($value); } else { diff --git a/lib/PhpParser/NodeTraverser.php b/lib/PhpParser/NodeTraverser.php index 2294796..9c32c6b 100644 --- a/lib/PhpParser/NodeTraverser.php +++ b/lib/PhpParser/NodeTraverser.php @@ -226,7 +226,7 @@ class NodeTraverser implements NodeTraverserInterface } } } - } else if (\is_array($node)) { + } elseif (\is_array($node)) { throw new \LogicException('Invalid node structure: Contains nested arrays'); } } diff --git a/lib/PhpParser/PrettyPrinterAbstract.php b/lib/PhpParser/PrettyPrinterAbstract.php index c95cfda..1fea10a 100644 --- a/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/PhpParser/PrettyPrinterAbstract.php @@ -804,7 +804,7 @@ abstract class PrettyPrinterAbstract // Add new comments $result .= $this->pComments($comments) . $this->nl; } - } else if ($diffType === DiffElem::TYPE_ADD) { + } elseif ($diffType === DiffElem::TYPE_ADD) { if (null === $insertStr) { // We don't have insertion information for this list type return null; @@ -836,7 +836,7 @@ abstract class PrettyPrinterAbstract } else { $result .= $insertStr; } - } else if ($diffType === DiffElem::TYPE_REMOVE) { + } elseif ($diffType === DiffElem::TYPE_REMOVE) { if ($i === 0) { // TODO Handle removal at the start return null; diff --git a/lib/PhpParser/TokenStream.php b/lib/PhpParser/TokenStream.php index e507375..0d3a093 100644 --- a/lib/PhpParser/TokenStream.php +++ b/lib/PhpParser/TokenStream.php @@ -214,7 +214,7 @@ class TokenStream { // TODO Handle non-space indentation if ($indent < 0) { $result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content); - } else if ($indent > 0) { + } elseif ($indent > 0) { $result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content); } else { $result .= $content; diff --git a/test/PhpParser/CodeParsingTest.php b/test/PhpParser/CodeParsingTest.php index 420ee9d..3bdab81 100644 --- a/test/PhpParser/CodeParsingTest.php +++ b/test/PhpParser/CodeParsingTest.php @@ -26,7 +26,7 @@ class CodeParsingTest extends CodeTestAbstract if (isset($modes['php5'])) { $this->assertSame($expected, $output5, $name); $this->assertNotSame($expected, $output7, $name); - } else if (isset($modes['php7'])) { + } elseif (isset($modes['php7'])) { $this->assertNotSame($expected, $output5, $name); $this->assertSame($expected, $output7, $name); } else { diff --git a/test/PhpParser/NodeAbstractTest.php b/test/PhpParser/NodeAbstractTest.php index 691d80d..4fd7f05 100644 --- a/test/PhpParser/NodeAbstractTest.php +++ b/test/PhpParser/NodeAbstractTest.php @@ -140,10 +140,10 @@ class NodeAbstractTest extends TestCase if ($i === 0) { $this->assertSame('subNode1', $key); $this->assertSame('value1', $value); - } else if ($i === 1) { + } elseif ($i === 1) { $this->assertSame('subNode2', $key); $this->assertSame('value2', $value); - } else if ($i === 2) { + } elseif ($i === 2) { $this->assertSame('notSubNode', $key); $this->assertSame('value3', $value); } else { diff --git a/test/PhpParser/PrettyPrinterTest.php b/test/PhpParser/PrettyPrinterTest.php index 38c4777..e47a9b9 100644 --- a/test/PhpParser/PrettyPrinterTest.php +++ b/test/PhpParser/PrettyPrinterTest.php @@ -45,7 +45,7 @@ class PrettyPrinterTest extends CodeTestAbstract if ('php5' === $version) { $this->assertSame($expected, $output5, $name); $this->assertNotSame($expected, $output7, $name); - } else if ('php7' === $version) { + } elseif ('php7' === $version) { $this->assertSame($expected, $output7, $name); $this->assertNotSame($expected, $output5, $name); } else {