Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Oct 11, 2025

Another cherry pick from one private project. We kept filling string type where value was always used in the sprintf() call.

It might have couple edge cases (like stringable objetcs), so I put this rule in the of level.

class SomeClass
{
-    public function formatMessage($name)
+    public function formatMessage(string $name)
    {
        return sprintf('My name is %s', $name);
    }
}

@TomasVotruba TomasVotruba changed the title tv param string type based on sprtinf [type-declaration] Add AddParamStringTypeFromSprintfUseRector Oct 11, 2025
@TomasVotruba TomasVotruba force-pushed the tv-param-string-type-based-on-sprtinf branch from 2bdda81 to 19e03ac Compare October 11, 2025 19:51
@TomasVotruba TomasVotruba enabled auto-merge (squash) October 11, 2025 19:51
@TomasVotruba TomasVotruba merged commit e7381c2 into main Oct 11, 2025
53 checks passed
@TomasVotruba TomasVotruba deleted the tv-param-string-type-based-on-sprtinf branch October 11, 2025 19:53
return null;
}

$hasChanged = false;
Copy link
Member

Choose a reason for hiding this comment

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

check parent method exists guard is needed here

Copy link
Member

Choose a reason for hiding this comment

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

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