Skip to content
Permalink
Browse files

Fix replacement for inherited methods

  • Loading branch information...
muglug committed May 31, 2019
1 parent 4002504 commit 534e4c034b4f72cec5692057f39d629212406ef3
@@ -2220,15 +2220,19 @@ public static function checkFunctionArgumentType(
&& strpos($cased_method_id, '::')
&& !strpos($cased_method_id, '__')
) {
$method_storage = $codebase->methods->getStorage($cased_method_id);
$declaring_method_id = $codebase->methods->getDeclaringMethodId($cased_method_id);
if (!isset($method_storage->possible_param_types[$argument_offset])) {
$method_storage->possible_param_types[$argument_offset] = clone $input_type;
} else {
$method_storage->possible_param_types[$argument_offset] = Type::combineUnionTypes(
$method_storage->possible_param_types[$argument_offset],
clone $input_type
);
if ($declaring_method_id) {
$method_storage = $codebase->methods->getStorage($declaring_method_id);
if (!isset($method_storage->possible_param_types[$argument_offset])) {
$method_storage->possible_param_types[$argument_offset] = clone $input_type;
} else {
$method_storage->possible_param_types[$argument_offset] = Type::combineUnionTypes(
$method_storage->possible_param_types[$argument_offset],
clone $input_type
);
}
}
}
@@ -85,6 +85,30 @@ public function fooFoo($a): void {}
['MissingParamType'],
true,
],
'noStringParamTypeParent' => [
'<?php
class C {
public function fooFoo($a): void {}
}
class D extends C {}
(new D)->fooFoo("hello");',
'<?php
class C {
/**
* @param string $a
*/
public function fooFoo($a): void {}
}
class D extends C {}
(new D)->fooFoo("hello");',
'7.1',
['MissingParamType'],
true,
],
'stringParamTypeNoOp' => [
'<?php
class C {

0 comments on commit 534e4c0

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