Skip to content

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

Open
TomasVotruba wants to merge 1 commit into
mainfrom
string-class-other-method-reference
Open

TomasVotruba wants to merge 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.

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