Skip to content

Commit

Permalink
Update to nikic/php-parser 4.13.0 (#904)
Browse files Browse the repository at this point in the history
* Update to nikic/php-parser 4.13.0

* check Arg on PregMatchTypeCorrector

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* check Aeg on NodeTransformer

* check arg on RegexPatternArgumentManipulator

* [ci-review] Rector Rectify

* check Arg on FuncCallManipulator

* check Arg on ClassMethodAssignManipulator

* check Arg on StringifyStrNeedlesRector

* [ci-review] Rector Rectify

* Arg check on CompactFuncCallAnalyzer

* Arg check on CompactFuncCallAnalyzer

* check Arg on CallableInMethodCallToVariableRector

* check Arg on CallableInMethodCallToVariableRector

* Arg check on BeConstructedWithAssignFactory

* Add ArgsAnalyzer to check Arg instance in in Args position

* Arg check on SubstrMatchAndRefactor

* Arg check on NewArgToMethodCallRector

* check Arg on ConsistentImplodeRector

* Arg check on DuringMethodCallFactory

* Arg check on CountOnNullRector

* Arg check on ExportToReflectionFunctionRector

* Arg check on ImplodeAnalyzer

* Arg check on WhileEachToForeachRector

* Arg check on DowngradeIsCountableRector

* Arg check on VariableNaming

* Arg check on ConditionResolver

* Arg check on DirNameFileConstantToDirConstantRector

* Arg check on NewFluentChainMethodCallNodeAnalyzer

* Arg check on MbStrrposEncodingArgumentPositionRector

* Arg check on UnwrapFutureCompatibleIfFunctionExistsRector

* Arg check on JsonArrayFactory

* Arg check on RemoveFuncCallRector

* Arg check on ArrayKeyExistsOnPropertyRector

* Arg check on FunctionExistsFunCallAnalyzer

* Arg check on SetTypeToCastRector

* Arg check on ReplaceEachAssignmentWithKeyCurrentRector

* Arg check on PregMatchTypeCorrector

* Arg check on SwapFuncCallArgumentsRector

* Arg check on FilterVarToAddSlashesRector

* Arg check on ClassOnObjectRector

* Arg check on ClassOnObjectRector

* Arg check on CallerParamMatcher

* Arg check on ArgumentFuncCallToMethodCallRector

* add ArgsAnalyzer::isArgsInstanceInArgsPositions() for multi check directly

* Arg check on ArraySpreadInsteadOfArrayMergeRector

* Arg check on GetDebugTypeRector

* Arg check on GetDebugTypeRector

* Arg check on StringifyDefineRector

* Arg check on DowngradeArrayKeyFirstLastRector

* Arg check on IsArrayAndDualCheckToAble

* Arg check on CreateFunctionToAnonymousFunctionRector

* Arg check on AddArrayDefaultToArrayPropertyRector

* Arg check on IsObjectOnIncompleteClassRector

* Arg check on ForToForeachRector

* Arg check on ClassMethodNodeRemover

* Arg check on CompactConverter

* Arg check on IsAWithStringWithThirdArgumentRector

* Arg check on CallUserFuncArrayToVariadicRector

* Arg check on MysqlPConnectToMysqliConnectRector

* Arg check on MysqlAssignToMysqliRector

* Arg check on InArrayAndArrayKeysToArrayKeyExistsRector

* Arg check on NonVariableToVariableOnFunctionCallRector

* Arg check on VersionCompareFuncCallToConstantRector

* fix test

* Arg check on StrEndsWithRector

* Arg check on TokenManipulator

* Arg check on StrStartsWithFactory

* Arg check on DowngradeIsIterableRector

* Arg check on DowngradeStripTagsCallWithArrayRector

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* Arg check on ChangeDiffForHumansArgsRector

* Arg check on ThrowWithPreviousExceptionRector

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* Arg check on StrposMatchAndRefactor

* Arg check on UseMessageVariableForSprintfInSymfonyStyleRector

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* fix

* Arg check on PhpSpecClassToPHPUnitClassRector

* Arg check on CallTypesResolver

* Arg check on NonVariableToVariableOnFunctionCallRector

* Arg check on DispatchStringToObjectRector

* Arg check on GetClassToInstanceOfRector

* Arg check on StrncmpMatchAndRefactor

* Arg check on StrncmpMatchAndRefactor

* Arg check on ArraySpreadInsteadOfArrayMergeRector

* Arg check on ArrayKeysAndInArrayToArrayKeyExistsRector

* Arg check on DowngradeSessionStartArrayOptionsRector

* Arg check on CountArrayToEmptyArrayComparisonRector

* Arg check on DowngradeClosureFromCallableRector

* Arg check on EregToPregMatchRector

* Arg check on GetClassOnNullRector

* Arg check on use RemoveSoleValueSprintfRector

* Arg check on UnSpreadOperatorRector

* Arg check on DowngradeStrContainsRector

* [ci-review] Rector Rectify

* Arg check on ArrayMergeOfNonArraysToSimpleArrayRector

* Arg check on IntvalToTypeCastRector

* Arg check on RemoveUnusedVariableAssignRector

* Arg check on ConsistentPregDelimiterRector

* Arg check on CountManipulator

* Arg check on DowngradeDefineArrayConstantRector

* Arg check on RemoveReferenceFromCallRector

* Arg check on SimplifyInArrayValuesRector

* Arg check on SingleInArrayToCompareRector

* Arg check on SimplifyIfIssetToNullCoalescingRector

* Arg check on StrlenZeroToIdenticalEmptyStringRector

* [ci-review] Rector Rectify

* Add ComplexType check

* Arg check on UnwrapSprintfOneArgumentRector

* Arg check on CurrentAndParentClassMethodComparator

* Arg check on CompactToVariablesRector

* [ci-review] Rector Rectify

* ComplexType check

* Arg check on MockVariableCollector

* re-generate preload.php

* [ci-review] Rector Rectify

* fix phpstan ignore error

* Arg check on FormerNullableArgumentToScalarTypedRector

* ComplexType check on MakeTypedPropertyNullableIfCheckedRector

* Arg check on ArgumentRemoverRector

* using getArgs() on PhpSpecPromisesToPHPUnitAssertRector

* using getArgs() on args using in method call args

* Arg check on PhpSpecMocksToPHPUnitMocksRector

* Arg check on SetCookieRector

* Arg check on StringsAssertNakedRector

* Arg check on PregReplaceEModifierRector

* using getArgs() on multiple count() usage

* using getArgs() on args using in method call args

* using getArgs() on args using in method call args

* using getArgs() on args using in method call args

* Arg check on MysqlFuncCallToMysqliRector

* using getArgs() on args using in method call args

* using getArgs() on args using in method call args

* Arg check on DowngradeCovariantReturnTypeRector

* Arg check on SetCookieOptionsArrayToArgumentsRector

* using getArgs() on too complex check

* Arg check on DowngradeNegativeStringOffsetToStrlenRector

* ensure preload always used when file exists

* Arg check on SimplifyFuncGetArgsCountRector

* set back reportUnmatchedIgnoredErrors as different between local and github

* Arg check on ArgumentDefaultValueReplacer

* fix test of getArgs() on MysqlQueryMysqlErrorWithLinkRector

* Arg check on SymmetricArrayDestructuringToListRector

* Arg check on UseMessageVariableForSprintfInSymfonyStyleRector

* Arg check on ConsistentPregDelimiterRector

* Arg check on CallUserFuncToMethodCallRector

* Arg check on ArrayKeyExistsTernaryThenValueToCoalescingRector

* Arg check on SimplifyStrposLowerRector

* Arg check on CompactToVariablesRector

* Arg check on CompactToVariablesRector

* Arg check on ChangeArrayPushToArrayAssignRector

* Arg check on ChangeArrayPushToArrayAssignRector

* Arg check on CompactConverter

* final touch: Arg check on CallUserFuncWithArrowFunctionToInlineRector

* fix

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 27, 2021
1 parent 042daa1 commit 17cfa9f
Show file tree
Hide file tree
Showing 130 changed files with 1,622 additions and 452 deletions.
20 changes: 3 additions & 17 deletions bin/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
$extractedPhpstanAutoload = __DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php';
if (file_exists($extractedPhpstanAutoload)) {
require_once $extractedPhpstanAutoload;
} elseif (should_include_preload()) {
}

if (file_exists(__DIR__ . '/../preload.php')) {
require_once __DIR__ . '/../preload.php';
}

Expand Down Expand Up @@ -141,19 +143,3 @@ public function loadIfExistsAndNotLoadedYet(string $filePath): void
require_once $filePath;
}
}


