Skip to content

Commit

Permalink
Mark support for isEmpty and notEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Oct 5, 2022
1 parent f4f29ab commit 25c836b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ This extension specifies types of values passed to:
* `Assert::notFalse`
* `Assert::null`
* `Assert::notNull`
* `Assert::isEmpty`
* `Assert::notEmpty`
* `Assert::eq`
* `Assert::notEq`
* `Assert::same`
Expand Down
1 change: 1 addition & 0 deletions src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\Cast\Int_;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\Empty_;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Expr\StaticCall;
Expand Down
26 changes: 26 additions & 0 deletions tests/Type/WebMozartAssert/data/comparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ public function notNull(?int $a): void
assertType('int', $a);
}

/** @param string|null $c */
public function isEmpty(string $a, $b, $c): void
{
Assert::isEmpty($a);
assertType("''|'0'", $a);

Assert::isEmpty($b);
assertType("0|0.0|''|'0'|array{}|false|null", $b);

Assert::isEmpty($c);
assertType("''|'0'|null", $c);
}

/** @param string|null $c */
public function notEmpty(string $a, $b, $c): void
{
Assert::notEmpty($a);
assertType('non-falsy-string', $a);

Assert::notEmpty($b);
assertType("mixed~0|0.0|''|'0'|array{}|false|null", $b);

Assert::notEmpty($c);
assertType('non-falsy-string', $c);
}

/**
* @param non-empty-string $b2
*/
Expand Down

0 comments on commit 25c836b

Please sign in to comment.