1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/Zend/tests/exit/exit_as_function.phpt
Juliette 4c5767f62f PHP 8.4 | Exit as function: fix incorrect parameter name (#15433)
Follow up on 13483

As previously reported in https://github.com/php/php-src/pull/13483#discussion_r1718546927:

> The parameter names seem to be incorrect.
>
> It should be `$status`, not `$code`.
>
> The RFC explicitly uses that parameter name in the proposal: https://wiki.php.net/rfc/exit-as-function#proposal
>
> It is also the name already used in the [manual](https://www.php.net/exit).
>
> Lastly, the parameter name `$status` better covers what can be passed: either a status _message_ or a status _code_.
> While `$code` would read pretty weird when passing a message:
> ```php
> exit(code: 'message');
> ```

This commit attempts to fix this.

Includes adding a test for exit/die using a named argument.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
2024-08-16 22:35:16 +01:00

43 lines
546 B
PHP

--TEST--
exit() as function
--FILE--
<?php
function foo(callable $fn) {
var_dump($fn);
}
$values = [
'exit',
'die',
exit(...),
die(...),
];
foreach ($values as $value) {
foo($value);
}
?>
--EXPECT--
string(4) "exit"
string(3) "die"
object(Closure)#1 (2) {
["function"]=>
string(4) "exit"
["parameter"]=>
array(1) {
["$status"]=>
string(10) "<optional>"
}
}
object(Closure)#2 (2) {
["function"]=>
string(4) "exit"
["parameter"]=>
array(1) {
["$status"]=>
string(10) "<optional>"
}
}