Closed sta1r closed 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.
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.
Fixed with #243 and PHPStan 1.7.2.
We've just published a new release 0.23.0 with the new PHPStan requirement.
@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
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
@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.
@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
@tr33m4n I am not unhappy about this turn of events :P
I'm running v0.21.0 with phpstan/phpstan 1.7.1. For:
I see persistent errors relating to cache folder creation. Example: