File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
tests/Type/WebMozartAssert/data Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,9 @@ This extension specifies types of values passed to:
7272* ` Assert::maxCount `
7373* ` Assert::countBetween `
7474* ` Assert::isList `
75+ * ` Assert::isNonEmptyList `
7576* ` Assert::isMap `
77+ * ` Assert::isNonEmptyMap `
7678* ` Assert::inArray `
7779* ` Assert::oneOf `
7880* ` Assert::methodExists `
Original file line number Diff line number Diff line change @@ -331,6 +331,15 @@ private static function getExpressionResolvers(): array
331331 )
332332 );
333333 },
334+ 'isNonEmptyList ' => static function (Scope $ scope , Arg $ expr ): Expr {
335+ return new BooleanAnd (
336+ self ::$ resolvers ['isList ' ]($ scope , $ expr ),
337+ new NotIdentical (
338+ $ expr ->value ,
339+ new Array_ ()
340+ )
341+ );
342+ },
334343 'isMap ' => static function (Scope $ scope , Arg $ expr ): Expr {
335344 return new BooleanAnd (
336345 new FuncCall (
@@ -346,6 +355,15 @@ private static function getExpressionResolvers(): array
346355 )
347356 );
348357 },
358+ 'isNonEmptyMap ' => static function (Scope $ scope , Arg $ expr ): Expr {
359+ return new BooleanAnd (
360+ self ::$ resolvers ['isMap ' ]($ scope , $ expr ),
361+ new NotIdentical (
362+ $ expr ->value ,
363+ new Array_ ()
364+ )
365+ );
366+ },
349367 'isCountable ' => static function (Scope $ scope , Arg $ expr ): Expr {
350368 return new BooleanOr (
351369 new FuncCall (
Original file line number Diff line number Diff line change @@ -106,6 +106,15 @@ public function isList($a, $b): void
106106 \PHPStan \Testing \assertType ('array<int, mixed>|null ' , $ b );
107107 }
108108
109+ public function isNonEmptyList ($ a , $ b ): void
110+ {
111+ Assert::isNonEmptyList ($ a );
112+ \PHPStan \Testing \assertType ('non-empty-array<int, mixed> ' , $ a );
113+
114+ Assert::nullOrIsNonEmptyList ($ b );
115+ \PHPStan \Testing \assertType ('non-empty-array<int, mixed>|null ' , $ b );
116+ }
117+
109118 public function isMap ($ a , $ b ): void
110119 {
111120 Assert::isMap ($ a );
@@ -115,4 +124,13 @@ public function isMap($a, $b): void
115124 \PHPStan \Testing \assertType ('array<string, mixed>|null ' , $ b );
116125 }
117126
127+ public function isNonEmptyMap ($ a , $ b ): void
128+ {
129+ Assert::isNonEmptyMap ($ a );
130+ \PHPStan \Testing \assertType ('non-empty-array<string, mixed> ' , $ a );
131+
132+ Assert::nullOrIsNonEmptyMap ($ b );
133+ \PHPStan \Testing \assertType ('non-empty-array<string, mixed>|null ' , $ b );
134+ }
135+
118136}
You can’t perform that action at this time.
0 commit comments