// load local php-parser only in prefixed version or development repository
function should_include_preload(): bool
{
if (file_exists(__DIR__ . '/../vendor/scoper-autoload.php')) {
return true;
}

if (! file_exists(getcwd() . '/composer.json')) {
return false;
}

$composerJsonFileContent = file_get_contents(getcwd() . '/composer.json');
return strpos($composerJsonFileContent, '"name": "rector/rector"') !== false;
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"idiosyncratic/editorconfig": "^0.1.3",
"myclabs/php-enum": "^1.8",
"nette/utils": "^3.2",
"nikic/php-parser": "4.12.0",
"nikic/php-parser": "4.13.0",
"phpstan/phpdoc-parser": "^0.5.5",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-phpunit": "^0.12.22",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
use Rector\Core\NodeAnalyzer\ArgsAnalyzer;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\NodeNameResolver\NodeNameResolver;
Expand All @@ -23,7 +24,8 @@ public function __construct(
private BetterNodeFinder $betterNodeFinder,
private NodeNameResolver $nodeNameResolver,
private ParentScopeFinder $parentScopeFinder,
private NodeComparator $nodeComparator
private NodeComparator $nodeComparator,
private ArgsAnalyzer $argsAnalyzer
) {
}

Expand Down Expand Up @@ -58,12 +60,15 @@ public function correct(Node $node, Type $originalType): Type
continue;
}

