Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector should only apply to methods defined in a @dataProvider annotation. #2187

Closed
gnutix opened this issue Oct 21, 2019 · 5 comments · Fixed by #2275

Comments

@gnutix
Copy link
Contributor

gnutix commented Oct 21, 2019

I've added config/set/phpunit/phpunit-yield-data-provider.yaml to my imports, which does the following :

services:
    Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector:
        PHPUnit\Framework\TestCase:
            - '#(provide|dataProvider)*#'

I would have assumed that this would apply only on methods targeted by a dataProvider, but it's not. I had a private function getSomeData(): array; method in a test that got changed by the Rector (furthermore, data providers in PHPUnit are always public!).

Is there something I misunderstood about the intended behavior of this config file ? Or should I try to add a broken test ?

@gnutix gnutix changed the title Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector should only apply to methods listed by a @dataProvider annotation. Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector should only apply to methods defined in a @dataProvider annotation. Oct 21, 2019
@TomasVotruba
Copy link
Member

Broken test would be great 👍

@gnutix
Copy link
Contributor Author

gnutix commented Nov 6, 2019

I've had a look at the existing fixtures (as I would have thought this issue would have been caught in there already), and I have to say that they are very obscure to me. I don't really understand what test cases they cover and how/why they are structured the way they are.

@TomasVotruba
Copy link
Member

What file exactly do we talk about?

@TomasVotruba
Copy link
Member

No need to explore old test cases, as they all passes.
We need your failing test case, so I'd just add your failing one.

@gnutix
Copy link
Contributor Author

gnutix commented Nov 6, 2019

There you go : #2273

TomasVotruba added a commit that referenced this issue Nov 6, 2019
…tor/add-test-case-issue-2187

Add a working and a failing test case for #2187
TomasVotruba added a commit that referenced this issue Apr 28, 2022
rectorphp/rector-src@b055a88 Add RectorConfigProvider to ask for configuration behave for 3rd party packages (#2187)
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 a pull request may close this issue.

2 participants