Closed alexander-schranz closed 3 months ago
that should already covered at PR:
please try latest dev-main
This seems only a upgrade rule if you want to upgrade to PHPUnit 10.1 not one if you keep 9.5 and want just remove the deprecation message if I understand correctly?
Looks like the PropertyExistsWithoutAssertRector
was for that but it got removed again.
phpunit is changing method from one version to another, so the last one is used, that's the reason why, for example, this PR exists:
@alexander-schranz This is caused by back and forth PHPUnit 9/10 removal added methods :) we don't have such a detailed sets, to counter that. So the best way is to ignore these methods for now and do the upgrade on PHPUnit 10.
What is the blocker for your to go PHPUnit 10?
PHPUnit 10 requires PHP 8.1 we still support lower version, but want to keep the code based prepared for PHPUnit 10.
I see :+1:
In that case I'd go for https://github.com/Yoast/PHPUnit-Polyfills and run the PHPUnit 10 rule explicitly
The polyfills sounds like a good idea, could use that traits as a BC layer, Thx.
Yeah we already run rector rules for the static data providers to make sure we not create unstatic data providers in our projects, thats why I thought forcing the property_exists is may something we could also already prepare 😄 :
->withRules([
StaticDataProviderClassMethodRector::class, // prepare for PHPUnit >= 10
]);
Until I use a simple assertObjectHasAttribute\((.*), (.*)\)
regex with assertTrue(property_exists($2, $1))
todo the replaces :)
The
assertObjectHasAttribute
andassertObjectNotHasAttribute
are deprecated in PHPUnit 9. To silence the deprecation error they can be replace with:The inverted version of AssertPropertyExistsRector need to be created. For PHPUnit 10.1 a new version converting to the new
assertObjectHasProperty
could be added but on PHPUnit 9 this das sadly not exists.