Skip to content

Commit

Permalink
Update incorrect configuration example (#6294)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
steef authored Sep 6, 2024
1 parent 4a94d2e commit feaf6ea
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,13 +42,13 @@ class SomeClass
{
public function run()
{
$this->someProperty;
$this->firstname;
}
}
CODE_SAMPLE
,
[
'someMethod' => 'someProperty',
new MethodCallToPropertyFetch('ExamplePersonClass', 'getFirstname', 'firstname'),
]
),
]);
Expand Down

0 comments on commit feaf6ea

Please sign in to comment.