From 96d042d1790a8233cb644597973b1afa4aca2fa0 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 3 Nov 2023 06:24:34 -0400 Subject: [PATCH] Style fixes --- src/CodeCleaner/ListPass.php | 11 ++--------- src/CodeCleaner/NamespaceAwarePass.php | 6 +++--- src/CodeCleaner/NamespacePass.php | 4 ++-- src/CodeCleaner/ValidConstructorPass.php | 4 ++-- src/Command/ThrowUpCommand.php | 2 +- src/Exception/ParseErrorException.php | 2 +- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/CodeCleaner/ListPass.php b/src/CodeCleaner/ListPass.php index 52d9c582..eb0001ab 100644 --- a/src/CodeCleaner/ListPass.php +++ b/src/CodeCleaner/ListPass.php @@ -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; @@ -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; @@ -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()]); } } diff --git a/src/CodeCleaner/NamespaceAwarePass.php b/src/CodeCleaner/NamespaceAwarePass.php index 12de7575..53290fd8 100644 --- a/src/CodeCleaner/NamespaceAwarePass.php +++ b/src/CodeCleaner/NamespaceAwarePass.php @@ -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; } -} \ No newline at end of file +} diff --git a/src/CodeCleaner/NamespacePass.php b/src/CodeCleaner/NamespacePass.php index 75ec844f..25c0be03 100644 --- a/src/CodeCleaner/NamespacePass.php +++ b/src/CodeCleaner/NamespacePass.php @@ -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; } } diff --git a/src/CodeCleaner/ValidConstructorPass.php b/src/CodeCleaner/ValidConstructorPass.php index a02f94be..481de6fc 100644 --- a/src/CodeCleaner/ValidConstructorPass.php +++ b/src/CodeCleaner/ValidConstructorPass.php @@ -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; } } diff --git a/src/Command/ThrowUpCommand.php b/src/Command/ThrowUpCommand.php index 337a5bdc..8e597914 100644 --- a/src/Command/ThrowUpCommand.php +++ b/src/Command/ThrowUpCommand.php @@ -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; diff --git a/src/Exception/ParseErrorException.php b/src/Exception/ParseErrorException.php index 632e1fd6..ee2e2d42 100644 --- a/src/Exception/ParseErrorException.php +++ b/src/Exception/ParseErrorException.php @@ -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]; }