Draft
Conversation
- Emit deprecation notices pointing to the actual call site in user code - Allow to redirect deprecated class names to their replacements via class_alias() - Resolve call site by walking the backtrace past autoloader frames To be expanded.
Member
|
At least horde/util has no hard dependencies on anything notable. I will check details later. |
ralflang
requested changes
Mar 17, 2026
Member
ralflang
left a comment
There was a problem hiding this comment.
I agree with putting the helper here if you don't want a dedicated component for it.
I don't agree with log spamming library users for using a migration path we actively offer and still use in 25+ places though.
Do not use this on Horde_Array right now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Add DeprecationHelper utility class
The helper can be used to redirect to another class by replacing the old class file with these 2 lines:
Of course it would be nicer to have a single root helper class, so we could do this:
or
In addition to the actual redirecton it also calls
trigger_error(or, optionally,error_log) to output deprecation notice with exact location of the deprecated code. It relies on autoloader to load old class, so only the first occurrence gets reported (overhead is small).The debug mode output example in case of
trigger_error:[horde] PHP ERROR: The Horde_Array class is deprecated. Switch to Horde\Util\ArrayUtils (.../vendor/horde/util/lib/Horde/Variables.php:364)And in case of
error_log(if 3rd parameter isfalse):DEPRECATED: The Horde_Array class is deprecated. Switch to Horde\\Util\\ArrayUtils (.../vendor/horde/util/lib/Horde/Variables.php:364)TODO: It might be a good idea to adjust Horde's error handler to suppress backtrace output for
E_USER_DEPRECATEDcase (the helper already reports exact location).2. Deprecate Horde_Array class (redirect to PSR-4 implementation)
This provides a working example, but many other classes could be redirected the same way, provided their methods/parameters are 100% compatible.
TODO: Add more helper methods for other scenarios (e.g. emit custom message and pinpoint location of the caller) for deprecated method or method parameters.