2016-10-20 06:13:35 +02:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2016-10-20 06:13:35 +02:00
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
|
|
|
|
|
2017-04-25 05:45:02 +02:00
|
|
|
class Php55Test extends TestCase
|
2016-10-20 06:13:35 +02:00
|
|
|
{
|
2021-12-04 21:55:53 +01:00
|
|
|
use ValidCodeAnalysisTestTrait;
|
2016-10-20 06:13:35 +02:00
|
|
|
|
2017-01-13 20:07:23 +01:00
|
|
|
/**
|
2022-11-05 22:34:42 +01:00
|
|
|
*
|
2017-01-13 20:07:23 +01:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerValidCodeParse(): iterable
|
2016-10-20 06:13:35 +02:00
|
|
|
{
|
2017-04-25 05:45:02 +02:00
|
|
|
return [
|
|
|
|
'finally' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2017-04-25 05:45:02 +02:00
|
|
|
try {
|
|
|
|
}
|
|
|
|
catch (\Exception $e) {
|
|
|
|
}
|
|
|
|
finally {
|
2017-05-27 02:05:57 +02:00
|
|
|
}',
|
2017-04-25 05:45:02 +02:00
|
|
|
],
|
|
|
|
'foreachList' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2017-04-25 05:45:02 +02:00
|
|
|
$array = [
|
|
|
|
[1, 2],
|
|
|
|
[3, 4],
|
|
|
|
];
|
2017-06-29 16:22:49 +02:00
|
|
|
|
2017-04-25 05:45:02 +02:00
|
|
|
foreach ($array as list($a, $b)) {
|
|
|
|
echo "A: $a; B: $b\n";
|
2017-05-27 02:05:57 +02:00
|
|
|
}',
|
2017-04-25 05:45:02 +02:00
|
|
|
],
|
|
|
|
'arrayStringDereferencing' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2017-04-25 05:45:02 +02:00
|
|
|
$a = [1, 2, 3][0];
|
|
|
|
$b = "PHP"[0];',
|
|
|
|
'assertions' => [
|
2017-06-29 16:22:49 +02:00
|
|
|
'$a' => 'int',
|
|
|
|
'$b' => 'string',
|
2017-05-27 02:05:57 +02:00
|
|
|
],
|
2017-04-25 05:45:02 +02:00
|
|
|
],
|
|
|
|
'classString' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2017-04-25 05:45:02 +02:00
|
|
|
class ClassName {}
|
2017-06-29 16:22:49 +02:00
|
|
|
|
2017-04-25 05:45:02 +02:00
|
|
|
$a = ClassName::class;',
|
|
|
|
'assertions' => [
|
2018-03-05 22:06:06 +01:00
|
|
|
'$a' => 'class-string',
|
2017-05-27 02:05:57 +02:00
|
|
|
],
|
|
|
|
],
|
2016-10-20 06:13:35 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|