Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Sep 12, 2025

This is array param docblock brother to already existing rule: https://getrector.com/rule-detail/add-method-call-based-strict-param-type-rector

Since param array type is not conflicting with any parent/child class (contrary to strict type declaration), we can add those even on public methods, that use local calls 👍

class SomeClass
{
    public function go()
    {
        $this->run(['item1', 'item2']);
    }

+  /**    
+   * @param string[] $items
+   */
    private function run(array $items)
    {
    }
}

@TomasVotruba TomasVotruba force-pushed the tv-add-array-param-of-private-method-based-on-calls branch from 99d8606 to c542a09 Compare September 12, 2025 15:38
@TomasVotruba TomasVotruba force-pushed the tv-add-array-param-of-private-method-based-on-calls branch from c542a09 to bbfd6bc Compare September 12, 2025 15:41
@TomasVotruba TomasVotruba force-pushed the tv-add-array-param-of-private-method-based-on-calls branch from eb564cc to e2727e0 Compare September 12, 2025 15:47
@TomasVotruba TomasVotruba changed the title [type-declaration-docblocks] Add PrivateClassMethodArrayDocblockParamFromLocalCallsRector [type-declaration-docblocks] Add ClassMethodArrayDocblockParamFromLocalCallsRector Sep 12, 2025
@TomasVotruba TomasVotruba merged commit 45af749 into main Sep 12, 2025
49 checks passed
@TomasVotruba TomasVotruba deleted the tv-add-array-param-of-private-method-based-on-calls branch September 12, 2025 15:49
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Configuration\Parameter\FeatureFlags;

final class PrivateMethodFlagger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class should be on namespace Rector\TypeDeclaration namespace, since code logic is nothing todo with docblock,

using on docblock rules is fine, as a "user" that consume the logic.

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.

3 participants