-
-
Notifications
You must be signed in to change notification settings - Fork 712
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
Incorrect behavior of TestWithAnnotationToAttributeRector with integers #8941
Incorrect behavior of TestWithAnnotationToAttributeRector with integers #8941
Comments
Re-open per rectorphp/rector-src#6608 (comment) the fix for numeric string, "true", "false" should be in a single PR to ease rollback. |
First time I see someone using this super ugly annotation based data-provider stuff instead of a proper php coded one :-). Recently @sebastianbergmann and me were discussing whether anyone on the planet needs this phpunit feature 😅 |
I believe @heiglandreas was the author of this particular But I think it's kinda nice if you have just 2-3 variations of something, then the "overhead" of a test provider method can feel overkill. |
IMO with this phpdoc based version you are loosing static analysis and other tooling support, which is a footgun.
I guess its a dark net thing ;-) |
I was working on several code-bases that heavily rely upon this 😂 And the attribute-version might actually be better in terms of types. But yes: It does come with a gun pointing at your foot out of the box! OTOH: Which data-provider is providing more type-safety... /**
* @return array{string, int, bool}[]
*/ or #[TestWith(['foo', 1, true])] Yes, the annotation one is about the same level of type-safety. But for small datasets the |
I don't like both. I would use a dataprovider method 😅 |
The first one is from a data-provider method 😉 |
when time allows I will revive a phpstan-phpunit PR, which will verify types of dataprovider vs. tests without the need for the manual phpdoc return type |
It could also inspect TestWith attribute types ;) |
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/322b336f-f232-4614-a264-6077e0a8f206
Responsible rules
TestWithAnnotationToAttributeRector
Expected Behavior
I'd expect
#[TestWith('2')]
as the annotation was using a string, but somehow it thinks it is smart to convert that to an int because I guess the string is numeric. Anyway this breaks the test as the $userId param requires a string.The text was updated successfully, but these errors were encountered: