PHPStorm version: 2017.2 EAP (172.3198.4)
PHPInspections version: 2.3.8-preview.1
Code:
```php
declare(strict_types = 1);
class Test
{
/**
* @var int
*/
protected $val;
/**
* @var ?int
*/
protected $maybeNull = null;
public function testMaybe() : int
{
return ($this->maybeNull ?? $this->val);
}
}
````
Actual result:
$this->maybeNull is hilighted with the message "Return value must be of type 'int', 'null' returned"
Expected result:
No error hilight - null will never be returned from this function because of the null coalesce operator.
Thank you for reporting @AllenJB.
I did check and it seems that the message emitted by PhpStorm itself, hence closing the issue.
Reported to Jetbrains: https://youtrack.jetbrains.com/issue/WI-37013
Ta. I did check, but obviously my eyes deceived me and told me it was under the PHP Inspections EA branch in the inspections list. I've just rechecked and it definitely isn't. My bad.
No problem! I do that too a lot of times. haha
Most helpful comment
Reported to Jetbrains: https://youtrack.jetbrains.com/issue/WI-37013