-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
positive-int
and negative-int
types
- Loading branch information
1 parent
912e66b
commit 2fc6a5f
Showing
4 changed files
with
40 additions
and
1 deletion.
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,26 @@ | ||
<?php | ||
|
||
namespace ExtraIntTypes; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @param positive-int $positiveInt | ||
* @param negative-int $negativeInt | ||
*/ | ||
public function doFoo( | ||
int $positiveInt, | ||
int $negativeInt, | ||
string $str | ||
): void | ||
{ | ||
assertType('int<1, max>', $positiveInt); | ||
assertType('int<min, -1>', $negativeInt); | ||
assertType('false', strpos('u', $str) === -1); | ||
assertType('true', strpos('u', $str) !== -1); | ||
} | ||
|
||
} |