Bug Report
| Subject |
Details |
| Rector version |
last dev-main |
| Installed as |
composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/8e48a73d-15a7-4c5b-b80d-84e652712f0b
<?php
final class DemoFile
{
/**
* @var array{
* cache: array{directory: null}
* }
*/
protected array $config = [
'cache' => [
'directory' => null,
],
];
public function getCacheDirectory(): ?string
{
$dir = $this->config['cache']['directory'] ?? null;
\assert(\is_string($dir) || $dir === null, 'Invalid cache directory.');
return $dir;
}
}
Responsible rules
NarrowWideUnionReturnTypeRector
Expected Behavior
On assert(), it can still execute, just show warning, so changing return type is invalid here, see https://3v4l.org/02vqB#v8.5.8
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/8e48a73d-15a7-4c5b-b80d-84e652712f0b
Responsible rules
NarrowWideUnionReturnTypeRectorExpected Behavior
On
assert(), it can still execute, just show warning, so changing return type is invalid here, see https://3v4l.org/02vqB#v8.5.8