> 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. >
I agree that using an attribute would be better for this case. > I would personally prefer the void syntax, but that's really because > attributes look odd to me due to lack of habits (and also because it avoids > an additional line of code… which is probably not a solid enough reason when > it comes to language design decisions). As a reader of the code, having the attribute is much more clear to me than having something that looks like an argument. Also, with attributes, the code is backwards-compatible, i.e., I can add the attribute to my code without any errors or warnings even if I don't use the latest version of PHP, and even in those cases, IDEs could still help me.