My thoughts overall on this:

0. I'm not against introducing the attribute, only how it's used/enforced
etc. (And, incidentally, what it actually MEANS, see if you can spot that
from the rest of my comments....)

1. Static analysers and IDEs: I agree with everyone who's said that whether
or not the return value is "used" should be a concern for tooling like
static analysers and the IDE, and ideally not for PHP runtime.
Attributes were added as a structured replacement for docblock props and I
don't like it when they affect how a program actually runs (as long as
you're not using reflection).

2. If it must be a concern for PHP at runtime, a warning is preferred over
an exception. It only makes sense – it's in the name: Exceptions are for
exceptional situations, warnings are for warning you.

3. Naming of the attribute: I think the most precise name (if I understand
the purpose correctly) is: #[ReturnValueMayContainCriticalInformation]

4. Should all internal functions, such as fopen() (which may return false
on error instead of throwing an exception), have this attribute?
I understand that ideally we only want to add it where the failure to
inspect the return value could result in something outright dangerous, but
I think that's a really hard call to make.
If we scale it back to mean "Look, this function may not behave the way
you'd expect it to, - the return value may actually contain some
information you might be interested in, so you better check it man", then I
think it could be a small but useful addition.

Best,
Jakob

Reply via email to