Skip to content

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

@chx

Description

@chx

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions