Skip to content
Permalink
Browse files

Add extra safety feature

  • Loading branch information
muglug committed Dec 3, 2019
1 parent 585ef06 commit aa4daea18236316c4021acbddec04576ffef7ce1
Showing with 39 additions and 0 deletions.
  1. +11 −0 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +28 −0 tests/FileManipulation/ParamTypeManipulationTest.php
@@ -1952,6 +1952,17 @@ private function findPossibleMethodParamTypes(ClassLikeStorage $classlike_storag
$method_storage->location->file_path
);

$has_variable_calls = $codebase->analyzer->hasMixedMemberName(
strtolower($method_name)
)
|| $codebase->analyzer->hasMixedMemberName(
strtolower($classlike_storage->name . '::')
);

if ($has_variable_calls) {
$possible_type->from_docblock = true;
}

if ($function_analyzer) {
$function_analyzer->addOrUpdateParamType(
$project_analyzer,
@@ -78,6 +78,34 @@ public function fooFoo(string $a): void {}
['MissingParamType'],
true,
],
'noStringParamTypeWithVariableCall' => [
'<?php
class C {
public function fooFoo($a): void {}
}
/** @var mixed */
$c = null;
$c->fooFoo("hello");
(new C)->fooFoo("hello");',
'<?php
class C {
/**
* @param string $a
*/
public function fooFoo($a): void {}
}
/** @var mixed */
$c = null;
$c->fooFoo("hello");
(new C)->fooFoo("hello");',
'7.1',
['MissingParamType'],
true,
],
'noStringParamTypeWithDocblockCall' => [
'<?php
class C {

0 comments on commit aa4daea

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