1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 08:49:52 +01:00
psalm/tests/CastTest.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2022-02-18 20:17:56 +01:00
<?php
namespace Psalm\Tests;
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
class CastTest extends TestCase
{
use ValidCodeAnalysisTestTrait;
public function providerValidCodeParse(): iterable
{
2022-10-17 12:14:07 +02:00
yield 'SKIPPED-castFalseOrIntToInt' => [
2022-02-18 20:17:56 +01:00
'code' => '<?php
/** @var false|int<10, 20> */
$intOrFalse = 10;
$int = (int) $intOrFalse;
',
'assertions' => [
'$int===' => '0|int<10, 20>',
],
];
2022-10-17 12:14:07 +02:00
yield 'SKIPPED-castTrueOrIntToInt' => [
2022-02-18 20:17:56 +01:00
'code' => '<?php
/** @var true|int<10, 20> */
$intOrTrue = 10;
$int = (int) $intOrTrue;
',
'assertions' => [
'$int===' => '1|int<10, 20>',
],
];
2022-10-17 12:14:07 +02:00
yield 'SKIPPED-castBoolOrIntToInt' => [
2022-02-18 20:17:56 +01:00
'code' => '<?php
/** @var bool|int<10, 20> */
$intOrBool = 10;
$int = (int) $intOrBool;
',
'assertions' => [
'$int===' => '0|1|int<10, 20>',
],
];
}
}