Skip to content

Commit

Permalink
Merge pull request #471 from samsonasik/add-rector-for-qa
Browse files Browse the repository at this point in the history
[Rector] Start Add Rector for QA
  • Loading branch information
butschster authored Nov 11, 2021
2 parents d398347 + 81d5855 commit cc6cb37
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
use Rector\Set\ValueObject\LevelSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src/*/src',
]);

$parameters->set(Option::SKIP, [
CountOnNullRector::class,
]);

$containerConfigurator->import(LevelSetList::UP_TO_PHP_72);
};
2 changes: 1 addition & 1 deletion src/Console/src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/Csrf/src/Middleware/CsrfMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class DeclareGrammar implements GrammarInterface
*/
public function parse(Buffer $src): \Generator
{
$quoted = [];
while ($n = $src->next()) {
switch ($n->char) {
case '"':
Expand Down
2 changes: 1 addition & 1 deletion src/Streams/src/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function register()
return;
}

stream_wrapper_register('spiral', __CLASS__);
stream_wrapper_register('spiral', self::class);

self::$registered = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Tokenizer/src/Reflection/ReflectionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Views/src/Loader/PathParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc6cb37

Please sign in to comment.