if (! isset($funcCallNode->args[2])) {
if (! $this->argsAnalyzer->isArgInstanceInArgsPosition($funcCallNode->args, 2)) {
continue;
}

/** @var Arg $thirdArg */
$thirdArg = $funcCallNode->args[2];

// are the same variables
if (! $this->nodeComparator->areNodesEqual($funcCallNode->args[2]->value, $node)) {
if (! $this->nodeComparator->areNodesEqual($thirdArg->value, $node)) {
continue;
}

Expand Down
12 changes: 1 addition & 11 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ parameters:
scanDirectories:
- stubs

# reportUnmatchedIgnoredErrors: false
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
Expand Down Expand Up @@ -106,7 +106,6 @@ parameters:
- '#Cognitive complexity for "Rector\\Transform\\Rector\\Class_\\AddInterfaceByParentRector\:\:refactor\(\)" is \d+, keep it under 9#'


- '#Parameter \#1 \$type of class PhpParser\\Node\\NullableType constructor expects PhpParser\\Node\\Identifier\|PhpParser\\Node\\Name\|string, PhpParser\\Node\\Identifier\|PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|PhpParser\\Node\\UnionType given#'
- '#Parameter \#1 \$objectType of method Rector\\Naming\\Naming\\PropertyNaming\:\:fqnToVariableName\(\) expects PHPStan\\Type\\ObjectType\|string, PHPStan\\Type\\Type given#'
# known value
- '#Property PhpParser\\Node\\Stmt\\Foreach_\:\:\$valueVar \(PhpParser\\Node\\Expr\) does not accept PhpParser\\Node\\Expr\|null#'
Expand Down Expand Up @@ -358,12 +357,6 @@ parameters:

- '#Cannot call method getSmartFileInfo\(\) on Rector\\Core\\ValueObject\\Application\\File\|null#'

# doc typo in php-parser
- '#Parameter \#2 \$args of class PhpParser\\Node\\Expr\\FuncCall constructor expects array<PhpParser\\Node\\Arg\>, array<int, PhpParser\\Node\\Arg\|null\> given#'

# php-parser bug
- '#Parameter \#1 \$type of method PhpParser\\Builder\\FunctionLike\:\:setReturnType\(\) expects PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|string, PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|PhpParser\\Node\\UnionType given#'

- '#Method Rector\\Core\\Tests\\DependencyInjection\\ConfigurableRectorImportConfigCallsMergeTest\:\:provideData\(\) return type has no value type specified in iterable type Iterator#'

-
Expand Down Expand Up @@ -514,6 +507,3 @@ parameters:
- packages/FileFormatter/ValueObject/NewLine.php #15
- src/Application/VersionResolver.php #16
- utils/compiler/src/Unprefixer.php #9

# false positive, class exists is right above
- '#Parameter \#1 \$objectOrClass of class ReflectionClass constructor expects class\-string<Rector\\RectorInstaller\\GeneratedConfig\>\|Rector\\RectorInstaller\\GeneratedConfig, string given#'
Loading

0 comments on commit 17cfa9f

Please sign in to comment.