Oh, and doing this would literally break class autoloading in symfony, and even the engine itself, which relies on this feature.
Oh, and doing this would literally break class autoloading in symfony, and even the engine itself, which relies on this feature.
Not for builtin PHP functions which already throw errors on arity mismatch.
> this would literally break class autoloading in symfony, and even the engine itself, which relies on this feature
I don't understand. Could you point to where in the Symfony code it relies on being able to wrongly call a function with more arguments than it expects and will use?
For variadic functions there is the ... operator already in the language since version 5.6, and my proposal wouldn't break that. Also note that builtin functions already emit deprecated warning in PHP 8 when called with too many arguments.
Here is the full thread discussing it on the PHP internal mailing list: https://news-web.php.net/php.internals/122928
It still only happens during run time. Having a never-called function with an incorrect number of arguments is not an error.
Also, due to the nature and usage of PHP, some things cannot be statically analyzed because they're inherently dynamic. A simple example would be MVC frameworks where the routing is done like so: /controller/action/param1/param2/param3 where "controller" references a class and "action" references a method, which will take the "paramN" as arguments through the splicing of an array: `$ctrl->$actn(...$args);`. In such situations it would be nice to have errors/exceptions raised automatically if the URL is wrong (not enough OR too much arguments) without having to manually assess everything inside each method. Since PHP 7 and 8 over we're moving away from long lines of isset() and !empty() (and verifications such as is_numeric() etc. thanks to argument typing).
Regardless of the ‘improve the language angle’: Is somebody isn’t running PHPStan (or Psalm, Sonar, etc), then they’re missing out.
PHPStan is currently so good that using it should be non-negiotable. So the question would then even be: “I’d like rule 123 of the tool to be native, we helps with the RFC?”
$a = &$arr[]
Gives you a reference to null and appends it to the array. Then you can pass $a to something to mutate the tail “from a distance”. Most people never need this, nor should they use it. But when you are writing a streaming parser, it is quite handy as a one-liner instead of writing $a = null
$arr[] = &$a
or keeping track of the current index and dealing with off-by-one errors.For applications, these static analysis tools are great. For libraries, not so much.