-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#4159Labels
Description
Bug report
PHP 8.0 - 8.4
<?php declare(strict_types = 1);
/**
* @return string[]|null
*/
function getData(): ?array
{
if (time() > 113) {
return null;
}
return [''];
}
$list = getData();
echo implode(',', $list);Fatal error: Uncaught TypeError: implode(): Argument #1 ($array) must be of type array, string given in /opt/scratches/scratch_182.php:17
Stack trace:
#0 /opt/scratches/scratch_182.php(17): implode(',', NULL)
#1 {main}
thrown in /opt/scratches/scratch_182.php on line 17
Code snippet that reproduces the problem
https://phpstan.org/r/7bb01c8a-5d6d-4d5a-a6af-b760d13e0b8d
Expected output
Expected behavior with php 7.4
Parameter #2 $pieces of function implode expects array, array<string>|null given.
Did PHPStan help you today? Did it make you happy in any way?
No response

