mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-02 09:17:58 +01:00
[CS] Use elseif instead of else if
Conflicts: lib/PhpParser/TokenStream.php
This commit is contained in:
parent
4366aa2fb0
commit
5285df8f22
@ -50,7 +50,7 @@ class Interface_ extends Declaration
|
|||||||
|
|
||||||
if ($stmt instanceof Stmt\ClassConst) {
|
if ($stmt instanceof Stmt\ClassConst) {
|
||||||
$this->constants[] = $stmt;
|
$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
|
// we erase all statements in the body of an interface method
|
||||||
$stmt->stmts = null;
|
$stmt->stmts = null;
|
||||||
$this->methods[] = $stmt;
|
$this->methods[] = $stmt;
|
||||||
|
@ -34,9 +34,9 @@ class Trait_ extends Declaration
|
|||||||
|
|
||||||
if ($stmt instanceof Stmt\Property) {
|
if ($stmt instanceof Stmt\Property) {
|
||||||
$this->properties[] = $stmt;
|
$this->properties[] = $stmt;
|
||||||
} else if ($stmt instanceof Stmt\ClassMethod) {
|
} elseif ($stmt instanceof Stmt\ClassMethod) {
|
||||||
$this->methods[] = $stmt;
|
$this->methods[] = $stmt;
|
||||||
} else if ($stmt instanceof Stmt\TraitUse) {
|
} elseif ($stmt instanceof Stmt\TraitUse) {
|
||||||
$this->uses[] = $stmt;
|
$this->uses[] = $stmt;
|
||||||
} else {
|
} else {
|
||||||
throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
|
throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
|
||||||
|
@ -184,7 +184,7 @@ final class BuilderHelpers {
|
|||||||
public static function normalizeDocComment($docComment) : Comment\Doc {
|
public static function normalizeDocComment($docComment) : Comment\Doc {
|
||||||
if ($docComment instanceof Comment\Doc) {
|
if ($docComment instanceof Comment\Doc) {
|
||||||
return $docComment;
|
return $docComment;
|
||||||
} else if (is_string($docComment)) {
|
} elseif (is_string($docComment)) {
|
||||||
return new Comment\Doc($docComment);
|
return new Comment\Doc($docComment);
|
||||||
} else {
|
} else {
|
||||||
throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
|
throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
|
||||||
|
@ -255,7 +255,7 @@ class Lexer
|
|||||||
$id = $this->tokenMap[$token[0]];
|
$id = $this->tokenMap[$token[0]];
|
||||||
if (\T_CLOSE_TAG === $token[0]) {
|
if (\T_CLOSE_TAG === $token[0]) {
|
||||||
$this->prevCloseTagHasNewline = false !== strpos($token[1], "\n");
|
$this->prevCloseTagHasNewline = false !== strpos($token[1], "\n");
|
||||||
} else if (\T_INLINE_HTML === $token[0]) {
|
} elseif (\T_INLINE_HTML === $token[0]) {
|
||||||
$startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
|
$startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ class Lexer
|
|||||||
if ('T_HASHBANG' === $name) {
|
if ('T_HASHBANG' === $name) {
|
||||||
// HHVM uses a special token for #! hashbang lines
|
// HHVM uses a special token for #! hashbang lines
|
||||||
$tokenMap[$i] = Tokens::T_INLINE_HTML;
|
$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
|
// Other tokens can be mapped directly
|
||||||
$tokenMap[$i] = constant($name);
|
$tokenMap[$i] = constant($name);
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ class Name extends NodeAbstract
|
|||||||
return null;
|
return null;
|
||||||
} elseif (null === $name1) {
|
} elseif (null === $name1) {
|
||||||
return new static(self::prepareName($name2), $attributes);
|
return new static(self::prepareName($name2), $attributes);
|
||||||
} else if (null === $name2) {
|
} elseif (null === $name2) {
|
||||||
return new static(self::prepareName($name1), $attributes);
|
return new static(self::prepareName($name1), $attributes);
|
||||||
} else {
|
} else {
|
||||||
return new static(
|
return new static(
|
||||||
|
@ -65,9 +65,9 @@ class NodeDumper
|
|||||||
} elseif (is_scalar($value)) {
|
} elseif (is_scalar($value)) {
|
||||||
if ('flags' === $key || 'newModifier' === $key) {
|
if ('flags' === $key || 'newModifier' === $key) {
|
||||||
$r .= $this->dumpFlags($value);
|
$r .= $this->dumpFlags($value);
|
||||||
} else if ('type' === $key && $node instanceof Include_) {
|
} elseif ('type' === $key && $node instanceof Include_) {
|
||||||
$r .= $this->dumpIncludeType($value);
|
$r .= $this->dumpIncludeType($value);
|
||||||
} else if ('type' === $key
|
} elseif ('type' === $key
|
||||||
&& ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) {
|
&& ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) {
|
||||||
$r .= $this->dumpUseType($value);
|
$r .= $this->dumpUseType($value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -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');
|
throw new \LogicException('Invalid node structure: Contains nested arrays');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -804,7 +804,7 @@ abstract class PrettyPrinterAbstract
|
|||||||
// Add new comments
|
// Add new comments
|
||||||
$result .= $this->pComments($comments) . $this->nl;
|
$result .= $this->pComments($comments) . $this->nl;
|
||||||
}
|
}
|
||||||
} else if ($diffType === DiffElem::TYPE_ADD) {
|
} elseif ($diffType === DiffElem::TYPE_ADD) {
|
||||||
if (null === $insertStr) {
|
if (null === $insertStr) {
|
||||||
// We don't have insertion information for this list type
|
// We don't have insertion information for this list type
|
||||||
return null;
|
return null;
|
||||||
@ -836,7 +836,7 @@ abstract class PrettyPrinterAbstract
|
|||||||
} else {
|
} else {
|
||||||
$result .= $insertStr;
|
$result .= $insertStr;
|
||||||
}
|
}
|
||||||
} else if ($diffType === DiffElem::TYPE_REMOVE) {
|
} elseif ($diffType === DiffElem::TYPE_REMOVE) {
|
||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
// TODO Handle removal at the start
|
// TODO Handle removal at the start
|
||||||
return null;
|
return null;
|
||||||
|
@ -214,7 +214,7 @@ class TokenStream {
|
|||||||
// TODO Handle non-space indentation
|
// TODO Handle non-space indentation
|
||||||
if ($indent < 0) {
|
if ($indent < 0) {
|
||||||
$result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content);
|
$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);
|
$result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content);
|
||||||
} else {
|
} else {
|
||||||
$result .= $content;
|
$result .= $content;
|
||||||
|
@ -26,7 +26,7 @@ class CodeParsingTest extends CodeTestAbstract
|
|||||||
if (isset($modes['php5'])) {
|
if (isset($modes['php5'])) {
|
||||||
$this->assertSame($expected, $output5, $name);
|
$this->assertSame($expected, $output5, $name);
|
||||||
$this->assertNotSame($expected, $output7, $name);
|
$this->assertNotSame($expected, $output7, $name);
|
||||||
} else if (isset($modes['php7'])) {
|
} elseif (isset($modes['php7'])) {
|
||||||
$this->assertNotSame($expected, $output5, $name);
|
$this->assertNotSame($expected, $output5, $name);
|
||||||
$this->assertSame($expected, $output7, $name);
|
$this->assertSame($expected, $output7, $name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,10 +140,10 @@ class NodeAbstractTest extends TestCase
|
|||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
$this->assertSame('subNode1', $key);
|
$this->assertSame('subNode1', $key);
|
||||||
$this->assertSame('value1', $value);
|
$this->assertSame('value1', $value);
|
||||||
} else if ($i === 1) {
|
} elseif ($i === 1) {
|
||||||
$this->assertSame('subNode2', $key);
|
$this->assertSame('subNode2', $key);
|
||||||
$this->assertSame('value2', $value);
|
$this->assertSame('value2', $value);
|
||||||
} else if ($i === 2) {
|
} elseif ($i === 2) {
|
||||||
$this->assertSame('notSubNode', $key);
|
$this->assertSame('notSubNode', $key);
|
||||||
$this->assertSame('value3', $value);
|
$this->assertSame('value3', $value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,7 +45,7 @@ class PrettyPrinterTest extends CodeTestAbstract
|
|||||||
if ('php5' === $version) {
|
if ('php5' === $version) {
|
||||||
$this->assertSame($expected, $output5, $name);
|
$this->assertSame($expected, $output5, $name);
|
||||||
$this->assertNotSame($expected, $output7, $name);
|
$this->assertNotSame($expected, $output7, $name);
|
||||||
} else if ('php7' === $version) {
|
} elseif ('php7' === $version) {
|
||||||
$this->assertSame($expected, $output7, $name);
|
$this->assertSame($expected, $output7, $name);
|
||||||
$this->assertNotSame($expected, $output5, $name);
|
$this->assertNotSame($expected, $output5, $name);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user