Comment

Comment by p4bl0

Something I'd really like is for PHP to somehow be stricter on the number of arguments passed to a function.

As of now, PHP emits an error if arguments are missing but not if there are too many.

A way to bake that in without breaking old code would be to allow function definition to put an explicit stop to the argument list, for example using the void type keyword:

    function foo (int $a, string $b, void) : bool
    { ... }

A few month ago I discussed this on the development mailing list and people seemed to agree and even suggested that this would be a good idea by default without the keyword thing I suggested. But I never got the time to properly write an RFC. There is already an old one from years ago that was voted against but In was told it was from before anything strict and typing related was considered important in PHP. If anyone's up to it, please write this RFC :) !
parent p4bl0 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton