merge composer_validate (#5620)

This commit is contained in:
Tomas Votruba 2021-02-19 01:36:48 +01:00 committed by GitHub
parent 1ea1f5852b
commit 652459ad3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 68 deletions

View File

@ -10,8 +10,8 @@ jobs:
matrix:
actions:
-
name: 'Show command'
run: bin/rector show --ansi
name: 'Composer Validate'
run: composer validate --strict
-
name: Validate Fixtures

View File

@ -15,6 +15,14 @@ jobs:
bin/rector init-recipe --ansi
bin/rector generate --ansi
-
name: 'Rector List'
run: bin/rector list
-
name: 'Show command'
run: bin/rector show --ansi
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
@ -26,7 +34,9 @@ jobs:
php-version: 7.4
coverage: none
# must be removed, as local config is missing dev dependencies
- run: rm phpstan-for-rector.neon
- run: composer install --no-progress --ansi
- run: composer install --no-progress --ansi --no-dev
- run: ${{ matrix.actions.run }}

View File

@ -1,14 +0,0 @@
name: Composer validate
on:
pull_request: null
jobs:
tests:
runs-on: ubuntu-latest
name: Composer validate
steps:
- uses: actions/checkout@v2
- run: composer validate --strict

View File

@ -1,34 +0,0 @@
name: Rector Run
on:
pull_request: null
jobs:
matrix:
strategy:
fail-fast: false
matrix:
actions:
-
name: Rector without Dev Dependencies
install: composer install --no-progress --ansi --no-dev
run: |
# must be removed, as local config is missing dev dependencies
rm phpstan-for-rector.neon
bin/rector list
runs-on: ubuntu-latest
name: ${{ matrix.actions.name }}
steps:
- uses: actions/checkout@v2
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- run: ${{ matrix.actions.install }}
- run: ${{ matrix.actions.run }}

View File

@ -22,13 +22,14 @@ use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\PackageBuilder\Php\TypeChecker;
final class AssignManipulator
{
/**
* @var string[]
* @var array<class-string<Node>>
*/
private const MODIFYING_NODES = [
private const MODIFYING_NODE_TYPES = [
AssignOp::class,
PreDec::class,
PostDec::class,
@ -56,16 +57,23 @@ final class AssignManipulator
*/
private $propertyFetchAnalyzer;
/**
* @var TypeChecker
*/
private $typeChecker;
public function __construct(
BetterStandardPrinter $betterStandardPrinter,
NodeNameResolver $nodeNameResolver,
BetterNodeFinder $betterNodeFinder,
PropertyFetchAnalyzer $propertyFetchAnalyzer
PropertyFetchAnalyzer $propertyFetchAnalyzer,
TypeChecker $typeChecker
) {
$this->nodeNameResolver = $nodeNameResolver;
$this->betterStandardPrinter = $betterStandardPrinter;
$this->betterNodeFinder = $betterNodeFinder;
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
$this->typeChecker = $typeChecker;
}
/**
@ -92,7 +100,7 @@ final class AssignManipulator
return true;
}
if ($parent !== null && $this->isValueModifyingNode($parent)) {
if ($parent !== null && $this->typeChecker->isInstanceOf($parent, self::MODIFYING_NODE_TYPES)) {
return true;
}
@ -145,17 +153,4 @@ final class AssignManipulator
return $this->isLeftPartOfAssign($node);
});
}
private function isValueModifyingNode(Node $node): bool
{
foreach (self::MODIFYING_NODES as $modifyingNode) {
if (! is_a($node, $modifyingNode)) {
continue;
}
return true;
}
return false;
}
}