|
23 | 23 | use PHPUnit\Framework\Constraint\IsInstanceOf;
|
24 | 24 | use PHPUnit\Framework\Constraint\IsNull;
|
25 | 25 | use PHPUnit\Framework\Constraint\IsType;
|
26 |
| -use PHPUnit\Framework\Constraint\LogicalAnd; |
27 | 26 | use PHPUnit\Framework\Constraint\LogicalNot;
|
28 | 27 | use PHPUnit\Framework\Constraint\LogicalOr;
|
29 | 28 | use RuntimeException;
|
|
39 | 38 | use function is_float;
|
40 | 39 | use function is_int;
|
41 | 40 | use function is_object;
|
42 |
| -use function method_exists; |
43 | 41 | use function sprintf;
|
44 | 42 |
|
45 | 43 | use const PHP_INT_SIZE;
|
@@ -148,40 +146,18 @@ private function assertBSONType(string $expectedType, $actualValue): void
|
148 | 146 | return;
|
149 | 147 |
|
150 | 148 | case 'object':
|
151 |
| - $constraints = [ |
| 149 | + LogicalOr::fromConstraints( |
152 | 150 | 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); |
166 | 153 |
|
167 | 154 | return;
|
168 | 155 |
|
169 | 156 | case 'array':
|
170 |
| - $constraints = [ |
| 157 | + LogicalOr::fromConstraints( |
171 | 158 | 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); |
185 | 161 |
|
186 | 162 | return;
|
187 | 163 |
|
|
0 commit comments