Skip to content

Commit

Permalink
merge composer_validate (#5620)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Feb 19, 2021
1 parent 1ea1f58 commit 652459a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/code_analysis_no_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}
14 changes: 0 additions & 14 deletions .github/workflows/composer_validate.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/rector.yaml

This file was deleted.

29 changes: 12 additions & 17 deletions src/NodeManipulator/AssignManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
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,
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -92,7 +100,7 @@ public function isLeftPartOfAssign(Node $node): bool
return true;
}

if ($parent !== null && $this->isValueModifyingNode($parent)) {
if ($parent !== null && $this->typeChecker->isInstanceOf($parent, self::MODIFYING_NODE_TYPES)) {
return true;
}

Expand Down Expand Up @@ -145,17 +153,4 @@ public function resolveAssignsToLocalPropertyFetches(FunctionLike $functionLike)
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;
}
}

0 comments on commit 652459a

Please sign in to comment.