Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider::hasClass(): Argument #1 ($className) must be of type string, int given #6540

Closed
stephanvierkant opened this issue Jul 1, 2021 · 4 comments · Fixed by rectorphp/rector-src#391
Labels

Comments

@stephanvierkant
Copy link
Contributor

stephanvierkant commented Jul 1, 2021

Bug Report

Subject Details
Rector version e.g. v0.11.32

PHP Fatal error: Uncaught TypeError: PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider::hasClass(): Argument #1 ($className) must be of type string, int given, called in vendor/rector/rector/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php on line 112 and defined in phar:///home/{snap}/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:25

Minimal PHP Code Causing Issue

https://getrector.org/demo/1ebdd6d7-d305-6bfa-aa66-e9270fcce247

Expected Behaviour

@TomasVotruba
Copy link
Member

Thank you for your report and demo link!

Could you send a failing test case in a pull-request, so we have it covered in Rector?
Here is step by step tutorial how to add it: https://github.com/rectorphp/rector/blob/master/docs/how_to_add_test_for_rector_rule.md

@stephanvierkant
Copy link
Contributor Author

Any idea where I should add it? Since I got a fatal error, I don't know which rule is relevant.

@samsonasik
Copy link
Member

You can run rector locally with --debug option to see what nearest rules that cause the error.

@stephanvierkant
Copy link
Contributor Author

stephanvierkant commented Jul 6, 2021

I failed to reproduce this issue in the rector-src repo. Can someone help me reproducing this issue? Thanks!

Stacktrace:

[refactoring] src/EventListener/TaggableListener.php
[applying] Rector\CodeQuality\Rector\Name\FixClassCaseSensitivityNameRector
[applying] Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector
[applying] Rector\Transform\Rector\Class_\AddInterfaceByTraitRector
[applying] Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector
[applying] Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector
[applying] Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector
[applying] Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector
[applying] Rector\Php70\Rector\ClassMethod\Php4ConstructorRector
[applying] Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector
[applying] Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector
[applying] Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector
[applying] Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector
[applying] Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector
[applying] Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector
[applying] Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector
[applying] Rector\CodeQuality\Rector\Assign\CombinedAssignRector
[applying] Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector
[applying] Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector
[applying] Rector\Php70\Rector\Assign\ListSplitStringRector
[applying] Rector\Php70\Rector\Assign\ListSwapArrayOrderRector
[applying] Rector\Php71\Rector\Assign\AssignArrayToStringRector
[applying] Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector
[applying] Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector
[applying] Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector
[applying] Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector
[applying] Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector
[applying] Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector
[applying] Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector
[applying] Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector
[applying] Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector
[applying] Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector
[applying] Rector\CodeQuality\Rector\If_\CombineIfRector
[applying] Rector\CodeQuality\Rector\If_\ShortenElseIfRector
[applying] Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector
[applying] Rector\Php70\Rector\If_\IfToSpaceshipRector
[applying] Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector
[applying] Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector
[applying] Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector
[applying] Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector
[applying] Rector\CodeQuality\Rector\Concat\JoinStringConcatRector
[applying] Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector
PHP Fatal error:  Uncaught TypeError: PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider::hasClass(): Argument #1 ($className) must be of type string, int given, called in {projectDir}/vendor/rector/rector/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php on line 109 and defined in phar://{projectDir}/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:25
Stack trace:
#0 {projectDir}/vendor/rector/rector/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php(109): PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasClass()
#1 {projectDir}/vendor/rector/rector/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php(68): Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher->resolveClassConstFetchType()
#2 {projectDir}/vendor/rector/rector/rules/CodeQuality/Rector/Array_/CallableThisArrayToAnonymousFunctionRector.php(96): Rector\NodeCollector\NodeAnalyzer\ArrayCallableMethodMatcher->match()
#3 {projectDir}/vendor/rector/rector/src/Rector/AbstractRector.php(254): Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector->refactor()
#4 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): Rector\Core\Rector\AbstractRector->enterNode()
#5 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#6 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#7 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#8 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#9 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#10 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#11 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#12 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#13 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#14 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#15 {projectDir}/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#16 {projectDir}/vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(46): PhpParser\NodeTraverser->traverse()
#17 {projectDir}/vendor/rector/rector/src/Application/FileProcessor.php(53): Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()
#18 {projectDir}/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(162): Rector\Core\Application\FileProcessor->refactor()
#19 {projectDir}/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(175): Rector\Core\Application\FileProcessor\PhpFileProcessor->Rector\Core\Application\FileProcessor\{closure}()
#20 {projectDir}/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(161): Rector\Core\Application\FileProcessor\PhpFileProcessor->tryCatchWrapper()
#21 {projectDir}/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(106): Rector\Core\Application\FileProcessor\PhpFileProcessor->refactorNodesWithRectors()
#22 {projectDir}/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(65): Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#23 {projectDir}/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(51): Rector\Core\Application\ApplicationFileProcessor->processFiles()
#24 {projectDir}/vendor/rector/rector/src/Console/Command/ProcessCommand.php(121): Rector\Core\Application\ApplicationFileProcessor->run()
#25 {projectDir}/vendor/rector/rector/vendor/symfony/console/Command/Command.php(262): Rector\Core\Console\Command\ProcessCommand->execute()
#26 {projectDir}/vendor/rector/rector/vendor/symfony/console/Application.php(828): RectorPrefix20210630\Symfony\Component\Console\Command\Command->run()
#27 {projectDir}/vendor/rector/rector/vendor/symfony/console/Application.php(255): RectorPrefix20210630\Symfony\Component\Console\Application->doRunCommand()
#28 {projectDir}/vendor/rector/rector/src/Console/ConsoleApplication.php(67): RectorPrefix20210630\Symfony\Component\Console\Application->doRun()
#29 {projectDir}/vendor/rector/rector/vendor/symfony/console/Application.php(153): Rector\Core\Console\ConsoleApplication->doRun()
#30 {projectDir}/vendor/rector/rector/bin/rector.php(47): RectorPrefix20210630\Symfony\Component\Console\Application->run()
#31 {projectDir}/vendor/rector/rector/bin/rector(5): require_once('...')
#32 {main}
thrown in phar://{projectDir}/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php on line 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants