mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #43 - do not emit issues when doing instanceof interface checks
This commit is contained in:
parent
dc585ff22a
commit
82af023d6f
@ -643,7 +643,8 @@ class TypeChecker
|
||||
return $new_type;
|
||||
}
|
||||
|
||||
if (!TypeChecker::isContainedBy($new_type, $existing_var_type, $file_checker) &&
|
||||
if (!InterfaceChecker::interfaceExists($new_var_type, $file_checker) &&
|
||||
!TypeChecker::isContainedBy($new_type, $existing_var_type, $file_checker) &&
|
||||
!TypeChecker::isContainedBy($existing_var_type, $new_type, $file_checker) &&
|
||||
$code_location) {
|
||||
if (IssueBuffer::accepts(
|
||||
|
@ -382,4 +382,21 @@ class InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
$context = new Context('somefile.php');
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
|
||||
public function testTypeDoesNotContainType()
|
||||
{
|
||||
$stmts = self::$parser->parse('<?php
|
||||
interface A { }
|
||||
interface B {
|
||||
function foo();
|
||||
}
|
||||
function bar(A $a) : void {
|
||||
if ($a instanceof B) {
|
||||
$a->foo();
|
||||
}
|
||||
}');
|
||||
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
|
||||
$context = new Context('somefile.php');
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user