Skip to content

Commit acb2975

Browse files
committed
Drop more phpunit 9 things
1 parent 0ea5396 commit acb2975

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
### Changed
11+
12+
- Dropped more code support for PHPUnit versions prior to 10.
13+
814
## v1.14.0
915

1016
### Added

src/mantle/testing/concerns/trait-reads-annotations.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ trait Reads_Annotations {
2626
* Read docblock annotations for the current test case and method.
2727
*/
2828
public function get_annotations_for_method(): array {
29-
// PHPUnit 9.4 and below method.
30-
if ( method_exists( $this, 'getAnnotations' ) ) {
31-
return $this->getAnnotations();
32-
}
33-
34-
// Use the PHPUnit ^9.5 method if available.
35-
if ( method_exists( Test::class, 'parseTestMethodAnnotations' ) ) { // @phpstan-ignore-line
36-
return Test::parseTestMethodAnnotations(
37-
static::class,
38-
$this->getName(), // @phpstan-ignore-line
39-
);
40-
}
41-
4229
// Use the PHPUnit 10.x method if available.
4330
if ( class_exists( Registry::class ) && class_exists( DocBlock::class ) ) {
4431
$registry = Registry::getInstance();
@@ -51,26 +38,12 @@ public function get_annotations_for_method(): array {
5138

5239
// If we are using PHPUnit 12.0.0 or greater, we can bail because
5340
// annotations are no longer supported. Attributes must be used instead.
54-
if ( class_exists( Version::class ) && version_compare( Version::id(), '12.0.0', '>=' ) ) {
55-
return [];
56-
}
57-
58-
// Throw a warning if we can't read annotations.
59-
trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
60-
'Unable to read annotations for test method. Please file an issue with https://github.com/alleyinteractive/mantle-framework',
61-
E_USER_WARNING
62-
);
63-
6441
return [];
6542
}
6643

6744
/**
6845
* Read the attributes for the current test case and method.
6946
*
70-
* Supports PHPUnit 9.5+.
71-
*
72-
* @todo Remove the PHPUnit 9.5+ support in a future major release and require PHPUnit 11+.
73-
*
7447
* @template T of object
7548
*
7649
* @param class-string|null $name Filter the results to include only ReflectionAttribute instances for attributes matching this class name.
@@ -84,10 +57,7 @@ public function get_annotations_for_method(): array {
8457
public function get_attributes_for_method( ?string $name = null, int $flags = 0, bool $inherit = true ): array {
8558
$class = new ReflectionClass( $this );
8659

87-
// Use either the PHPUnit 9.5+ method or the PHPUnit 10.x method to get the method.
88-
if ( method_exists( $this, 'getName' ) ) {
89-
$method = $class->getMethod( $this->getName( false ) );
90-
} elseif ( method_exists( $this, 'name' ) ) { // @phpstan-ignore-line function.alreadyNarrowedType
60+
if ( method_exists( $this, 'name' ) ) { // @phpstan-ignore-line function.alreadyNarrowedType
9161
$method = $class->getMethod( $this->name() );
9262
} elseif ( isset( $this->name ) ) {
9363
$method = $class->getMethod( $this->name );

0 commit comments

Comments
 (0)