I use native types, but it seems the problem does exist for phpDoc too. Extension version is v1.48.15635
When using null as argument, the error PHP0406 is showing. When using the nullable of the new object, no error is showing.
null
Nico Thank you for the question.
Here, both lines should be reported as a warning. We are just not so strict in the second case (it is too often in most PHP projects).
Would you suggest reporting the second case as a warning as well? We may enable it in strict_types=1 mode.
strict_types=1
Hi. yes, I would exect a warning on second func call too.
Would this mean declare(strict_types=1); is required to add everywhere? Is there something like a global setting like tsconfig.json / eslint.config.js in TypeScript?
declare(strict_types=1);
Nico there is no global setting; PHP is "increasingly" being more strict with every new version, so we try to reflect the actual PHP behavior.
However; it's a good point. We should have our own "strictness" global setting for that.