Skip to content

[Php55] Handle other class method reference strings in StringClassNameToClassConstantRector - #9069

Merged
TomasVotruba merged 1 commit into
mainfrom
string-class-other-method-reference
Nov 26, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
string-class-other-method-reference

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to #9066 and #9068. Method reference strings of other existing classes now use ::class too, so IDEs and renames can track them:

 return [
-    'controller' => 'App\Controller\DefaultController::indexAction',
+    'controller' => \App\Controller\DefaultController::class . '::indexAction',
-    'template' => 'App\Controller\LeadController::' . $func . 'Action',
+    'template' => \App\Controller\LeadController::class . '::' . $func . 'Action',
 ];
  • same checks as bare class names: class must exist, skip list applies, lowercase start skipped
  • inside a trait or anonymous class the own class name now becomes \Fqcn::class instead of being skipped, self::class stays limited to the enclosing named class
  • invalid method parts (::, ::a::b, ::$property) are skipped

Real world case: 46 such strings in Mautic, mostly controller keys in bundle configs.

@TomasVotruba
TomasVotruba force-pushed the string-class-other-method-reference branch from d6c05d7 to 79aa96d Compare November 26, 2026 16:58
@TomasVotruba
TomasVotruba enabled auto-merge (squash) November 26, 2026 16:59
@TomasVotruba
TomasVotruba merged commit 838b1ad into main Nov 26, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the string-class-other-method-reference branch November 26, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant