Skip to content
Permalink
Browse files

Fix #2505 - don’t attempt to analyse classes that weren‘t properly sc…

…anned
  • Loading branch information
muglug committed Dec 31, 2019
1 parent 02fd165 commit 87fec3e6fe0641e5b337110e0d4b37e82893f429
Showing with 24 additions and 0 deletions.
  1. +5 −0 src/Psalm/Internal/Analyzer/FileAnalyzer.php
  2. +19 −0 tests/ClassStringTest.php
@@ -276,6 +276,11 @@ private function populateClassLikeAnalyzers(PhpParser\Node\Stmt\ClassLike $stmt)
return;
}

// this can happen when stubbing
if (!$this->codebase->classOrInterfaceExists($stmt->name->name)) {
return;
}

if ($stmt instanceof PhpParser\Node\Stmt\Class_) {
$class_analyzer = new ClassAnalyzer($stmt, $this, $stmt->name->name);

@@ -660,6 +660,24 @@ function example(string $className, Example $object): string {
/** @param class-string<Example> $className */
function takesExampleClassString(string $className): void {}'
],
'noCrashOnPolyfill' => [
'<?php
if (class_exists(My_Parent::class) && !class_exists(My_Extend::class)) {
/**
* Extended class
*/
class My_Extend extends My_Parent {
/**
* Construct
*
* @return void
*/
public function __construct() {
echo "foo";
}
}
}',
],
];
}

@@ -798,6 +816,7 @@ function foo(string $s) : string {
}',
'error_message' => 'InvalidReturnStatement',
],

];
}
}

0 comments on commit 87fec3e

Please sign in to comment.
You can’t perform that action at this time.