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

Failed to open directory: "PHPStan\Reflection\BetterReflection\SourceLocator\FileReadTrapStreamWrapper::dir_opendir" call failed #8610

Closed
staabm opened this issue Dec 29, 2022 · 4 comments

Comments

@staabm
Copy link
Contributor

staabm commented Dec 29, 2022

Bug report

In https://github.com/redaxo/redaxo/actions/runs/3800786744/jobs/6464589280 / redaxo/redaxo#5459 we ran into

Error: Reached internal errors count limit of 50, exiting...
Error: Internal error: Internal error: RecursiveDirectoryIterator::__construct(/home/runner/work/redaxo/redaxo/redaxo/src/core/lib/): Failed to open directory: "PHPStan\Reflection\BetterReflection\SourceLocator\FileReadTrapStreamWrapper::dir_opendir" call failed in file /home/runner/work/redaxo/redaxo/redaxo/src/core/lib/console/setup/run.php

Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md: 
#0 /home/runner/work/redaxo/redaxo/redaxo/src/core/lib/autoload.php(255): RecursiveDirectoryIterator->__construct()
#1 /home/runner/work/redaxo/redaxo/redaxo/src/core/lib/autoload.php(194): rex_autoload::_addDirectory()
#2 /home/runner/work/redaxo/redaxo/redaxo/src/core/lib/autoload.php(117): rex_autoload::reload()
#3 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator.php(278): rex_autoload::autoload()
#4 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/FileReadTrapStreamWrapper.php(61): PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator::PHPStan\Reflection\BetterReflection\SourceLocator\{closure}()
#5 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator.php(272): PHPStan\Reflection\BetterReflection\SourceLocator\FileReadTrapStreamWrapper::withStreamWrapperOverride()
#6 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator.php(119): PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locateClassByName()
#7 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php(26): PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator->locateIdentifier()
#8 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocator.php(33): PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier()
#9 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/DefaultReflector.php(32): PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier()
#10 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingReflector.php(45): PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass()
#11 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(149): PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectClass()
#12 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(35): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasClass()
#13 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Type/Constant/ConstantStringType.php(88): PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasClass()
#14 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/DependencyResolver.php(435): PHPStan\Type\Constant\ConstantStringType->isClassStringType()
#15 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Dependency/DependencyResolver.php(412): PHPStan\Dependency\DependencyResolver->considerArrayForCallableTest()
#16 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(158): PHPStan\Dependency\DependencyResolver->resolveDependencies()
#17 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(98): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
#18 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(506): PHPStan\Node\ClassStatementsGatherer->__invoke()
#19 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2478): PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}()
#20 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1471): PHPStan\Analyser\NodeScopeResolver->callNodeCallbackWithExpression()
#21 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2742): PHPStan\Analyser\NodeScopeResolver->processExprNode()
#22 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1535): PHPStan\Analyser\NodeScopeResolver->processArgs()
#23 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2012): PHPStan\Analyser\NodeScopeResolver->processExprNode()
#24 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(640): PHPStan\Analyser\NodeScopeResolver->processExprNode()
#25 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(360): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#26 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(646): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#27 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(360): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#28 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(505): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#29 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(360): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#30 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(599): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#31 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(327): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#32 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(175): PHPStan\Analyser\NodeScopeResolver->processNodes()
#33 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(147): PHPStan\Analyser\FileAnalyser->analyseFile()
#34 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}()
#35 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110): _PHPStan_5c71ab23c\Evenement\EventEmitter->emit()
#36 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_5c71ab23c\Clue\React\NDJson\Decoder->handleData()
#37 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_5c71ab23c\Evenement\EventEmitter->emit()
#38 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_5c71ab23c\React\Stream\Util::_PHPStan_5c71ab23c\React\Stream\{closure}()
#39 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_5c71ab23c\Evenement\EventEmitter->emit()
#40 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_5c71ab23c\React\Stream\DuplexResourceStream->handleData()
#41 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_5c71ab23c\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
#42 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(107): _PHPStan_5c71ab23c\React\EventLoop\StreamSelectLoop->run()
#43 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\WorkerCommand->execute()
#44 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(868): _PHPStan_5c71ab23c\Symfony\Component\Console\Command\Command->run()
#45 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259): _PHPStan_5c71ab23c\Symfony\Component\Console\Application->doRunCommand()
#46 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_5c71ab23c\Symfony\Component\Console\Application->doRun()
#47 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_5c71ab23c\Symfony\Component\Console\Application->run()
#48 phar:///home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_5c71ab23c\{closure}()
#49 /home/runner/work/redaxo/redaxo/vendor/phpstan/phpstan/phpstan(8): require('...')
#50 /home/runner/work/redaxo/redaxo/vendor/bin/phpstan(120): include('...')
#51 {main}

but the error itself is not reproducible for me locally. it happens in github actions and seems to be reproducible.

Code snippet that reproduces the problem

I wonder whether FileReadTrapStreamWrapper is missing to implement some methods.

the "prototype" class in the php.net manual contains a few more methods then the stream-wrapper of phpstan implements...?

e.g.

public dir_closedir(): bool
public dir_opendir(string $path, int $options): bool
public dir_readdir(): string
public dir_rewinddir(): bool
public mkdir(string $path, int $mode, int $options): bool
public renam(string $path_from, string $path_to): bool
public rmdir(string $path, int $options): bool

are these methods missing?

Expected output

no error

@mergeable
Copy link

mergeable bot commented Dec 29, 2022

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@staabm
Copy link
Contributor Author

staabm commented Dec 29, 2022

just remembered I had reported this very same issue a few months ago: #4294

not sure why we see it now again though


I have the feeling that the current FileReadTrapStreamWrapper contains only logic to handle file reads from e.g. include or require. but in case you do directory related operations like RecursiveDirectoryIterator it is not prepared for that situation.

our autoloader is building up a cache using these directories reading/opening (file discovery)

@staabm
Copy link
Contributor Author

staabm commented Dec 29, 2022

fixed with phpstan/phpstan-src#2154

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant