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
|
|
|
|
|
|
|
/**
|
2021-03-20 02:44:44 +01:00
|
|
|
* @return iterable<string,array{string,error_message:string,1?:string[],2?:bool,3?:string}>
|
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' => [
|
|
|
|
'<?php
|
|
|
|
/** @psalm-trace $a */
|
|
|
|
$a = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
2021-11-15 03:09:37 +01:00
|
|
|
'traceVariables' => [
|
|
|
|
'<?php
|
|
|
|
/** @psalm-trace $a $b */
|
|
|
|
$a = getmypid();
|
|
|
|
$b = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
|
|
|
'traceVariablesComma' => [
|
|
|
|
'<?php
|
|
|
|
/** @psalm-trace $a, $b */
|
|
|
|
$a = getmypid();
|
|
|
|
$b = getmypid();',
|
|
|
|
'error_message' => 'Trace',
|
|
|
|
],
|
2020-04-09 03:03:05 +02:00
|
|
|
'undefinedTraceVariable' => [
|
|
|
|
'<?php
|
|
|
|
/** @psalm-trace $b */
|
|
|
|
echo 1;',
|
|
|
|
'error_message' => 'UndefinedTrace',
|
|
|
|
'error_levels' => [
|
|
|
|
'MixedAssignment',
|
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|