Skip to content
Permalink
Browse files

Fix #2095 - respect @method annotations even when method already exists

  • Loading branch information...
muglug committed Sep 4, 2019
1 parent de5df1e commit 071fae98b2b89bb58cbf3a90b15b655f00d8629d
@@ -840,7 +840,10 @@ function (PhpParser\Node\Arg $arg) {
$method_id,
$context->calling_method_id,
$method_id !== $source_method_id ? new CodeLocation($source, $stmt->name) : null
)) {
)
|| ($config->use_phpdoc_method_without_magic_or_parent
&& isset($class_storage->pseudo_methods[$method_name_lc]))
) {
$class_storage = $codebase->classlike_storage_provider->get($fq_class_name);
if (($is_interface || $config->use_phpdoc_method_without_magic_or_parent)
@@ -131,6 +131,28 @@ class Child extends ParentClass {}
$this->assertSame('Child', (string) $context->vars_in_scope['$child']);
}
public function testOverrideExceptionMethodReturn() : void
{
Config::getInstance()->use_phpdoc_method_without_magic_or_parent = true;
$this->addFile(
'somefile.php',
'<?php
/**
* @method int getCode()
*/
class MyException extends Exception {}
function foo(MyException $e): int {
return $e->getCode();
}'
);
$context = new Context();
$this->analyzeFile('somefile.php', $context);
}
/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
*/

0 comments on commit 071fae9

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