TomasVotruba / bladestan

PHPStan analysis for Blade templates

Home Page:https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to reflect on model when Larastan and config() is used

AJenbo opened this issue · comments

This appears to be a bad interaction between bladestan, larastan and the given project. When ever an instance of Spatie\Permission\Models\Role is used i get the below stack trace.

This may well be related to #29

Drilling down to it we can see that getTable() on the model calls config() for which Laravel's container will try to resolve the Illuminate\Config\Repository class via the alias config, probably because of Illuminate\Support\Facades\Config.

    public function getTable()
    {
        return config('permission.table_names.roles', parent::getTable());
    }

Disabeling Larastan will resolve this, but that is obviously not a viable option.

Internal error: Internal error: Target class [config] does not exist. in file
 /project/app/Http/Controllers/Admin/RolesController.php 

 Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md:
 #0 /project/vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build() 
 #1 /project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve()
 #2 /project/vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve()
 #3 /project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make() 
 #4 /project/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(120): Illuminate\Foundation\Application->make()
 #5 /project/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(276): app()
 #6 /project/vendor/spatie/laravel-permission/src/Models/Role.php(41): config()
 #7 /project/vendor/nunomaduro/larastan/src/Properties/ModelPropertyExtension.php(70): Spatie\Permission\Models\Role->getTable() 
 #8 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(420): 
 NunoMaduro\Larastan\Properties\ModelPropertyExtension->hasProperty() 
 #9 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(134):
 PHPStan\Reflection\ClassReflection->hasProperty()
 #10 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3384): 
 PHPStan\Type\ObjectType->hasProperty() 
 #11 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3394): 
 PHPStan\Analyser\MutatingScope->getPropertyReflection()
 #12 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1399): 
 PHPStan\Analyser\MutatingScope->propertyFetchType()
 #13 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1405): 
 PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() 
 #14 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(556):
 PHPStan\Analyser\MutatingScope->resolveType()
 #15 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1333): 
 PHPStan\Analyser\MutatingScope->getType()
 #16 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1339): 
 PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() 
 #17 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(556):
 PHPStan\Analyser\MutatingScope->resolveType()
 #18 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1333): 
 PHPStan\Analyser\MutatingScope->getType()
 #19 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1339): 
 PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() 
 #20 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(556):
 PHPStan\Analyser\MutatingScope->resolveType()
 #21 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(742):
 PHPStan\Analyser\MutatingScope->getType()
 #22 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(556):
 PHPStan\Analyser\MutatingScope->resolveType()
 #23 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1452): 
 PHPStan\Analyser\MutatingScope->getType()
 #24 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(562):
 PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr() 
 #25 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(332):
 PHPStan\Analyser\NodeScopeResolver->processStmtNode()
 #26 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(175): 
 PHPStan\Analyser\NodeScopeResolver->processNodes() 
 #27 /project/vendor/tomasvotruba/bladestan/src/Rules/ViewRuleHelper.php(100): PHPStan\Analyser\FileAnalyser->analyseFile()
 #28 /project/vendor/tomasvotruba/bladestan/src/Rules/ViewRuleHelper.php(55):
 TomasVotruba\Bladestan\Rules\ViewRuleHelper->processTemplateFilePath() 
 #29 /project/vendor/tomasvotruba/bladestan/src/Rules/BladeRule.php(59): TomasVotruba\Bladestan\Rules\ViewRuleHelper->processNode()
 #30 /project/vendor/tomasvotruba/bladestan/src/Rules/BladeRule.php(42): 
 TomasVotruba\Bladestan\Rules\BladeRule->processLaravelViewFunction() 
 #31 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(106): 
 TomasVotruba\Bladestan\Rules\BladeRule->processNode()
 #32 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(98): 
 PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}()
 #33 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(511):
 PHPStan\Node\ClassStatementsGatherer->__invoke() 
 #34 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2484): 
 PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}() 
 #35 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1477): 
 PHPStan\Analyser\NodeScopeResolver->callNodeCallbackWithExpression() 
 #36 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(541):
 PHPStan\Analyser\NodeScopeResolver->processExprNode()
 #37 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(365):
 PHPStan\Analyser\NodeScopeResolver->processStmtNode()
 #38 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(526):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes() 
 #39 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(365):
 PHPStan\Analyser\NodeScopeResolver->processStmtNode()
 #40 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(604):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes() 
 #41 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(365):
 PHPStan\Analyser\NodeScopeResolver->processStmtNode()
 #42 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(576):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes() 
 #43 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(332):
 PHPStan\Analyser\NodeScopeResolver->processStmtNode()
 #44 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(175): 
 PHPStan\Analyser\NodeScopeResolver->processNodes() 
 #45 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(134): 
 PHPStan\Analyser\FileAnalyser->analyseFile() 
 #46 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): 
 PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}() 
 #47 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110):
 _PHPStan_eb00fd21c\Evenement\EventEmitter->emit()
 #48 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): 
 _PHPStan_eb00fd21c\Clue\React\NDJson\Decoder->handleData() 
 #49 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): 
 _PHPStan_eb00fd21c\Evenement\EventEmitter->emit()
 #50 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): 
 _PHPStan_eb00fd21c\React\Stream\Util::_PHPStan_eb00fd21c\React\Stream\{closure}()
 #51 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154):
 _PHPStan_eb00fd21c\Evenement\EventEmitter->emit()
 #52 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):
 _PHPStan_eb00fd21c\React\Stream\DuplexResourceStream->handleData() 
 #53 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):
 _PHPStan_eb00fd21c\React\EventLoop\StreamSelectLoop->waitForStreamActivity() 
 #54 phar:///project/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(97):
 _PHPStan_eb00fd21c\React\EventLoop\StreamSelectLoop->run() 
 #55 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):
 PHPStan\Command\WorkerCommand->execute() 
 #56 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870):
 _PHPStan_eb00fd21c\Symfony\Component\Console\Command\Command->run()
 #57 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):
 _PHPStan_eb00fd21c\Symfony\Component\Console\Application->doRunCommand() 
 #58 phar:///project/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):
 _PHPStan_eb00fd21c\Symfony\Component\Console\Application->doRun()
 #59 phar:///project/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): 
 _PHPStan_eb00fd21c\Symfony\Component\Console\Application->run()
 #60 phar:///project/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_eb00fd21c\{closure}()
 #61 /project/vendor/phpstan/phpstan/phpstan(8): require('...')
 #62 /project/vendor/bin/phpstan(120): include('...')
 #63 {main} 

