From feaf6eae6b9a765fe229d65a9ba07c5715649dee Mon Sep 17 00:00:00 2001 From: Stefano Degenkamp Date: Fri, 6 Sep 2024 14:09:11 +0200 Subject: [PATCH] Update incorrect configuration example (#6294) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Where we are required to give a MethodCallToPropertyFetch object instead of just method names. The class of the corosponding methods is also a requirement. To illustrate this more clearly, I’ve used the example of a Person class with the getFirstName() method. --- .../Rector/MethodCall/MethodCallToPropertyFetchRector.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php index 5dd867ee2ff..2d515d47e31 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php @@ -25,14 +25,14 @@ final class MethodCallToPropertyFetchRector extends AbstractRector implements Co public function getRuleDefinition(): RuleDefinition { - return new RuleDefinition('Turns method call "$this->something()" to property fetch "$this->something"', [ + return new RuleDefinition('Turns method call "$this->getFirstname()" to property fetch "$this->firstname"', [ new ConfiguredCodeSample( <<<'CODE_SAMPLE' class SomeClass { public function run() { - $this->someMethod(); + $this->getFirstname(); } } CODE_SAMPLE @@ -42,13 +42,13 @@ class SomeClass { public function run() { - $this->someProperty; + $this->firstname; } } CODE_SAMPLE , [ - 'someMethod' => 'someProperty', + new MethodCallToPropertyFetch('ExamplePersonClass', 'getFirstname', 'firstname'), ] ), ]);