Hi Benjamin,

https://wiki.php.net/rfc/deprecated_attribute


Thanks for the RFC.
Why didn't you mention support for deprecating classes/interfaces/traits
themselves?
If there is a reason, it should be in the RFC at least to me.

- all other languages with Attributes/Annotations support have it as well
>

Did you research what runtime side effects the other languages provide?

I'm concerned about runtime side-effects. Attributes should lead to none of
them to me. The moment an attribute leads to runtime side effects, it
should be turned into code instead, because it looses its "declarative"
property.

>From my experience, e.g. a method can be declared as deprecated but can
*still* be called internally without any issue. This should not be reported
to anyone as its internal. Preserving BC often requires this, and only
runtime logic can decide when a deprecation should be reported to the
end-user. Note that this is different from configuring the global error
reporting level: deciding *locally* that some declaration should not be
reported is the important part of this.

That's also why I very much favor @trigger_error() and why static analysis
works only for the simpler cases.

If one wants to save the duplicate "declaration" (attribute + explicit call
inline), then this should be opt-in to me, e.g. <<Deprecated(true)>>.

As an additional step, I very much which that the attribute could accept
two arguments: the package and the version of it. From my experience,
making deprecations actionable is critical to help ppl to fix them. And
making them actionable starts with allowing ppl to quickly identify which
package cannot be upgraded to the next major yet.

This is what make us work on symfony/deprecation-contracts
<https://github.com/symfony/deprecation-contracts>, which provide this
single trigger_deprecation(string $package, string $version, string $message
, ...$args); function. From the example in the readme:

trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is
deprecated, use "%s" instead.', 'bitcoin', 'fabcoin');

Generates:
Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use
"fabcoin" instead.

Joke aside, this is very useful and I wish the attribute could borrow
from the experience we gathered on the topic.

This would be nice:
<<Deprecated('symfony/blockchain', '8.9', 'Using "%s" is deprecated,
use "%s" instead.', 'bitcoin', 'fabcoin')>>

It could also be quiteuseful to have this trigger_deprecation()
function in core, but that's another topic :)

Cheers,

Nicolas

Reply via email to