Repository navigation
Refactor the tests and make them pass PHPStan - #966
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PaCuQk8vH2QvAo5vXUe7t7
…ch blocks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PaCuQk8vH2QvAo5vXUe7t7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PaCuQk8vH2QvAo5vXUe7t7
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add precise PHPDoc types to the test helpers and fixtures, narrow nullable values and DOM query results, and pass deliberately invalid arguments through `TestCase::unchecked()` instead of suppressing the errors. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements to the test infrastructure and static analysis configuration, focusing on better management of temporary directories during tests, enhanced exception handling in test assertions, and improved static analysis for PHPUnit integration. The changes also refine how test fixtures are excluded from code analysis tools, ensuring more accurate and maintainable test and code quality processes.
Test Infrastructure Improvements:
TestCaseand various unit tests) to use theUsesTempDirectoryattribute for automatic setup and teardown of temporary directories, replacing manual directory management methods. This ensures consistent and reliable cleanup of test artifacts. [1] [2] [3] [4] [5] [6]TestCase, such asunchecked()for passing deliberately invalid arguments andcaptureException()for concise exception assertion and retrieval in tests.captureException()for clearer and more robust exception testing, replacing manual try/catch blocks. [1] [2] [3] [4] [5] [6] [7]Static Analysis and Code Quality:
phpstan/phpstan-phpunittocomposer.jsonand enabled its extension inphpstan.neon, improving static analysis for PHPUnit-specific code. [1] [2]phpstan.neonby refining ignored error patterns and adjusting excluded paths to focus on fixtures rather than entire test directories..php-cs-fixer.phpand.rector.phpconfiguration files to more accurately exclude only test fixtures from code formatting and refactoring tools, rather than all tests. [1] [2]Type and Signature Improvements:
mixedreturn type tocallMethod()inMethods.phpfor improved type safety and clarity.Minor Enhancements:
These changes collectively enhance test reliability, code quality, and maintainability, especially in how temporary resources and exceptions are managed during testing.