Skip to content

Conversation

samsonasik
Copy link
Member

@TomasVotruba I tested in our project, this cause diff:

1) Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\TypeWillReturnCallableArrowFunctionRector\TypeWillReturnCallableArrowFunctionRectorTest::test with data set #3 ('/Users/samsonasik/www/rector-...hp.inc')
Failed on fixture file "skip_return_create_mock.php.inc"
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
         $form = $this->createMock(FormInterface::class);
 
         $form->method('add')
-            ->willReturnCallback(function ($name, $type, $options) use (&$calls) {
+            ->willReturnCallback(function ($name, $type, $options) use (&$calls): static {
                  $calls[] = compact('name', 'type', 'options');
                  return $this->createMock(FormInterface::class);
              });

which cause error:

There was 1 error:

Return value must be of type SomeTest, MockObject_FormInterface_afa3944a returned

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @TomasVotruba

@samsonasik samsonasik closed this Aug 21, 2025
@samsonasik samsonasik reopened this Aug 21, 2025
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it to have faster feedback to test ;)

@samsonasik samsonasik enabled auto-merge (squash) August 21, 2025 04:25
@samsonasik samsonasik merged commit 5506285 into main Aug 21, 2025
6 checks passed
@samsonasik samsonasik deleted the skip-mock branch August 21, 2025 04:25
@samsonasik
Copy link
Member Author

For note: MockObject return already covered by ClosureReturnTypeRector so this skip is on purpose.

@TomasVotruba
Copy link
Member

Looks good 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants