bitExpert / phpstan-magento

Magento specific extension for PHPStan
MIT License
134 stars 24 forks source link

Compatibility with phpstan 1.7+ #245

Closed sta1r closed 2 years ago

sta1r commented 2 years ago

I'm running v0.21.0 with phpstan/phpstan 1.7.1. For:

vendor/bin/phpstan analyse -l 2 module-path/file.php -v

I see persistent errors relating to cache folder creation. Example:

 -- --------------------------------------------------------------------------------
     Error
 -- --------------------------------------------------------------------------------
     Internal error: Internal error: Failed to create directory
     "/var/folders/tk/xvp5s1qd77131xvk85lq5snw0000gn/T/phpstan/cache/PHPStan"
     (unknown cause). in file
     /Users/alastairmucklow/Sites/magento-cc-2.4.4/app/code/Dotdigitalgroup/Email/M
     odel/Sync/Subscriber/SubscriberWithSalesExporter.php

     Post the following stack trace to
     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md:
     #0
     /Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/bitexpert/phpstan-magento
     /src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php(61):
     bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->makeDir('/var/folde
     rs/tk...')
     #1
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Cache/Cache.php(28):
     bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->save('Dotdigitalgro
     up...', '', '<?php\nnamespace...')
     #2
     /Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/bitexpert/phpstan-magento
     /src/bitExpert/PHPStan/Magento/Autoload/FactoryAutoloader.php(42):
     PHPStan\Cache\Cache->save('Dotdigitalgroup...', '', '<?php\nnamespace...')
     #3
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator
     .php(270):
     bitExpert\PHPStan\Magento\Autoload\FactoryAutoloader->autoload('Dotdigitalgrou
     p...')
     #4
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/SourceLocator/FileReadTrapStreamWra
     pper.php(59):
     PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator::PHPSt
     an\Reflection\BetterReflection\SourceLocator\{closure}()
     #5
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator
     .php(282):
     PHPStan\Reflection\BetterReflection\SourceLocator\FileReadTrapStreamWrapper::w
     ithStreamWrapperOverride(Object(Closure))
     #6
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator
     .php(114):
     PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locat
     eClassByName('Dotdigitalgroup...')
     #7
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/Aggreg
     ateSourceLocator.php(28):
     PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locat
     eIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector),
     Object(PHPStan\BetterReflection\Identifier\Identifier))
     #8
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/Memoiz
     ingSourceLocator.php(33):
     PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIden
     tifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector),
     Object(PHPStan\BetterReflection\Identifier\Identifier))
     #9
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/DefaultReflecto
     r.php(32):
     PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIden
     tifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector),
     Object(PHPStan\BetterReflection\Identifier\Identifier))
     #10
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingReflector.php(45
     ):
     PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass('Dotdigitalg
     roup...')
     #11
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(151):
     PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectClass
     ('Dotdigitalgroup...')
     #12
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(3
     4):
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasClass('Dotdig
     italgroup...')
     #13
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Rules/ClassCaseSensitivityCheck.php(34):
     PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasClass('D
     otdigitalgroup...')
     #14
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Rules/Namespaces/ExistingNamesInUseRule.php(107):
     PHPStan\Rules\ClassCaseSensitivityCheck->checkClassNames(Array)
     #15
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Rules/Namespaces/ExistingNamesInUseRule.php(61):
     PHPStan\Rules\Namespaces\ExistingNamesInUseRule->checkClasses(Array)
     #16
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/FileAnalyser.php(102):
     PHPStan\Rules\Namespaces\ExistingNamesInUseRule->processNode(Object(PhpParser\
     Node\Stmt\Use_), Object(PHPStan\Analyser\MutatingScope))
     #17
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/NodeScopeResolver.php(378):
     PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PhpParser\Nod
     e\Stmt\Use_), Object(PHPStan\Analyser\MutatingScope))
     #18
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/NodeScopeResolver.php(323):
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt
     \Use_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
     #19
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/NodeScopeResolver.php(535):
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stm
     t\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
     #20
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/NodeScopeResolver.php(294):
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt
     \Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
     #21
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Analyser/FileAnalyser.php(189):
     PHPStan\Analyser\NodeScopeResolver->processNodes(Array,
     Object(PHPStan\Analyser\MutatingScope), Object(Closure))
     #22
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Command/WorkerCommand.php(143):
     PHPStan\Analyser\FileAnalyser->analyseFile('/Users/alastair...', Array,
     Object(PHPStan\Rules\Registry), NULL)
     #23
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}(Array)
     #24
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110):
     _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data', Array)
     #25
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     _PHPStan_c24aa5a16\Clue\React\NDJson\Decoder->handleData(Array)
     #26
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/react/stream/src/Util.php(62):
     _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data', Array)
     #27
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
     _PHPStan_c24aa5a16\React\Stream\Util::_PHPStan_c24aa5a16\React\Stream\{closure
     }('{"action":"anal...')
     #28
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154):
     _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data', Array)
     #29
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):
     _PHPStan_c24aa5a16\React\Stream\DuplexResourceStream->handleData(Resource id
     #4117)
     #30
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):
     _PHPStan_c24aa5a16\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NUL
     L)
     #31
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/src/Command/WorkerCommand.php(106):
     _PHPStan_c24aa5a16\React\EventLoop\StreamSelectLoop->run()
     #32
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/symfony/console/Command/Command.php(259):
     PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_c24aa5a16\Symfony\Compo
     nent\Console\Input\ArgvInput),
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))
     #33
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/symfony/console/Application.php(856):
     _PHPStan_c24aa5a16\Symfony\Component\Console\Command\Command->run(Object(_PHPS
     tan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))
     #34
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/symfony/console/Application.php(259):
     _PHPStan_c24aa5a16\Symfony\Component\Console\Application->doRunCommand(Object(
     PHPStan\Command\WorkerCommand),
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))
     #35
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/vendor/symfony/console/Application.php(157):
     _PHPStan_c24aa5a16\Symfony\Component\Console\Application->doRun(Object(_PHPSta
     n_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))
     #36
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/bin/phpstan(96):
     _PHPStan_c24aa5a16\Symfony\Component\Console\Application->run()
     #37
     phar:///Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/ph
     pstan.phar/bin/phpstan(97): _PHPStan_c24aa5a16\{closure}()
     #38
     /Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/phpstan/phpstan/phpstan(8
     ): require('phar:///Users/a...')
     #39 /Users/alastairmucklow/Sites/magento-cc-2.4.4/vendor/bin/phpstan(117):
     include('/Users/alastair...')
     #40 {main}
     Internal error: Internal error: Failed to create directory
     "/var/folders/tk/xvp5s1qd77131xvk85lq5snw0000gn/T/phpstan/cache/PHPStan"
     (unknown cause). in file
     /Users/alastairmucklow/Sites/magento-cc-2.4.4/app/code/Dotdigitalgroup/Email/M
     odel/Sync/Subscriber/SubscriberExporter.php
     Child process error (exit code 1):
 -- --------------------------------------------------------------------------------
