I was doing some research but wasn't able to find an answer (probably beacause I did not searched it right)
Consider this piece of code:
public function foo(?array $optionalParam);
And then this one:
public function foo(array $optionalParam = null);
What differs between them? Using PHPstorm I noticed that when I use the ?
, it creates a PHPdoc and mark the variable type as type|null
. But when I call the function without that argument, PHP screams on my face "you kidding me? where is $optionalParam". In the other side, I managed to use with no problems the =null
option.
Sorry if this question is too simple, but i did not find any answers online.