diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3909a4736..72dc1dac3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: run: composer require --dev roave/security-advisories:dev-latest static-analysis: - name: Psalm + name: Psalm and Rector runs-on: ${{ matrix.os }} strategy: @@ -100,7 +100,9 @@ jobs: # Execution - name: Static Analysis - run: vendor/bin/psalm --no-cache + run: | + vendor/bin/psalm --no-cache + vendor/bin/rector --dry-run coding-standards: diff --git a/composer.json b/composer.json index 367ed4801..02d44b521 100644 --- a/composer.json +++ b/composer.json @@ -134,6 +134,7 @@ "mockery/mockery": "^1.3", "phpunit/phpunit": "^8.5|^9.0", "ramsey/uuid": "^3.9", + "rector/rector": "0.12.3", "spiral/broadcast": "^2.0", "spiral/broadcast-ws": "^1.0", "spiral/code-style": "^1.0", diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..14d23ed85 --- /dev/null +++ b/rector.php @@ -0,0 +1,21 @@ +parameters(); + $parameters->set(Option::PATHS, [ + __DIR__ . '/src/*/src', + ]); + + $parameters->set(Option::SKIP, [ + CountOnNullRector::class, + ]); + + $containerConfigurator->import(LevelSetList::UP_TO_PHP_72); +}; diff --git a/src/Console/src/Command.php b/src/Console/src/Command.php index 0c152bd83..fbf6e588c 100644 --- a/src/Console/src/Command.php +++ b/src/Console/src/Command.php @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $resolver = $this->container->get(ResolverInterface::class); try { - list($this->input, $this->output) = [$input, $output]; + [$this->input, $this->output] = [$input, $output]; //Executing perform method with method injection return (int)$reflection->invokeArgs($this, $resolver->resolveArguments( diff --git a/src/Csrf/src/Middleware/CsrfMiddleware.php b/src/Csrf/src/Middleware/CsrfMiddleware.php index c98d35a6c..bc58770da 100644 --- a/src/Csrf/src/Middleware/CsrfMiddleware.php +++ b/src/Csrf/src/Middleware/CsrfMiddleware.php @@ -46,6 +46,7 @@ public function __construct(CsrfConfig $config) */ public function process(Request $request, RequestHandlerInterface $handler): Response { + $cookie = null; if (isset($request->getCookieParams()[$this->config->getCookie()])) { $token = $request->getCookieParams()[$this->config->getCookie()]; } else { diff --git a/src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php b/src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php index 6cf1f9fdf..01aa3d4bb 100644 --- a/src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php +++ b/src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php @@ -40,6 +40,7 @@ final class DeclareGrammar implements GrammarInterface */ public function parse(Buffer $src): \Generator { + $quoted = []; while ($n = $src->next()) { switch ($n->char) { case '"': diff --git a/src/Streams/src/StreamWrapper.php b/src/Streams/src/StreamWrapper.php index df11eb9db..f6e8c183a 100644 --- a/src/Streams/src/StreamWrapper.php +++ b/src/Streams/src/StreamWrapper.php @@ -173,7 +173,7 @@ public static function register() return; } - stream_wrapper_register('spiral', __CLASS__); + stream_wrapper_register('spiral', self::class); self::$registered = true; } diff --git a/src/Tokenizer/src/Reflection/ReflectionFile.php b/src/Tokenizer/src/Reflection/ReflectionFile.php index 839b9ebe6..49d9df84d 100644 --- a/src/Tokenizer/src/Reflection/ReflectionFile.php +++ b/src/Tokenizer/src/Reflection/ReflectionFile.php @@ -255,7 +255,7 @@ public function exportSchema(): array */ protected function importSchema(array $cache) { - list($this->hasIncludes, $this->declarations, $this->functions, $this->namespaces) = $cache; + [$this->hasIncludes, $this->declarations, $this->functions, $this->namespaces] = $cache; } /** @@ -599,7 +599,7 @@ private function registerInvocation( //Nested invocations $this->locateInvocations($arguments, $invocationLevel + 1); - list($class, $operator, $name) = $this->fetchContext($invocationID, $argumentsID); + [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID); if (!empty($operator) && empty($class)) { //Non detectable @@ -639,7 +639,7 @@ private function fetchContext(int $invocationTID, int $argumentsTID): array } if (!empty($operator)) { - list($class, $name) = explode($operator, $name); + [$class, $name] = explode($operator, $name); //We now have to clarify class name if (in_array($class, ['self', 'static', '$this'])) { diff --git a/src/Views/src/Loader/PathParser.php b/src/Views/src/Loader/PathParser.php index 70ce117fd..4f56282e5 100644 --- a/src/Views/src/Loader/PathParser.php +++ b/src/Views/src/Loader/PathParser.php @@ -83,7 +83,7 @@ public function parse(string $path): ?ViewPath } if (strpos($filename, LoaderInterface::NS_SEPARATOR) !== false) { - list($namespace, $filename) = explode(LoaderInterface::NS_SEPARATOR, $filename); + [$namespace, $filename] = explode(LoaderInterface::NS_SEPARATOR, $filename); } //Twig like namespaces