On 03/04/2019 18:13, M. W. Moe wrote: > The argument sits there. > > function handle(int $cmd, ...$arg) : int /* throw */ > function !handle(int $cmd, ...$arg) : int
The first example is unambiguous, easy to understand by anyone with a basic knowledge of the language, easy to spot when reading the code, easy to grep for, and will be recognised as a comment by any tool for parsing PHP.
The second example is hard to spot, completely opaque in meaning, and would break any tool which didn't have it added as a feature. I'm really struggling to see any advantages at all, other than saving a few key presses.
Of course, neither documents what type of exceptions will be thrown, so it's a bit like documenting every return type as either "void" or "mixed"; which is why the more common practice would look more like this:
/** @throws InvalidFooException */ function handle(int $cmd, ...$arg): int
you seems not having the experience of working on the same code base with basically literally dozen of people which can at some point intervene; this is reality, this not wrong or bad; you deal with it.
You're right, I haven't worked in a team that size, but if I did, I would expect strict coding standards that emphasise clear intent and documented behaviour to be absolutely essential for everyone to know what was going on.
either you enforce extra qualifiers in term of signature or you don't encourage it
I'm struggling to see the difference between enforcing "add an ! before the name if it throws" and "add a comment next to the name if it throws", or even "add X to the name if it throws", unless the language itself is going to perform some extra check.
Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php