13
13
use SebastianBergmann \Comparator \ComparisonFailure ;
14
14
use SebastianBergmann \Comparator \Factory ;
15
15
use stdClass ;
16
- use Symfony \Bridge \PhpUnit \ConstraintTrait ;
17
16
18
17
use function array_values ;
19
18
use function get_debug_type ;
36
35
*/
37
36
class DocumentsMatchConstraint extends Constraint
38
37
{
39
- use ConstraintTrait;
40
-
41
38
/**
42
39
* TODO: This is not currently used, but was preserved from the design of
43
40
* TestCase::assertMatchesDocument(), which would sort keys and then compare
@@ -65,7 +62,7 @@ public function __construct(array|object $value, private bool $ignoreExtraKeysIn
65
62
$ this ->comparatorFactory = Factory::getInstance ();
66
63
}
67
64
68
- private function doEvaluate ($ other , $ description = '' , $ returnResult = false )
65
+ public function evaluate ($ other , string $ description = '' , bool $ returnResult = false ): ? bool
69
66
{
70
67
/* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
71
68
* able to skip preparation, convert both documents to extended JSON,
@@ -100,6 +97,8 @@ private function doEvaluate($other, $description = '', $returnResult = false)
100
97
if (! $ success ) {
101
98
$ this ->fail ($ other , $ description , $ this ->lastFailure );
102
99
}
100
+
101
+ return null ;
103
102
}
104
103
105
104
/** @param string|BSONArray[] $expectedType */
@@ -198,7 +197,7 @@ private function assertEquals(ArrayObject $expected, ArrayObject $actual, bool $
198
197
}
199
198
}
200
199
201
- private function doAdditionalFailureDescription ($ other )
200
+ protected function additionalFailureDescription ($ other ): string
202
201
{
203
202
if ($ this ->lastFailure === null ) {
204
203
return '' ;
@@ -207,12 +206,12 @@ private function doAdditionalFailureDescription($other)
207
206
return $ this ->lastFailure ->getMessage ();
208
207
}
209
208
210
- private function doFailureDescription ($ other )
209
+ protected function failureDescription ($ other ): string
211
210
{
212
211
return 'two BSON objects are equal ' ;
213
212
}
214
213
215
- private function doMatches ($ other )
214
+ protected function matches ($ other ): bool
216
215
{
217
216
/* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
218
217
* able to skip preparation, convert both documents to extended JSON,
@@ -232,7 +231,7 @@ private function doMatches($other)
232
231
return true ;
233
232
}
234
233
235
- private function doToString ()
234
+ public function toString (): string
236
235
{
237
236
return 'matches ' . $ this ->exporter ()->export ($ this ->value );
238
237
}
0 commit comments