Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax #2

Open
yejune opened this issue Jan 9, 2019 · 3 comments
Open

Syntax #2

yejune opened this issue Jan 9, 2019 · 3 comments

Comments

@yejune
Copy link

yejune commented Jan 9, 2019

php

function foo(?array $t) {
}

converted zephir

function foo(?array t) {
}

right syntax

function foo(array! t) {
}
@sandrokeil
Copy link
Owner

Looking at the docs this would disable type check right? But we want only allow an array or null.

@danhunsaker
Copy link

danhunsaker commented Jan 9, 2019

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.

@sandrokeil
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants