-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1010Labels
Milestone
Description
Bug report
Hi,
Binary operations between string and int, gives errors as expected. Except dividing!
But the same operations between non-empty-string and int does not produce any error.
In runtime these all error.
Code snippet that reproduces the problem
https://phpstan.org/r/980008ff-df01-4485-aab0-1fd7b8a73f55
<?php declare(strict_types = 1);
/** @var non-empty-string $foo */
/** @var string $bar */
echo ($foo + 10); // Should error
echo ($foo - 10); // Should error
echo ($foo * 10); // Should error
echo ($foo / 10); // Should error
echo ($bar + 10); // Gives error correctly
echo ($bar - 10); // Gives error correctly
echo ($bar * 10); // Gives error correctly
echo ($bar / 10); // Should errorExpected output
Error is expected for the operations on $foo
Did PHPStan help you today? Did it make you happy in any way?
Yes!