1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
psalm/tests/AssignmentTest.php
2019-01-11 14:57:21 -05:00

58 lines
1.4 KiB
PHP

<?php
namespace Psalm\Tests;
class AssignmentTest extends TestCase
{
use Traits\InvalidCodeAnalysisTestTrait;
use Traits\ValidCodeAnalysisTestTrait;
/**
* @return array
*/
public function providerValidCodeParse()
{
return [
'nestedAssignment' => [
'<?php
$a = $b = $c = 5;',
'assertions' => [
'$a' => 'int',
],
],
'assignmentInByRefParams' => [
'<?php
function foo(?string $s, ?string $t): void {}
foo($s = null, $t = null);
echo $s;
echo $t;
function foo2(?string &$u, ?string &$v): void {}
foo2($u = null, $v = null);
echo $u;
echo $v;
$read = [fopen(\'php://stdin\', \'rb\')];
$return = stream_select($read, $w = null, $e = null, 0);
echo $w;
echo $e;',
],
];
}
/**
* @return array
*/
public function providerInvalidCodeParse()
{
return [
'mixedAssignment' => [
'<?php
/** @var mixed */
$a = 5;
$b = $a;',
'error_message' => 'MixedAssignment',
],
];
}
}