shochdoerfer commented 2 years ago

Thanks for opening the issue. For now, you need to downgrade to PHPStan 1.6, please.

There's an issue with our custom autoloaders (for the Magento generated classes) and PHPStan 1.7. See in #243 and the related issue I have opened in the phpstan repo.

Will try to debug and fix it in the next few days.

shochdoerfer commented 2 years ago

We've just released version 0.22.0 which will not allow being installed together with PHPStan 1.7, you have to use PHPStan 1.6 for now.

We tried everything possible to make the extension compatible with PHPStan 1.7 but we could not find a way to do it. We have to wait for PHPStan core to offer different extension points as the whole autoloader logic we are using to generate the missing Magento files (e.g. factory, proxy, ...) do no longer work with the changes made in PHPStan 1.7.

We will keep an eye on the development of newer PHPStan versions, once we are able to fix this, we will. Sorry for this.

shochdoerfer commented 2 years ago

Fixed with #243 and PHPStan 1.7.2.

We've just published a new release 0.23.0 with the new PHPStan requirement.

tr33m4n commented 1 year ago

@shochdoerfer Looks like this issue is happening again:

PHPStan Magento version: v0.30.1 PHPStan version: 1.10.14

Seeing errors along the lines of:


[ERROR] Could not process "SomePHPFile.php" file, due to:
         "System error: "Failed to create directory "/var/folders/7c/kf_y_trs4wjfj2hzp_9kfy4m0000gp/T/cache/PHPStan"
         (unknown cause)."
         Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 107
tr33m4n commented 1 year ago

A better stack trace. This was used in conjunction with Rector https://github.com/rectorphp/rector:

