1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix union type simplification of float|int eradicating int

This commit is contained in:
Matthew Brown 2017-02-01 19:39:40 -05:00
parent 1051ba9fc1
commit 5ec2a9742b
2 changed files with 4 additions and 47 deletions

View File

@ -881,6 +881,9 @@ class TypeChecker
return true;
}
// from https://wiki.php.net/rfc/scalar_type_hints_v5:
//
// > int types can resolve a parameter type of float
if ($input_type_part instanceof TInt && $container_type_part instanceof TFloat) {
return true;
}
@ -1406,6 +1409,7 @@ class TypeChecker
foreach ($union->types as $container_type_part) {
if ($type_part !== $container_type_part &&
!($type_part instanceof TInt && $container_type_part instanceof TFloat) &&
TypeChecker::isAtomicContainedBy(
$type_part,
$container_type_part,

View File

@ -619,51 +619,4 @@ class ClassTest extends PHPUnit_Framework_TestCase
$context = new Context();
$file_checker->visitAndAnalyzeMethods($context);
}
/**
* @return void
*/
public function testClassTraversalViaRequire()
{
$this->markTestSkipped();
$this->project_checker->registerFile(
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
'<?php
class A {
/** @return string */
public function __get() { }
}
'
);
$this->project_checker->registerFile(
getcwd() . DIRECTORY_SEPARATOR . 'file2.php',
'<?php
require("file1.php");
class B extends A {
/** @return void */
public function foo() {
echo (string)(new C)->bar;
}
}
'
);
$file3_checker = new FileChecker(
getcwd() . DIRECTORY_SEPARATOR . 'file3.php',
$this->project_checker,
self::$parser->parse('<?php
require("file2.php");
class C extends B {
const DOPE = "dope";
}
')
);
$context = new Context();
$file3_checker->visitAndAnalyzeMethods($context);
}
}