Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Nov 3, 2023
1 parent ff4a56e commit 96d042d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 18 deletions.
11 changes: 2 additions & 9 deletions src/CodeCleaner/ListPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Psy\CodeCleaner;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrayItem;
Expand Down Expand Up @@ -52,10 +51,7 @@ public function enterNode(Node $node)
$items = isset($node->var->items) ? $node->var->items : $node->var->vars;

if ($items === [] || $items === [null]) {
throw new ParseErrorException('Cannot use empty list', [
'startLine' => $node->var->getStartLine(),
'endLine' => $node->var->getEndLine(),
]);
throw new ParseErrorException('Cannot use empty list', ['startLine' => $node->var->getStartLine(), 'endLine' => $node->var->getEndLine()]);
}

$itemFound = false;
Expand All @@ -68,10 +64,7 @@ public function enterNode(Node $node)

if (!self::isValidArrayItem($item)) {
$msg = 'Assignments can only happen to writable values';
throw new ParseErrorException($msg, [
'startLine' => $item->getStartLine(),
'endLine' => $item->getEndLine(),
]);
throw new ParseErrorException($msg, ['startLine' => $item->getStartLine(), 'endLine' => $item->getEndLine()]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/CodeCleaner/NamespaceAwarePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ protected function getFullyQualifiedName($name): string
}

/**
* Backwards compatibility shim for PHP-Parser 4.x
* Backwards compatibility shim for PHP-Parser 4.x.
*
* At some point we might want to make $namespace a plain string, to match how Name works?
*/
protected function getParts(Name $name): array
{
return method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
return \method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
}
}
}
4 changes: 2 additions & 2 deletions src/CodeCleaner/NamespacePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ private function setNamespace($namespace)
}

/**
* Backwards compatibility shim for PHP-Parser 4.x
* Backwards compatibility shim for PHP-Parser 4.x.
*
* At some point we might want to make the namespace a plain string, to match how Name works?
*/
protected function getParts(Name $name): array
{
return method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
return \method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
}
}
4 changes: 2 additions & 2 deletions src/CodeCleaner/ValidConstructorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ private function validateConstructor(Node $constructor, Node $classNode)
}

/**
* Backwards compatibility shim for PHP-Parser 4.x
* Backwards compatibility shim for PHP-Parser 4.x.
*
* At some point we might want to make $namespace a plain string, to match how Name works?
*/
protected function getParts(Name $name): array
{
return method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
return \method_exists($name, 'getParts') ? $name->getParts() : $name->parts;
}
}
2 changes: 1 addition & 1 deletion src/Command/ThrowUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Expr\Throw_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Name\FullyQualified as FullyQualifiedName;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Expression;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ParseErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(string $message = '', $attributes = [])
{
$message = \sprintf('PHP Parse error: %s', $message);

if (!is_array($attributes)) {
if (!\is_array($attributes)) {
$attributes = ['startLine' => $attributes];
}

Expand Down

0 comments on commit 96d042d

Please sign in to comment.