Re: RFC idea: using the void type to control maximum arity of user-defined functions
| From: | Tim Düsterhus | Date: | Thu, 04 Apr 2024 15:49:03 +0000 |
| Subject: | Re: RFC idea: using the void type to control maximum arity of user-defined functions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122938@lists.php.net to get a copy of this message | ||
Hi
On 4/4/24 17:40, Vinicius Dias wrote:
I disagree with an attribute being the right choice here. In contrast to #[\Override], this proposal changes the behavior for the *caller* of the function and likely also requires adjustments in child classes when newly introduced in a parent class or interface. Thus it is part of the function's API and thus should be part of the regular signature and not the attribute-based metadata. Best regards Tim DüsterhusI like this concept, but instead of introducing a new syntax, have you considered leveraging attributes in the same way that PHP 8.3 introduced #[Override]? #[Nonvariadic] function foo () {} foo(42); // warning: foo() expects exactly 0 arguments, 1 given I think the intent would be clearer and it would avoid introducing a new syntax.I agree that using an attribute would be better for this case.