File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ class AssociativeArray extends Constraint
6161 public function __construct (array $ constraints , bool $ allowMissing = false , bool $ allowAdditional = true )
6262 {
6363 $ isNoConstraint = static function ($ constraint ): bool { return !($ constraint instanceof Constraint); };
64- if (!( is_array ( $ constraints ) && ! array_filter ($ constraints , $ isNoConstraint) )) {
64+ if (array_filter ($ constraints , $ isNoConstraint )) {
6565 throw InvalidArgumentException::create (1 , sprintf ('array of %s ' , Constraint::class));
6666 }
6767
@@ -167,12 +167,7 @@ protected function additionalFailureDescription($other): string
167167 $ table ->setHeaders ([ 'Key ' , 'Value ' , 'Constraint ' ]);
168168
169169 foreach ($ this ->constraints as $ key => $ constraint ) {
170- $ valueExists = false ;
171- if (is_array ($ other )) {
172- $ valueExists = array_key_exists ($ key , $ other );
173- } elseif ($ other instanceof ArrayAccess) {
174- $ valueExists = $ other ->offsetExists ($ key );
175- }
170+ $ valueExists = is_array ($ other ) ? array_key_exists ($ key , $ other ) : $ other ->offsetExists ($ key );
176171
177172 $ table ->addRow ([
178173 $ this ->exporter ()->export ($ key ),
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class SequentialArray extends Constraint
5353 /** @var int|null */
5454 protected $ maxItems ;
5555
56- /** @var Constraint */
56+ /** @var Constraint|null */
5757 protected $ constraint ;
5858
5959 /**
@@ -106,7 +106,7 @@ public function toString(): string
106106 }
107107 } elseif ($ this ->minItems ) {
108108 $ text .= ' with ≥ ' . $ this ->minItems . ' items ' ;
109- } else {
109+ } elseif ( $ this -> maxItems ) {
110110 $ text .= ' with ≤ ' . $ this ->maxItems . ' items ' ;
111111 }
112112
You can’t perform that action at this time.
0 commit comments