Bug Report
| Subject |
Details |
| Rector version |
2.4.2 |
| Installed as |
composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/d8eb040a-bade-476f-80db-31a111b7720c
<?php
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
$this->createMock('SomeClass')
->expects($this->once())
->method('someMethod')
->with($this->callback(static function (array $args): bool {
return count($args) === 2 && $args[0] === 'correct';
}));
}
}
Responsible rules
WithCallbackIdenticalToStandaloneAssertsRector
Expected Behavior
If the anonymouse function is static, it should also remove the static keyword, as otherwise the changed code containing the $this variable will break.
Just a minor thing. I think removing the static keyword should always be fine in this case, but maybe some deeper analysis is needed? Otherwise the rule should maybe ignore static functions.
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/d8eb040a-bade-476f-80db-31a111b7720c
Responsible rules
WithCallbackIdenticalToStandaloneAssertsRectorExpected Behavior
If the anonymouse function is static, it should also remove the static keyword, as otherwise the changed code containing the $this variable will break.
Just a minor thing. I think removing the static keyword should always be fine in this case, but maybe some deeper analysis is needed? Otherwise the rule should maybe ignore static functions.