Skip to content

#[IgnorePHPUnitWarnings] attribute for ignoring PHPUnit warnings #6268

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

Merged

Conversation

nikophil
Copy link
Contributor

@nikophil nikophil commented Jul 7, 2025

This is a follow up PR of this discussion

I hope the involved complexity is not too high. I was actually pleasantly surprised how easy it was

Please, could you tell me what's your feeling about the implementation, if you're okay to go, I'll add some missing unit tests.

thanks!

@sebastianbergmann
Copy link
Owner

Please, could you tell me what's your feeling about the implementation, if you're okay to go, I'll add some missing unit tests.

Looks good, thank you. I will merge once you're ready.

@nikophil nikophil force-pushed the feat/ignore-warnings branch from 5b7a797 to 226a7c3 Compare July 8, 2025 06:14
@@ -1008,6 +1011,17 @@ public function testTriggeredPhpunitError(Code\Test $test, string $message): voi
*/
public function testTriggeredPhpunitWarning(Code\Test $test, string $message): void
{
if (
$test->isTestMethod() &&
class_exists($test->className()) &&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the call to class_exists() really needed? I do not see how we could have a Code\Test $test object where $test->className() returns a string that is not the name of a class that exists.

Copy link
Contributor Author

@nikophil nikophil Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it because the test DispatchingEmitterTest::testTestTriggeredPhpunitWarningEmitsTestPhpunitWarningTriggeredEvent uses a classname that does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that otherwise, we should use existing classes/methods here

@nikophil nikophil force-pushed the feat/ignore-warnings branch from 226a7c3 to c14fba9 Compare July 8, 2025 06:30
@nikophil nikophil force-pushed the feat/ignore-warnings branch from c2ef009 to 735d011 Compare July 8, 2025 06:53
@nikophil
Copy link
Contributor Author

nikophil commented Jul 8, 2025

@sebastianbergmann ready! 😊

@sebastianbergmann sebastianbergmann merged commit 52384ee into sebastianbergmann:main Jul 8, 2025
25 checks passed
@sebastianbergmann sebastianbergmann added this to the PHPUnit 12.3 milestone Jul 8, 2025
@sebastianbergmann sebastianbergmann changed the title Introduce attribute #[IgnorePHPUnitWarnings] #[IgnorePHPUnitWarnings] attribute for ignoring PHPUnit warnings Jul 8, 2025
@sebastianbergmann
Copy link
Owner

@nikophil I have changed the implementation in 4db30b1 to be consistent with similar functionality.

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

Successfully merging this pull request may close these issues.

2 participants