File tree 3 files changed +38
-0
lines changed
tests/Type/WebMozartAssert/data
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:
72
72
* ` Assert::maxCount `
73
73
* ` Assert::countBetween `
74
74
* ` Assert::isList `
75
+ * ` Assert::isNonEmptyList `
75
76
* ` Assert::isMap `
77
+ * ` Assert::isNonEmptyMap `
76
78
* ` Assert::inArray `
77
79
* ` Assert::oneOf `
78
80
* ` Assert::methodExists `
Original file line number Diff line number Diff line change @@ -331,6 +331,15 @@ private static function getExpressionResolvers(): array
331
331
)
332
332
);
333
333
},
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
+ },
334
343
'isMap ' => static function (Scope $ scope , Arg $ expr ): Expr {
335
344
return new BooleanAnd (
336
345
new FuncCall (
@@ -346,6 +355,15 @@ private static function getExpressionResolvers(): array
346
355
)
347
356
);
348
357
},
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
+ },
349
367
'isCountable ' => static function (Scope $ scope , Arg $ expr ): Expr {
350
368
return new BooleanOr (
351
369
new FuncCall (
Original file line number Diff line number Diff line change @@ -106,6 +106,15 @@ public function isList($a, $b): void
106
106
\PHPStan \Testing \assertType ('array<int, mixed>|null ' , $ b );
107
107
}
108
108
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
+
109
118
public function isMap ($ a , $ b ): void
110
119
{
111
120
Assert::isMap ($ a );
@@ -115,4 +124,13 @@ public function isMap($a, $b): void
115
124
\PHPStan \Testing \assertType ('array<string, mixed>|null ' , $ b );
116
125
}
117
126
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
+
118
136
}
You can’t perform that action at this time.
0 commit comments