1313use SebastianBergmann \Comparator \ComparisonFailure ;
1414use SebastianBergmann \Comparator \Factory ;
1515use stdClass ;
16- use Symfony \Bridge \PhpUnit \ConstraintTrait ;
1716
1817use function array_values ;
1918use function get_debug_type ;
3635 */
3736class DocumentsMatchConstraint extends Constraint
3837{
39- use ConstraintTrait;
40-
4138 /**
4239 * TODO: This is not currently used, but was preserved from the design of
4340 * TestCase::assertMatchesDocument(), which would sort keys and then compare
@@ -65,7 +62,7 @@ public function __construct(array|object $value, private bool $ignoreExtraKeysIn
6562 $ this ->comparatorFactory = Factory::getInstance ();
6663 }
6764
68- private function doEvaluate ($ other , $ description = '' , $ returnResult = false )
65+ public function evaluate ($ other , string $ description = '' , bool $ returnResult = false ): ? bool
6966 {
7067 /* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
7168 * able to skip preparation, convert both documents to extended JSON,
@@ -100,6 +97,8 @@ private function doEvaluate($other, $description = '', $returnResult = false)
10097 if (! $ success ) {
10198 $ this ->fail ($ other , $ description , $ this ->lastFailure );
10299 }
100+
101+ return null ;
103102 }
104103
105104 /** @param string|BSONArray[] $expectedType */
@@ -198,7 +197,7 @@ private function assertEquals(ArrayObject $expected, ArrayObject $actual, bool $
198197 }
199198 }
200199
201- private function doAdditionalFailureDescription ($ other )
200+ protected function additionalFailureDescription ($ other ): string
202201 {
203202 if ($ this ->lastFailure === null ) {
204203 return '' ;
@@ -207,12 +206,12 @@ private function doAdditionalFailureDescription($other)
207206 return $ this ->lastFailure ->getMessage ();
208207 }
209208
210- private function doFailureDescription ($ other )
209+ protected function failureDescription ($ other ): string
211210 {
212211 return 'two BSON objects are equal ' ;
213212 }
214213
215- private function doMatches ($ other )
214+ protected function matches ($ other ): bool
216215 {
217216 /* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
218217 * able to skip preparation, convert both documents to extended JSON,
@@ -232,7 +231,7 @@ private function doMatches($other)
232231 return true ;
233232 }
234233
235- private function doToString ()
234+ public function toString (): string
236235 {
237236 return 'matches ' . $ this ->exporter ()->export ($ this ->value );
238237 }
0 commit comments