Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: Drop runtime deprecations where possible #31

Open
tux-rampage opened this issue Sep 28, 2021 · 0 comments
Open

[RFC]: Drop runtime deprecations where possible #31

tux-rampage opened this issue Sep 28, 2021 · 0 comments
Labels
Milestone

Comments

@tux-rampage
Copy link
Member

RFC

Q A
Proposed Version(s) 3.4.0
BC Break? ?

Goal

Reduce the maintenance Overhead and runtime cost when deprecating elements.

Background

Since static analysis tools like psalm have become quite powerful to analyse the code before it gets executed.
Therefore we should drop every trigger_error of a E_USER_DEPRECATED where a deprecation is already caught by static analysis. We should only keep it, where static analysis tool cannot catch then (for example when config keys have changed).

Another extreme weakness of deprecation notices during runtime is, that they only occur when the code path is actually executed. This means deprecated elements may be still in use undiscovered for a long time until somebody hits the execution path by accident.

Runtime deprecations are also a horror to maintain and they usually require ugly work arounds to be added like in https://github.com/laminas/laminas-di/blob/3.4.x/phpcs.xml#L21

Considerations

Some library consumers may not use static analysis to validate their code which are then cut of from being noted about deprecations.

This is a sign of poor code quality and tech debt. We should encourage users to use static analysis instead relying on runtime behaviour.

Proposal(s)

  • Drop all trigger_error statements from the codebase where a deprecation annotation is used
  • Add @deprecated Doc-Block annotations (usually those are already present)
  • Add @see to point to an alternative or a migration guide for the user
  • Encourage users to use static analysis tools like psalm or phpstan to detect usage of deprecated elements

Appendix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant