-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete string length type specifiers
- Loading branch information
1 parent
f53f3cb
commit 29c8c6c
Showing
4 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type\WebMozartAssert; | ||
|
||
use Webmozart\Assert\Assert; | ||
|
||
class Foo | ||
{ | ||
|
||
public function length(string $a, string $b): void | ||
{ | ||
Assert::length($a, 0); | ||
\PHPStan\Testing\assertType('\'\'', $a); | ||
|
||
Assert::length($b, 1); | ||
\PHPStan\Testing\assertType('non-empty-string', $b); | ||
} | ||
|
||
public function minLength(string $a, string $b): void | ||
{ | ||
Assert::minLength($a, 0); | ||
\PHPStan\Testing\assertType('string', $a); | ||
|
||
Assert::minLength($b, 1); | ||
\PHPStan\Testing\assertType('non-empty-string', $b); | ||
} | ||
|
||
public function maxLength(string $a, string $b): void | ||
{ | ||
Assert::maxLength($a, 0); | ||
\PHPStan\Testing\assertType('\'\'', $a); | ||
|
||
Assert::maxLength($b, 1); | ||
\PHPStan\Testing\assertType('string', $b); | ||
} | ||
|
||
public function lengthBetween(string $a, string $b, string $c, string $d): void | ||
{ | ||
Assert::lengthBetween($a, 0, 0); | ||
\PHPStan\Testing\assertType('\'\'', $a); | ||
|
||
Assert::lengthBetween($b, 0, 1); | ||
\PHPStan\Testing\assertType('string', $b); | ||
|
||
Assert::lengthBetween($c, 1, 0); | ||
\PHPStan\Testing\assertType('*NEVER*', $c); | ||
|
||
Assert::lengthBetween($d, 1, 1); | ||
\PHPStan\Testing\assertType('non-empty-string', $d); | ||
} | ||
|
||
} |