php-to-zephir
php-to-zephir copied to clipboard
Syntax
php
function foo(?array $t) {
}
converted zephir
function foo(?array t) {
}
right syntax
function foo(array! t) {
}
Looking at the docs this would disable type check right? But we want only allow an array or null.
array! forces the value to be an array; if anything else is passed, rather than coerce the value, an exception is thrown. array by itself doesn't force non-coercion, though as array isn't a scalar type, automatic coercion isn't generally supported anyway.
Ultimately, though, ?array means array|null in PHP, which Zephir supports via array t = null, rather than using a modifier.
I guess we have to wait for Allow nullable parameter because ?array $t !== $t = null. You must provide an array or null and you can not leave it empty like with array $t = null.
So the workaround could be array t = null for zephir?