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

array! is used in docs/closures.md but not explained elsewhere #50

Open
chx opened this issue Nov 28, 2024 · 0 comments
Open

array! is used in docs/closures.md but not explained elsewhere #50

chx opened this issue Nov 28, 2024 · 0 comments

Comments

@chx
Copy link

chx commented Nov 28, 2024

I saw public function map(array! data) in closures.md but as far as I can tell that exclamation mark is not explained elsewhere: https://github.com/search?q=repo%3Azephir-lang%2Fdocumentation%20!&type=code

I believe it's declared here: https://github.com/zephir-lang/php-zephir-parser/blob/ac23688ea0283b713295950d57b23f08c8637cc0/parser/zephir.lemon#L776 comparing it to a normal one and the C function signature:

xx_ret_parameter(zval *ret, int const_param, zval *type, zval *cast, xx_parser_token *N, zval *default_value, int mandatory, int reference, xx_scanner_state *state)
// type a
xx_parameter(R) ::= xx_parameter_type(T) IDENTIFIER(I) . {
	xx_ret_parameter(&R, 0, &T, NULL, I, NULL, 0, 0, status->scanner_state);
}
// type! a
xx_parameter(R) ::= xx_parameter_type(T) NOT IDENTIFIER(I) . {
	xx_ret_parameter(&R, 0, &T, NULL, I, NULL, 1, 0, status->scanner_state);
}

So does this all mean public function map(array data) has an optional argument and public function map(array! data) has a required argument?

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

1 participant