2020-04-09 03:03:05 +02:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2020-04-09 03:03:05 +02:00
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
|
|
|
|
|
2020-04-09 03:03:05 +02:00
|
|
|
class TraceTest extends TestCase
|
|
|
|
{
|
2021-12-04 21:55:53 +01:00
|
|
|
use InvalidCodeAnalysisTestTrait;
|
2020-04-09 03:03:05 +02:00
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerInvalidCodeParse(): iterable
|
2020-04-09 03:03:05 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'traceVariable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-04-09 03:03:05 +02:00
|
|
|
/** @psalm-trace $a */
|
|
|
|
$a = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
2021-11-15 03:09:37 +01:00
|
|
|
'traceVariables' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-11-15 03:09:37 +01:00
|
|
|
/** @psalm-trace $a $b */
|
|
|
|
$a = getmypid();
|
|
|
|
$b = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
|
|
|
'traceVariablesComma' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-11-15 03:09:37 +01:00
|
|
|
/** @psalm-trace $a, $b */
|
|
|
|
$a = getmypid();
|
|
|
|
$b = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
2020-04-09 03:03:05 +02:00
|
|
|
'undefinedTraceVariable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-04-09 03:03:05 +02:00
|
|
|
/** @psalm-trace $b */
|
|
|
|
echo 1;',
|
|
|
|
'error_message' => 'UndefinedTrace',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [
|
2020-04-09 03:03:05 +02:00
|
|
|
'MixedAssignment',
|
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|