Skip to content

Commit 0bb3a5a

Browse files
committed
Remove code path for unused PHPUnit versions
1 parent f62295c commit 0bb3a5a

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

tests/SpecTests/DocumentsMatchConstraint.php

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use PHPUnit\Framework\Constraint\IsInstanceOf;
2424
use PHPUnit\Framework\Constraint\IsNull;
2525
use PHPUnit\Framework\Constraint\IsType;
26-
use PHPUnit\Framework\Constraint\LogicalAnd;
2726
use PHPUnit\Framework\Constraint\LogicalNot;
2827
use PHPUnit\Framework\Constraint\LogicalOr;
2928
use RuntimeException;
@@ -39,7 +38,6 @@
3938
use function is_float;
4039
use function is_int;
4140
use function is_object;
42-
use function method_exists;
4341
use function sprintf;
4442

4543
use const PHP_INT_SIZE;
@@ -148,40 +146,18 @@ private function assertBSONType(string $expectedType, $actualValue): void
148146
return;
149147

150148
case 'object':
151-
$constraints = [
149+
LogicalOr::fromConstraints(
152150
new IsType('object'),
153-
new LogicalNot(new IsInstanceOf(BSONArray::class)),
154-
];
155-
156-
// LogicalAnd::fromConstraints was introduced in PHPUnit 6.5.0.
157-
// This check can be removed when the PHPUnit dependency is bumped to that version
158-
if (method_exists(LogicalAnd::class, 'fromConstraints')) {
159-
$constraint = LogicalAnd::fromConstraints(...$constraints);
160-
} else {
161-
$constraint = new LogicalAnd();
162-
$constraint->setConstraints($constraints);
163-
}
164-
165-
$constraint->evaluate($actualValue);
151+
new LogicalNot(new IsInstanceOf(BSONArray::class))
152+
)->evaluate($actualValue);
166153

167154
return;
168155

169156
case 'array':
170-
$constraints = [
157+
LogicalOr::fromConstraints(
171158
new IsType('array'),
172-
new IsInstanceOf(BSONArray::class),
173-
];
174-
175-
// LogicalOr::fromConstraints was introduced in PHPUnit 6.5.0.
176-
// This check can be removed when the PHPUnit dependency is bumped to that version
177-
if (method_exists(LogicalOr::class, 'fromConstraints')) {
178-
$constraint = LogicalOr::fromConstraints(...$constraints);
179-
} else {
180-
$constraint = new LogicalOr();
181-
$constraint->setConstraints($constraints);
182-
}
183-
184-
$constraint->evaluate($actualValue);
159+
new IsInstanceOf(BSONArray::class)
160+
)->evaluate($actualValue);
185161

186162
return;
187163

0 commit comments

Comments
 (0)