2016-12-16 18:56:23 -05:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2017-04-24 23:45:02 -04:00
|
|
|
class AssignmentTest extends TestCase
|
2016-12-16 18:56:23 -05:00
|
|
|
{
|
2018-11-05 21:57:36 -05:00
|
|
|
use Traits\InvalidCodeAnalysisTestTrait;
|
|
|
|
use Traits\ValidCodeAnalysisTestTrait;
|
2016-12-16 18:56:23 -05:00
|
|
|
|
2017-01-13 14:07:23 -05:00
|
|
|
/**
|
2017-04-24 23:45:02 -04:00
|
|
|
* @return array
|
2017-01-13 14:07:23 -05:00
|
|
|
*/
|
2018-11-05 21:57:36 -05:00
|
|
|
public function providerValidCodeParse()
|
2016-12-16 18:56:23 -05:00
|
|
|
{
|
2017-04-24 23:45:02 -04:00
|
|
|
return [
|
|
|
|
'nestedAssignment' => [
|
|
|
|
'<?php
|
|
|
|
$a = $b = $c = 5;',
|
|
|
|
'assertions' => [
|
2017-06-29 10:22:49 -04:00
|
|
|
'$a' => 'int',
|
2017-05-26 20:05:57 -04:00
|
|
|
],
|
|
|
|
],
|
2017-04-24 23:45:02 -04:00
|
|
|
];
|
2016-12-16 18:56:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-24 23:45:02 -04:00
|
|
|
* @return array
|
2016-12-16 18:56:23 -05:00
|
|
|
*/
|
2018-11-05 21:57:36 -05:00
|
|
|
public function providerInvalidCodeParse()
|
2016-12-16 18:56:23 -05:00
|
|
|
{
|
2017-04-24 23:45:02 -04:00
|
|
|
return [
|
|
|
|
'mixedAssignment' => [
|
|
|
|
'<?php
|
|
|
|
/** @var mixed */
|
|
|
|
$a = 5;
|
|
|
|
$b = $a;',
|
2017-05-26 20:05:57 -04:00
|
|
|
'error_message' => 'MixedAssignment',
|
|
|
|
],
|
2017-04-24 23:45:02 -04:00
|
|
|
];
|
2017-02-12 18:06:18 -05:00
|
|
|
}
|
2016-12-16 18:56:23 -05:00
|
|
|
}
|