I don't think "?" at the beginning is fully enough for the Nullable Type 
use case. 

You can easily express a "null or an array of elements that must be string" 
with "?string[]". But how can you express "an array of elements that must 
be string or null" ?

In code that would be:

/**
 * @param ?string[] $strings
 */
function nullOrArrayOfString(?array $strings) {
}

/**
 * @param WHAT SHOULD I WRITE HERE ? $stringsOrNulls
 */
function arrayOfStringOrNull(array $stringsOrNulls) {
}

nullOrArrayOfString(null);
nullOrArrayOfString(['foo', 'bar']);
nullOrArrayOfString(['foo', null]); // Invalid call !

arrayOfStringOrNull(null); // Invalid call !
arrayOfStringOrNull(['foo', 'bar']);
arrayOfStringOrNull(['foo', null]);


I think something like "(?string)[]" would be necessary to cover all null 
cases.

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/c0ba7fdf-5c45-493c-8f66-ff9bccbd7a14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to