diff --git a/tests/Php70Test.php b/tests/Php70Test.php index 790238996..8d1344c33 100644 --- a/tests/Php70Test.php +++ b/tests/Php70Test.php @@ -17,14 +17,14 @@ class Php70Test extends TestCase function indexof(string $haystack, string $needle) : int { $pos = strpos($haystack, $needle); - + if ($pos === false) { return -1; } - + return $pos; } - + $a = indexof("arr", "a");', 'assertions' => [ ['int' => '$a'], @@ -36,15 +36,15 @@ class Php70Test extends TestCase public static function indexof(string $haystack, string $needle) : int { $pos = strpos($haystack, $needle); - + if ($pos === false) { return -1; } - + return $pos; } } - + $a = Foo::indexof("arr", "a");', 'assertions' => [ ['int' => '$a'], @@ -52,11 +52,11 @@ class Php70Test extends TestCase ], 'nullCoalesce' => [ ' [ - ['mixed' => '$a'], + ['string|null' => '$a'], ], - 'error_levels' => ['MixedAssignment'], ], 'spaceship' => [ ' [ ['string' => '$a'], @@ -84,17 +84,17 @@ class Php70Test extends TestCase /** @return void */ public function log(string $msg); } - + class Application { /** @var Logger|null */ private $logger; - + /** @return void */ public function setLogger(Logger $logger) { $this->logger = $logger; } } - + $app = new Application; $app->setLogger(new class implements Logger { public function log(string $msg) { @@ -109,11 +109,11 @@ class Php70Test extends TestCase return 42; } }; - + function g(int $i) : int { return $i; } - + $x = g($class->f());', ], 'generatorWithReturn' => [ @@ -126,7 +126,7 @@ class Php70Test extends TestCase if ($i === 1) { return "bash"; } - + yield 1; }', ], @@ -144,7 +144,7 @@ class Php70Test extends TestCase yield from seven_eight(); return yield from nine_ten(); } - + /** * @return Generator */ @@ -152,14 +152,14 @@ class Php70Test extends TestCase yield 7; yield from eight(); } - + /** * @return Generator */ function eight() : Generator { yield 8; } - + /** * @return Generator * @psalm-generator-return int @@ -168,7 +168,7 @@ class Php70Test extends TestCase yield 9; return 10; } - + $gen = count_to_ten(); foreach ($gen as $num) { echo "$num "; @@ -184,20 +184,20 @@ class Php70Test extends TestCase 'foo = &$foo; $foo = "hello"; } } - + $bar = 5; $a = new A($bar); // $bar is constrained to an int $bar = null; // ReferenceConstraintViolation issue emitted', @@ -58,12 +58,12 @@ class ReferenceConstraintTest extends TestCase class A { /** @var int */ private $foo; - + public function __construct(int &$foo) { $this->foo = &$foo; } } - + $bar = 5; $a = new A($bar); $bar = null;', @@ -74,21 +74,21 @@ class ReferenceConstraintTest extends TestCase class A { /** @var int */ private $foo; - + public function __construct(int &$foo) { $this->foo = &$foo; } } - + class B { /** @var string */ private $bar; - + public function __construct(string &$bar) { $this->bar = &$bar; } } - + if (rand(0, 1)) { $v = 5; $c = (new A($v)); // $v is constrained to an int @@ -96,7 +96,7 @@ class ReferenceConstraintTest extends TestCase $v = "hello"; $c = (new B($v)); // $v is constrained to a string } - + $v = 8;', 'error_message' => 'ConflictingReferenceConstraint', ], diff --git a/tests/ToStringTest.php b/tests/ToStringTest.php index a562cb20e..fbb8b9a47 100644 --- a/tests/ToStringTest.php +++ b/tests/ToStringTest.php @@ -109,7 +109,7 @@ class ToStringTest extends TestCase takesString($i); }', 'error_message' => 'ImplicitToStringCast', - ] + ], ]; } }