Skip to content

chore/add : void return type to test setUp() overrides#19

Merged
rick-lam merged 1 commit into
mainfrom
chore/phpunit-8-compat
May 7, 2026
Merged

chore/add : void return type to test setUp() overrides#19
rick-lam merged 1 commit into
mainfrom
chore/phpunit-8-compat

Conversation

@rick-lam
Copy link
Copy Markdown
Contributor

@rick-lam rick-lam commented May 7, 2026

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:

  • `tests/unit/Db/DbTablePopulatorTest.php`
  • `tests/unit/Dump/DumperTest.php`
  • `tests/unit/Parser/FileTablePopulatorTest.php`
  • `tests/unit/Parser/SchemaParserTest.php`

The suite has no `tearDown()`, `setUpBeforeClass()`, `tearDownAfterClass()`, `assertPreConditions()`, `assertPostConditions()`, or `onNotSuccessfulTest()` overrides — checked with grep.

QA

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>
Copilot AI review requested due to automatic review settings May 7, 2026 10:42
@rick-lam rick-lam merged commit a5189fc into main May 7, 2026
9 checks passed
@rick-lam rick-lam deleted the chore/phpunit-8-compat branch May 7, 2026 10:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 : void return type to setUp() 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.

@rick-lam rick-lam restored the chore/phpunit-8-compat branch May 7, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants