Skip to content

Move/Rename events for issues triggered outside of tests #6580

@sebastianbergmann

Description

@sebastianbergmann

The new events introduced in #6579 for E_USER_DEPRECATION, E_USER_NOTICE, and E_USER_WARNING triggered outside of tests would naturally live in the PHPUnit\Event\TestRunner namespace as DeprecationTriggered, NoticeTriggered, and WarningTriggered. However, those names are already taken by existing event classes that represent something entirely different:

Current name What it represents Should have been named
TestRunner\DeprecationTriggered PHPUnit itself reporting a deprecation about the test runner TestRunner\PhpunitDeprecationTriggered
TestRunner\NoticeTriggered PHPUnit itself reporting a notice about the test runner TestRunner\PhpunitNoticeTriggered
TestRunner\WarningTriggered PHPUnit itself reporting a warning about the test runner TestRunner\PhpunitWarningTriggered

The regular deprecation process (deprecate old name, introduce new name, give consumers a migration window) cannot be applied here. After the renames, TestRunner\DeprecationTriggered would still exist but with a completely different meaning. Any subscriber implementing TestRunner\DeprecationTriggeredSubscriber would receive a structurally different object. There is no way to have both the old and new meaning coexist under the same fully-qualified class name.

For PHPUnit 13, the new events live in the PHPUnit\Event\TestRunner\Issue sub-namespace as a temporary home. The @todo annotations document the plan for PHPUnit 14:

  • The existing TestRunner\DeprecationTriggered (and NoticeTriggered, WarningTriggered) will be renamed to TestRunner\PhpunitDeprecationTriggered (and PhpunitNoticeTriggered, PhpunitWarningTriggered)
  • The new TestRunner\Issue\DeprecationTriggered (and NoticeTriggered, WarningTriggered) will be moved up to TestRunner\DeprecationTriggered (and NoticeTriggered, WarningTriggered)
  • The same applies to the corresponding Subscriber interfaces

This must be a hard break in PHPUnit 14 because both sides of the collision need to be reshuffled simultaneously.

Metadata

Metadata

Labels

feature/eventsIssues related to PHPUnit's event systemtype/backward-compatibilitySomething will be/is intentionally brokentype/refactoringA refactoring that should be applied to make the code easier to understand and maintain

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions