> Le 4 avr. 2024 à 15:03, Mark Trapp <m...@itafroma.com> a écrit :
>
> On Thu, Apr 4, 2024 at 5:43 AM Pablo Rauzy <r...@uzy.me> wrote:
>
> I 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.
>
Indeed, except that I think it should be better to have *by default* the same
behaviour between built-in functions and user-defined functions:
```php
function foo() { }
foo(42);
// in PHP 8.x: Deprecated: foo() expects expects exactly 0 arguments, 1 given
// in PHP 9: Fatal error: foo() expects expects exactly 0 arguments, 1 given
```
and, in case you want a variadic function:
```php
#[Variadic]
function foo() { }
```
Alternatively, we don’t really need to introduce a new attribute, because one
can just write:
```php
function foo(...$args) { }
```
—Claude