[deprecation] Deprecate AddAssertArrayFromClassMethodDocblockRector - #8341
Merged
TomasVotruba merged 1 commit intoAug 10, 2026
Merged
Conversation
…as runtime asserts from docblocks are risky and academic The rule turns a @param docblock type into a runtime Assert call in every method body. It pays a runtime cost on every call, and it trusts a docblock that is often stale or wrong, so the assert can fail on valid input. Write a custom rule if a project really wants this.
TomasVotruba
enabled auto-merge (squash)
August 10, 2026 19:18
TomasVotruba
force-pushed
the
deprecate-assert-array-from-class-method-docblock
branch
from
August 10, 2026 19:21
aba7308 to
af45c87
Compare
TomasVotruba
deleted the
deprecate-assert-array-from-class-method-docblock
branch
August 10, 2026 19:23
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.
The rule reads a
@paramdocblock type and injects a runtimeAssert::all*()call at the top of the method.class SomeClass { /** * @param int[] $items */ public function run(array $items) { + \Webmozart\Assert\Assert::allInteger($items); } }Two problems:
@paramturns into a hard runtime failure on input that was always valid.That trade-off is a project-level decision, not a general upgrade. Write a custom rule where it is wanted.
Changes:
DeprecatedInterfaceand throws onrefactor()config/set/assert.phpandSetList::ASSERTremoved, the set held only this ruleAssertClassNameandExistingAssertStaticCallResolverremoved, they had no other user