mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #1528 - double check for missing dependency
This commit is contained in:
parent
e08ef35b79
commit
d68e501bfa
@ -283,6 +283,12 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer implements StatementsSou
|
||||
}
|
||||
|
||||
foreach ($class_storage->invalid_dependencies as $dependency_class_name) {
|
||||
// if the implemented/extended class is stubbed, it may not yet have
|
||||
// been hydrated
|
||||
if ($codebase->classlike_storage_provider->has($dependency_class_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IssueBuffer::accepts(
|
||||
new MissingDependency(
|
||||
$fq_class_name . ' depends on class or interface '
|
||||
|
@ -305,8 +305,8 @@ if ($threads > 1) {
|
||||
|
||||
$type_map_location = null;
|
||||
|
||||
if (isset($options['generate-type-map']) && is_string($options['generate-type-map'])) {
|
||||
$type_map_location = $options['generate-type-map'];
|
||||
if (isset($options['generate-json-map']) && is_string($options['generate-json-map'])) {
|
||||
$type_map_location = $options['generate-json-map'];
|
||||
}
|
||||
|
||||
// If XDebug is enabled, restart without it
|
||||
@ -745,9 +745,13 @@ if ($type_map_location) {
|
||||
}
|
||||
}
|
||||
|
||||
$type_map_string = json_encode(['files' => $name_file_map, 'references' => $reference_dictionary]);
|
||||
|
||||
var_dump(strlen($type_map_string));
|
||||
|
||||
$providers->file_provider->setContents(
|
||||
$type_map_location,
|
||||
json_encode(['files' => $name_file_map, 'references' => $reference_dictionary])
|
||||
$type_map_string
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -750,6 +750,42 @@ class StubTest extends TestCase
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testStubFileWithExtendedStubbedClass()
|
||||
{
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
'<?xml version="1.0"?>
|
||||
<psalm>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
</projectFiles>
|
||||
|
||||
<stubs>
|
||||
<file name="tests/stubs/partial_class.php" />
|
||||
</stubs>
|
||||
</psalm>'
|
||||
)
|
||||
);
|
||||
|
||||
$file_path = getcwd() . '/src/somefile.php';
|
||||
|
||||
$this->addFile(
|
||||
$file_path,
|
||||
'<?php
|
||||
namespace Foo;
|
||||
|
||||
class Bar extends PartiallyStubbedClass {}
|
||||
|
||||
new Bar();'
|
||||
);
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psalm\Exception\CodeException
|
||||
* @expectedExceptionMessage TypeCoercion
|
||||
|
Loading…
x
Reference in New Issue
Block a user