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

Missing import in CachedBuilder? #462

Open
czuniga9 opened this issue Mar 14, 2024 · 0 comments
Open

Missing import in CachedBuilder? #462

czuniga9 opened this issue Mar 14, 2024 · 0 comments

Comments

@czuniga9
Copy link

Describe the bug

When I run the psalm analyzer on my project it trips on the CachedBuilder class because it can't find the EloquentBuilder class it extends. I don't know how it finds the class when the code actually runs because it works fine, but if I check get_parent_class on the object it says it's a subclass of Illuminate\Database\Eloquent\Builder. Adding the import line below fixes the issue in psalm and doesn't seem to break anything in my project and didn't seem to affect the laravel-model-caching tests (I had 2 failing tests with and without the import related to a missing authors table):

use Illuminate\Database\Eloquent\Builder as EloquentBuilder;

Stack Trace
The full stack trace from your log file.

./vendor/bin/psalm --taint-analysis

Target PHP version: 8.2 (inferred from composer.json) Enabled extensions: dom, pdo, simplexml.
Scanning files...
Analyzing files...

   Exception

  InvalidArgumentException Could not get class storage for genealabs\laravelmodelcaching\eloquentbuilder
Emitted in /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:45
Stack trace in the forked worker:
#0 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/AssertionsFromInheritanceResolver.php(46): Psalm\Internal\Provider\ClassLikeStorageProvider->get('GeneaLabs\\Larav...')
#1 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php(421): Psalm\Internal\Codebase\AssertionsFromInheritanceResolver->resolve(Object(Psalm\Storage\MethodStorage), Object(Psalm\Storage\ClassLikeStorage))
#2 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php(483): Psalm\Internal\Analyzer\Statements\Expression\Call\Method\ExistingAtomicMethodCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(PhpParser\Node\Identifier), Array, Object(Psalm\Codebase), Object(Psalm\Context), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), '$query', Object(Psalm\Internal\MethodIdentifier), Object(Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalysisResult), NULL)
#3 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php(195): Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Codebase), Object(Psalm\Context), Object(Psalm\Type\Union), Object(Psalm\Type\Atomic\TNamedObject), Object(Psalm\Type\Atomic\TNamedObject), false, '$query', Object(Psalm\Internal\Analyzer\Statements\Expression\Call\Method\AtomicMethodCallAnalysisResult), NULL)
#4 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(211): Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context), true, NULL)
#5 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(90): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context), false, NULL, true, NULL, false)
#6 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(563): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Expr\MethodCall), Object(Psalm\Context), false, NULL, true)
#7 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(197): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\Expression), Object(Psalm\Context), NULL)
#8 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php(158): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze(Array, Object(Psalm\Context))
#9 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php(260): Psalm\Internal\Analyzer\Statements\Block\IfElse\IfAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Internal\Scope\IfScope), Object(Psalm\Internal\Scope\IfConditionalScope), Object(Psalm\Context), Object(Psalm\Context), Array)
#10 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(517): Psalm\Internal\Analyzer\Statements\Block\IfElseAnalyzer::analyze(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Context))
#11 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(197): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement(Object(Psalm\Internal\Analyzer\StatementsAnalyzer), Object(PhpParser\Node\Stmt\If_), Object(Psalm\Context), Object(Psalm\Context))
#12 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(511): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze(Array, Object(Psalm\Context), Object(Psalm\Context), true)
#13 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1841): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Internal\Provider\NodeDataProvider), Object(Psalm\Context))
#14 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1515): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod(Object(PhpParser\Node\Stmt\ClassMethod), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Internal\Analyzer\TraitAnalyzer), Object(Psalm\Context), Object(Psalm\Context))
#15 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(459): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeTraitUse(Object(Psalm\Aliases), Object(PhpParser\Node\Stmt\TraitUse), Object(Psalm\Internal\Analyzer\ProjectAnalyzer), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Context), Object(Psalm\Context), NULL)
#16 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(201): Psalm\Internal\Analyzer\ClassAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Context))
#17 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(1591): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#18 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(191): Psalm\Internal\Codebase\Analyzer->analysisWorker(46, '/Users/user...')
#19 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(372): Psalm\Internal\Fork\Pool->__construct(Object(Psalm\Config), Array, Object(Closure), Object(Closure), Object(Closure), Object(Closure))
#20 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(272): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 9)
#21 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(552): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 9, false, true)
#22 /Users/user/project/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(374): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/Users/user...', false)
#23 /Users/user/project/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run(Array)
#24 /Users/user/project/vendor/bin/psalm(119): include('/Users/user...')
#25 {main}

  at vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php:379
    375▕                                  * @psalm-suppress MixedArgument
    376▕                                  */
    377▕                                 posix_kill($child_pid, SIGTERM);
    378▕                             }
  ➜ 379▕                             throw new Exception($message->message);
    380▕                         } else {
    381▕                             error_log('Child should return ForkMessage - response type=' . gettype($message));
    382▕                             $this->did_have_error = true;
    383▕                         }

Environment

  • PHP: 8.2.15
  • OS: macOS Sonoma 14.3.1
  • Laravel: v10.48.2
  • Model Caching: 0.13.9

Additional context
I wasn't able to get psalm working by ignoring the vendor directory in the configuration.

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

No branches or pull requests

1 participant