mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #55 - hiccup when negating strange expression
This commit is contained in:
parent
78c1138a94
commit
dc592f7a6e
@ -304,22 +304,19 @@ class TypeChecker
|
||||
}
|
||||
} elseif (count($clause->possibilities) === 1) {
|
||||
// if there's only one active clause, return all the non-negation clause members ORed together
|
||||
$things_that_can_be_said = implode(
|
||||
'|',
|
||||
array_filter(
|
||||
$possible_types,
|
||||
/**
|
||||
* @param string $possible_type
|
||||
* @return bool
|
||||
*/
|
||||
function ($possible_type) {
|
||||
return $possible_type[0] !== '!';
|
||||
}
|
||||
)
|
||||
$things_that_can_be_said = array_filter(
|
||||
$possible_types,
|
||||
/**
|
||||
* @param string $possible_type
|
||||
* @return bool
|
||||
*/
|
||||
function ($possible_type) {
|
||||
return $possible_type[0] !== '!';
|
||||
}
|
||||
);
|
||||
|
||||
if ($things_that_can_be_said) {
|
||||
$truths[$var] = $things_that_can_be_said;
|
||||
if ($things_that_can_be_said && count($things_that_can_be_said) === count($possible_types)) {
|
||||
$truths[$var] = implode('|', $things_that_can_be_said);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -821,4 +821,28 @@ class ScopeTest extends PHPUnit_Framework_TestCase
|
||||
$context = new Context('somefile.php');
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testIntstanceOfSubtraction()
|
||||
{
|
||||
$stmts = self::$parser->parse('<?php
|
||||
class Foo {}
|
||||
class FooBar extends Foo{}
|
||||
class FooBarBat extends FooBar{}
|
||||
class FooMoo extends Foo{}
|
||||
|
||||
$a = new Foo();
|
||||
|
||||
if ($a instanceof FooBar && !$a instanceof FooBarBat) {
|
||||
|
||||
} elseif ($a instanceof FooMoo) {
|
||||
|
||||
}
|
||||
');
|
||||
|
||||
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
|
||||
$file_checker->visitAndAnalyzeMethods();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user