[ERROR] Could not process "EventFactory.php" file, due to:
         "System error: "Failed to create directory "/var/folders/7c/kf_y_trs4wjfj2hzp_9kfy4m0000gp/T/cache/PHPStan"
         (unknown cause)."

         Stack trace:
         #0 vendor/bitexpert/phpstan-magento/src/bitExpert/PHPStan/Magento/Autoload/Cache/FileCacheStorage.php(61):
         bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->makeDir('/var/folders/7c...')
         #1 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Cache/Cache.php(28):
         bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->save('Ampersand\\Emars...', '',
         '<?php\nnamespace...')
         #2 vendor/bitexpert/phpstan-magento/src/bitExpert/PHPStan/Magento/Autoload/FactoryAutoloader.php(53):
         PHPStan\Cache\Cache->save('Ampersand\\Emars...', '', '<?php\nnamespace...')
         #3
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/A
         utoloadSourceLocator.php(277):
         bitExpert\PHPStan\Magento\Autoload\FactoryAutoloader->autoload('Ampersand\\Emars...')
         #4
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/F
         ileReadTrapStreamWrapper.php(62):
         PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator::PHPStan\Reflection\BetterReflection\So
         urceLocator\{closure}()
         #5
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/A
         utoloadSourceLocator.php(289):
         PHPStan\Reflection\BetterReflection\SourceLocator\FileReadTrapStreamWrapper::withStreamWrapperOverride(Object(C
         losure))
         #6
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/A
         utoloadSourceLocator.php(119):
         PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locateClassByName('Ampersand\\Emars..
         .')
         #7
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Sourc
         eLocator/Type/AggregateSourceLocator.php(26):
         PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locateIdentifier(Object(PHPStan\Bette
         rReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
         #8
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Sourc
         eLocator/Type/MemoizingSourceLocator.php(33):
         PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier(Object(PHPStan\BetterRefl
         ection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
         #9
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Sourc
         eLocator/Type/AggregateSourceLocator.php(26):
         PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier(Object(PHPStan\BetterRefl
         ection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
         #10
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Sourc
         eLocator/Type/MemoizingSourceLocator.php(33):
         PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier(Object(PHPStan\BetterRefl
         ection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
         #11
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Refle
         ctor/DefaultReflector.php(32):
         PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier(Object(PHPStan\BetterRefl
         ection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
         #12
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/Memoi
         zingReflector.php(45):
         PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass('Ampersand\\Emars...')
         #13
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectio
         nProvider.php(149):
         PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectClass('Ampersand\\Emars...')
         #14
         phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingRefl
         ectionProvider.php(35):
         PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasClass('Ampersand\\Emars...')
         #15 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(1126):
         PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasClass('Ampersand\\Emars...')
         #16 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(551):
         PHPStan\Type\ObjectType->getClassReflection()
         #17 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3327):
         PHPStan\Type\ObjectType->hasMethod('create')
         #18 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3346):
         PHPStan\Analyser\MutatingScope->filterTypeWithMethod(Object(PHPStan\Type\ObjectType), 'create')
         #19 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1356):
         PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType), 'create',
         Object(PhpParser\Node\Expr\MethodCall))
         #20 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1362):
         PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()
         #21 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(558):
         PHPStan\Analyser\MutatingScope->resolveType('$this->eventFac...', Object(PhpParser\Node\Expr\MethodCall))
         #22 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(744):
         PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall))
         #23 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(558):
         PHPStan\Analyser\MutatingScope->resolveType('$event = $this-...', Object(PhpParser\Node\Expr\Assign))
         #24 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1473):
         PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\Assign))
         #25 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(567):
         PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr(Object(PhpParser\Node\Expr\Assign),
         Object(PHPStan\Analyser\MutatingScope))
         #26 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(362):
         PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression),
         Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
         #27 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(531):
         PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array,
         Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
         #28 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(362):
         PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod),
         Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer),
         Object(PHPStan\Analyser\StatementContext))
         #29 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(609):
         PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array,
         Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer),
         Object(PHPStan\Analyser\StatementContext))
         #30 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(362):
         PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_),
         Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
         #31 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(581):
         PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array,
         Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
         #32 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(331):
         PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_),
         Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
         #33 vendor/rector/rector/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php(328):
         PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope),
         Object(Closure))
         #34 vendor/rector/rector/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php(215):
         Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver->processNodesWithDependentFiles('/Users/dandoyl
         e...', Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
         #35 vendor/rector/rector/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php(41):
         Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver->processNodes(Array, '/Users/dandoyle...')
         #36 vendor/rector/rector/src/Application/FileProcessor.php(54):
         Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator->decorateNodesFromFile(Object(Rector\Core\ValueObject\Ap
         plication\File), Array)
         #37 vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(143):
         Rector\Core\Application\FileProcessor->parseFileInfoToLocalCache(Object(Rector\Core\ValueObject\Application\Fi
         le))
         #38 vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(97):
         Rector\Core\Application\FileProcessor\PhpFileProcessor->parseFileAndDecorateNodes(Object(Rector\Core\ValueObje
         ct\Application\File))
         #39 vendor/rector/rector/packages/Parallel/WorkerRunner.php(130):
         Rector\Core\Application\FileProcessor\PhpFileProcessor->process(Object(Rector\Core\ValueObject\Application\Fil
         e), Object(Rector\Core\ValueObject\Configuration))
         #40 vendor/rector/rector/packages/Parallel/WorkerRunner.php(106):
         Rector\Parallel\WorkerRunner->processFiles(Object(Rector\Core\ValueObject\Application\File),
         Object(Rector\Core\ValueObject\Configuration), Array)
         #41 vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
         Rector\Parallel\WorkerRunner->Rector\Parallel\{closure}(Array)
         #42 vendor/rector/rector/vendor/clue/ndjson-react/src/Decoder.php(117):
         RectorPrefix202304\Evenement\EventEmitter->emit('data', Array)
         #43 vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
         RectorPrefix202304\Clue\React\NDJson\Decoder->handleData(Array)
         #44 vendor/rector/rector/vendor/react/stream/src/Util.php(62):
         RectorPrefix202304\Evenement\EventEmitter->emit('data', Array)
         #45 vendor/rector/rector/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):
         RectorPrefix202304\React\Stream\Util::RectorPrefix202304\React\Stream\{closure}('{"action":"main...')
         #46 vendor/rector/rector/vendor/react/stream/src/DuplexResourceStream.php(154):
         RectorPrefix202304\Evenement\EventEmitter->emit('data', Array)
         #47 vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(201):
         RectorPrefix202304\React\Stream\DuplexResourceStream->handleData(Resource id #3046)
         #48 vendor/rector/rector/vendor/react/event-loop/src/StreamSelectLoop.php(173):
         RectorPrefix202304\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
         #49 vendor/rector/rector/src/Console/Command/WorkerCommand.php(63):
         RectorPrefix202304\React\EventLoop\StreamSelectLoop->run()
         #50 vendor/rector/rector/vendor/symfony/console/Command/Command.php(311):
         Rector\Core\Console\Command\WorkerCommand->execute(Object(RectorPrefix202304\Symfony\Component\Console\Input\A
         rgvInput), Object(RectorPrefix202304\Symfony\Component\Console\Output\ConsoleOutput))
         #51 vendor/rector/rector/vendor/symfony/console/Application.php(899):
         RectorPrefix202304\Symfony\Component\Console\Command\Command->run(Object(RectorPrefix202304\Symfony\Component\
         Console\Input\ArgvInput), Object(RectorPrefix202304\Symfony\Component\Console\Output\ConsoleOutput))
         #52 vendor/rector/rector/vendor/symfony/console/Application.php(320):
         RectorPrefix202304\Symfony\Component\Console\Application->doRunCommand(Object(Rector\Core\Console\Command\Work
         erCommand), Object(RectorPrefix202304\Symfony\Component\Console\Input\ArgvInput),
         Object(RectorPrefix202304\Symfony\Component\Console\Output\ConsoleOutput))
         #53 vendor/rector/rector/src/Console/ConsoleApplication.php(49):
         RectorPrefix202304\Symfony\Component\Console\Application->doRun(Object(RectorPrefix202304\Symfony\Component\Co
         nsole\Input\ArgvInput), Object(RectorPrefix202304\Symfony\Component\Console\Output\ConsoleOutput))
         #54 vendor/rector/rector/vendor/symfony/console/Application.php(206):
         Rector\Core\Console\ConsoleApplication->doRun(Object(RectorPrefix202304\Symfony\Component\Console\Input\ArgvIn
         put), Object(RectorPrefix202304\Symfony\Component\Console\Output\ConsoleOutput))
         #55 vendor/rector/rector/bin/rector.php(128): RectorPrefix202304\Symfony\Component\Console\Application->run()
         #56 vendor/rector/rector/bin/rector(5): require_once('/Users/dandoyle...')
         #57 vendor/bin/rector(120): include('/Users/dandoyle...')
         #58 {main}". On line: 107
shochdoerfer commented 1 year ago

@tr33m4n what do you mean by "This was used in conjunction with Rector" - do you execute PHPStan in a specific way? Does it work with "older" versions of PHPStan? It's a bit hard to help without a proper test case.

tr33m4n commented 1 year ago

@shochdoerfer After taking a look further at this, feels like this is more of a "Rector" issue than PHPStan Magento, sorry about that! Rector will load parts of PHPStan as it uses some of its functionality in the background when comparing statically

shochdoerfer commented 1 year ago

@tr33m4n I am not unhappy about this turn of events :P