Skip to content

[experimental] [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector#7206

Merged
TomasVotruba merged 3 commits intomainfrom
tv-assert-keys
Sep 1, 2025
Merged

[experimental] [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector#7206
TomasVotruba merged 3 commits intomainfrom
tv-assert-keys

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Sep 1, 2025

"Trust, but verify" approach to scalar array types.

Instead of hope/trust/feel, verify the assumption instead 👍

Not suitable for weak codebases ⚠️

final class MultipleParameters
{
    /**
     * @param array<string, string> $items
     * @param string[] $names
     */
    public function run(array $items, array $names)
    {
+        \Webmozart\Assert\Assert::allString($items);
+        \Webmozart\Assert\Assert::allString(array_keys($items));
+        \Webmozart\Assert\Assert::allString($names);
    }
}

@TomasVotruba TomasVotruba changed the title tv assert keys [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector Sep 1, 2025
@TomasVotruba TomasVotruba merged commit 5226e84 into main Sep 1, 2025
49 checks passed
@TomasVotruba TomasVotruba deleted the tv-assert-keys branch September 1, 2025 14:02
@TomasVotruba TomasVotruba changed the title [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector [experimental] [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector Sep 1, 2025
@TomasVotruba TomasVotruba mentioned this pull request Sep 1, 2025
@TomasVotruba
Copy link
Member Author

Todo

@TomasVotruba
Copy link
Member Author

Now configurable ✔️ it allows to use either beberlei or webmozart packages 👍

#7215

arshidkv12 pushed a commit to arshidkv12/rector-src that referenced this pull request Sep 4, 2025
…lockRector (rectorphp#7206)

* add ...

* [assert] Kick of experimental rule, AddAssertArrayFromClassMethodDocblockRector

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants