chore/add : void return type to test setUp() overrides#19
Merged
Conversation
PHPUnit 8 declared TestCase::setUp(), tearDown(), and the related
lifecycle hooks with a : void return type. Existing overrides
without : void are LSP-incompatible and fatal under PHPUnit 8.
The four test classes that override setUp() each get the matching
return type. No tearDown() or setUp{Before,After}Class overrides
exist in the suite.
The : void declaration is also valid under PHPUnit 5/6/7 (PHP 7+
allows a child method to add a return type when the parent has
none), so this commit is non-breaking against the currently-pinned
phpunit ^5.7.21 | ^6 | ^7 constraint.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates PHPUnit lifecycle overrides in the unit test suite to be forward-compatible with PHPUnit 8+ by adding : void return type declarations to setUp() methods, preventing fatal errors due to signature mismatches.
Changes:
- Added
: voidreturn type tosetUp()in four unit test classes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/unit/Db/DbTablePopulatorTest.php | Updates setUp() signature to setUp(): void for PHPUnit 8+ compatibility. |
| tests/unit/Dump/DumperTest.php | Updates setUp() signature to setUp(): void for PHPUnit 8+ compatibility. |
| tests/unit/Parser/FileTablePopulatorTest.php | Updates setUp() signature to setUp(): void for PHPUnit 8+ compatibility. |
| tests/unit/Parser/SchemaParserTest.php | Updates setUp() signature to setUp(): void for PHPUnit 8+ compatibility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
PHPUnit 8 added `: void` return type declarations to `TestCase::setUp()`, `tearDown()`, and the related lifecycle hooks. Existing overrides without `: void` are LSP-incompatible and fail with a fatal error under PHPUnit 8 (see https://github.com/graze/sprout/actions/runs/25490601510 for the failure on Dependabot PR #14).
This is a forward-compat tweak: `: void` is also valid under PHPUnit 5/6/7 (PHP 7+ allows a child method to add a return type when the parent declares none), so the change is safe against the currently-pinned `phpunit ^5.7.21 | ^6 | ^7` constraint and unblocks any future bump to ^8 or ^9.
Notable changes
Added `: void` to the `setUp()` declarations in:
The suite has no `tearDown()`, `setUpBeforeClass()`, `tearDownAfterClass()`, `assertPreConditions()`, `assertPostConditions()`, or `onNotSuccessfulTest()` overrides — checked with grep.
QA