1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #1528 - double check for missing dependency

This commit is contained in:
Matthew Brown 2019-04-21 11:30:42 -04:00
parent e08ef35b79
commit d68e501bfa
3 changed files with 49 additions and 3 deletions

View File

@ -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 '

View File

@ -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
);
}

View File

@ -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