1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #3991 - fix test

This commit is contained in:
Matthew Brown 2020-08-15 14:21:24 -04:00
parent 8731b10bc6
commit a0bb5ed37d
2 changed files with 7 additions and 12 deletions

View File

@ -398,17 +398,16 @@ class MethodComparator
&& $implementer_param->location && $implementer_param->location
&& $guide_method_storage->cased_name && $guide_method_storage->cased_name
&& substr($guide_method_storage->cased_name, 0, 2) !== '__' && substr($guide_method_storage->cased_name, 0, 2) !== '__'
&& $config->isInProjectDirs(
$implementer_param->location->file_path
)
) { ) {
if ($config->allow_named_arg_calls if ($config->allow_named_arg_calls
|| ($guide_classlike_storage->location || ($guide_classlike_storage->location
&& !$config->isInProjectDirs($guide_classlike_storage->location->file_path) && !$config->isInProjectDirs($guide_classlike_storage->location->file_path)
) )
) { ) {
if ($codebase->alter_code if ($codebase->alter_code) {
&& $config->isInProjectDirs(
$implementer_param->location->file_path
)
) {
$project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance(); $project_analyzer = \Psalm\Internal\Analyzer\ProjectAnalyzer::getInstance();
if ($stmt && isset($project_analyzer->getIssuesToFix()['ParamNameMismatch'])) { if ($stmt && isset($project_analyzer->getIssuesToFix()['ParamNameMismatch'])) {
@ -435,11 +434,7 @@ class MethodComparator
. $implementer_param->name . ', expecting $' . $implementer_param->name . ', expecting $'
. $guide_param->name . ' as defined by ' . $guide_param->name . ' as defined by '
. $cased_guide_method_id, . $cased_guide_method_id,
$config->isInProjectDirs( $implementer_param->location
$implementer_param->location->file_path
)
? $implementer_param->location
: $code_location
) )
)) { )) {
// fall through // fall through

View File

@ -67,6 +67,8 @@ trait InvalidCodeAnalysisTestTrait
$this->project_analyzer->setPhpVersion($php_version); $this->project_analyzer->setPhpVersion($php_version);
$file_path = self::$src_dir_path . 'somefile.php';
$error_message = preg_replace('/ src[\/\\\\]somefile\.php/', ' src/somefile.php', $error_message); $error_message = preg_replace('/ src[\/\\\\]somefile\.php/', ' src/somefile.php', $error_message);
$this->expectException(\Psalm\Exception\CodeException::class); $this->expectException(\Psalm\Exception\CodeException::class);
@ -77,8 +79,6 @@ trait InvalidCodeAnalysisTestTrait
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
} }
$file_path = 'src/somefile.php';
$this->addFile($file_path, $code); $this->addFile($file_path, $code);
$this->analyzeFile($file_path, new Context()); $this->analyzeFile($file_path, new Context());
} }