14. Name the member every report is made from - #76
Open
nikolaystrikhar wants to merge 1 commit into
Open
Conversation
`_doing_it_wrong()`'s first argument came in two shapes: `Class::method` at the facade's two trampolines and at the too-late boot, and a bare class name at the other eight sites. WordPress prints it as "Function %s was called incorrectly", so it is the only part of a report that says where in the library the sentence came from -- and a bare class cannot separate two reports made by the same class, which is exactly what `Absorber::render_notices` and `Absorber::filter_activation_error_markup` are, and what `Loader::load_all`, `Loader::load` and `Loader::announce` are. `Class::method` everywhere. Written as `self::class . '::method'` rather than `__METHOD__`, because both traits here are reported through and `__METHOD__` inside a trait method names the trait rather than the class using it -- a host would be sent to `Traits\Guards_Hook_Prefix` instead of to the facade or the load pass that actually stood down. The too-late boot keeps naming `Absorber::boot`: the mistake there is in a call the host made, and that is the call it has to move. `Traits\Reports_Errors` now states the rule, so the next report site has one shape to copy rather than three to choose from, and `WithIncorrectUsage::assert_the_library_reported_incorrect_usage()` enforces it across the suite -- the shape, not the member name, so a rename still passes.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
What: one shape for
_doing_it_wrong()'s first argument across every report site in the library —Class::method, never a bare class name — with the rule stated onTraits\Reports_Errorsand enforced byWithIncorrectUsage.Usage: a host reading a debug log or listening on
{prefix}/plugin_absorber/errornow getsinstead of
Function Nexcess\PluginAbsorber\Loader was called incorrectly, which read identically whether the load pass abandoned a sub-plugin, the file gate refused one, or a lifecycle listener threw.Why this way:
The member is the only thing separating two reports from one class.
Absorberreports from two static trampolines andLoaderfrom three methods; a bare class name collapses all five into one attribution, and the message is then the only way to tell them apart.self::class . '::method', not__METHOD__.__METHOD__inside a trait method names the trait, so the prefix guard and the error reporter would both attribute toTraits\…rather than to the class that actually stood down.The too-late boot still names
Absorber::boot. Every other site names where the sentence was written; that one names the call the host got wrong, because moving that call is the fix.The suite pins the shape, not the name. One assertion that a report contains
::refuses a bare class at any new site while leaving method renames free.