-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e2099e
commit 525a86e
Showing
2 changed files
with
67 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Psalm\Tests; | ||
|
||
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait; | ||
|
||
class CastTest extends TestCase | ||
{ | ||
use ValidCodeAnalysisTestTrait; | ||
|
||
/** | ||
* @return iterable<string,array{code:string,assertions?:array<string,string>,ignored_issues?:list<string>,php_version?:string}> | ||
*/ | ||
public function providerValidCodeParse(): iterable | ||
{ | ||
yield 'castFalseOrIntToInt' => [ | ||
'code' => '<?php | ||
/** @var false|int<10, 20> */ | ||
$intOrFalse = 10; | ||
$int = (int) $intOrFalse; | ||
', | ||
'assertions' => [ | ||
'$int===' => '0|int<10, 20>', | ||
], | ||
]; | ||
yield 'castTrueOrIntToInt' => [ | ||
'code' => '<?php | ||
/** @var true|int<10, 20> */ | ||
$intOrTrue = 10; | ||
$int = (int) $intOrTrue; | ||
', | ||
'assertions' => [ | ||
'$int===' => '1|int<10, 20>', | ||
], | ||
]; | ||
yield 'castBoolOrIntToInt' => [ | ||
'code' => '<?php | ||
/** @var bool|int<10, 20> */ | ||
$intOrBool = 10; | ||
$int = (int) $intOrBool; | ||
', | ||
'assertions' => [ | ||
'$int===' => '0|1|int<10, 20>', | ||
], | ||
]; | ||
} | ||
} |