[PR][php-src][#1108][master] - RFC: Strict Arg Count On Function Calls
| From: | noreply@php.net | Date: | Sun, 01 Mar 2015 22:53:40 +0000 |
| Subject: | [PR][php-src][#1108][master] - RFC: Strict Arg Count On Function Calls | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-2525@lists.php.net to get a copy of this message | ||
You can view the Pull Request on github:
https://github.com/php/php-src/pull/1108
Pull Request Description:
RFC: [Strict Arg Count On Function Calls](https://wiki.php.net/rfc/strict_argcount)
Ex:
```php
function fn($arg) {
// 1 arg expected
}
fn(1, 2, 3);
# Warning: fn() expects at most 1 parameter, 3 given, defined in %s on line 2 and called...
```
The implementation is sensitive to
func_get_arg() and func_get_args()
usage. It means that if a function|method is implemented using the
variable-length arg list API, the warning is not emitted:
```php
function fn($arg) {
$arg = func_get_arg();
$args = func_get_args();
}
fn(1, 2, 3); # no warning
```
PS: Some unrelated tests had bugs revealed and had to be fixed.
PS2: func_num_args() is not checked because it's not directly associated to
variadic func behavior.