Adding the following to my config/app.php resolves the issue:

$config = [
    'aliases' => [
        'config' => Illuminate\Config\Repository::class,

The alias would normally be registered by Illuminate\Foundation\Application::registerCoreContainerAliases(), I'm wondering if Larastan or something else is somehow sidestepping this.

I tried that suggestion @AJenbo and it did in fact remove the posted error. However I do end up with a different error as a result:

Uncaught Error: Call to a member function driver() on null in /app/vendor/nunomaduro/larastan/src/Methods/Pipes/Managers.php:38
#0 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\Managers->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#1 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/Facades.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#2 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\Facades->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#3 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/Contracts.php(36): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#4 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\Contracts->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#5 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/SelfClass.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#6 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\SelfClass->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#7 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#8 /app/vendor/nunomaduro/larastan/src/Methods/Passable.php(187): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#9 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/Facades.php(34): NunoMaduro\Larastan\Methods\Passable->sendToPipeline('Illuminate\\Sess...', true)
#10 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\Facades->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#11 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/Contracts.php(36): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#12 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\Contracts->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#13 /app/vendor/nunomaduro/larastan/src/Methods/Pipes/SelfClass.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#14 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): NunoMaduro\Larastan\Methods\Pipes\SelfClass->handle(Object(NunoMaduro\Larastan\Methods\Passable), Object(Closure))
#15 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(NunoMaduro\Larastan\Methods\Passable))
#16 /app/vendor/nunomaduro/larastan/src/Methods/Kernel.php(66): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /app/vendor/nunomaduro/larastan/src/Methods/Extension.php(42): NunoMaduro\Larastan\Methods\Kernel->handle(Object(PHPStan\Reflection\ClassReflection), 'put')
#18 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(429): NunoMaduro\Larastan\Methods\Extension->hasMethod(Object(PHPStan\Reflection\ClassReflection), 'put')
#19 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(553): PHPStan\Reflection\ClassReflection->hasMethod('put')
#20 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Rules/Methods/CallToStaticMethodStatementWithoutSideEffectsRule.php(69): PHPStan\Type\ObjectType->hasMethod('put')
#21 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(106): PHPStan\Rules\Methods\CallToStaticMethodStatementWithoutSideEffectsRule->processNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope))
#22 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(98): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope))
#23 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(508): PHPStan\Node\ClassStatementsGatherer->__invoke(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope))
#24 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(417): PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope))
#25 phar:///app/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))
#26 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(648): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\If_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#27 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(362): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\If_), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#28 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1054): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\TryCatch), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#29 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(362): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TryCatch), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#30 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(523): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#31 phar:///app/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))
#32 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(601): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))
#33 phar:///app/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))
#34 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(573): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#35 phar:///app/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))
#36 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(175): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#37 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(72): PHPStan\Analyser\FileAnalyser->analyseFile('/app/app/Http/A...', Array, Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)
#38 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(62): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array)
#39 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(209): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), NULL, true, true, '/app/phpstan.ne...', Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput))
#40 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(102): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/app/phpstan.ne...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput))
#41 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(190): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/app/phpstan.ne...', Array, Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput))
#42 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Output\ConsoleOutput))
#43 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_cbfb23d84\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Output\ConsoleOutput))
#44 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_cbfb23d84\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Output\ConsoleOutput))
#45 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_cbfb23d84\Symfony\Component\Console\Application->doRun(Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_cbfb23d84\Symfony\Component\Console\Output\ConsoleOutput))
#46 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_cbfb23d84\Symfony\Component\Console\Application->run()
#47 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_cbfb23d84\{closure}()
#48 /app/vendor/phpstan/phpstan/phpstan(8): require('phar:///app/ven...')
#49 /app/vendor/bin/phpstan(120): include('/app/vendor/php...')
#50 {main}

I'm guessing it has something to do with notification channels based on the file referenced in the analysis error output, but unfortunately I don't have time to dig in further at the moment.

I had a similar issue with code using session()->with(), the solution there for me was switching to $request->session()->now().

Resolved by #76

@Firehed could you check if the latest dev-main solves all the conflicts you where having with the two extension?

I closed the issue since I was able to verify that things are now working correctly on the two project I have access to where this was an issue.

@AJenbo I no longer get the previous crashes, though we've significantly decoupled our app from Laravel since my previous comment so I have no good way of knowing if it's due to your change or other something else.

I am seeing that it's failing to detect an undefined variable in a mail template (which prompted me to try the extension in the first place) but that's almost certainly unrelated to this specific change.

I am seeing that it's failing to detect an undefined variable in a mail template

As I remember it currently not all methods of invoking email templates are analyzed. Could you post a short snipit of how you set the template, then I can change it in to a test for the case and maybe add support for it.

Sure. This is inside notification classes:

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class Whatever extends Notification
{
  // ...
  public function toMail($notifiable): MailMessage
  {
    return (new MailMessage())->view('my-view-name', [
      'var1' => 'value1',
      // ...
    ])->subject('not relevant');
  }
}

The view template in question tried to use a key that wasn't provided via the data array (oops!) which turned into a runtime error.

Thanks for looking into it!

As a start I created a new issue for this: #77