[
'code' => ' [
'code' => ' [
'code' => ' 0;
if ($a) {
echo $matches[1];
}',
],
'functionExists' => [
'code' => ' [
'code' => 'foo) {
echo $a;
}',
],
'globalReturn' => [
'code' => ' [
'code' => ' [
'code' => ' 1 && is_string($a)) {
throw new \Exception("bad");
}',
'assertions' => [
'$a' => 'null|string',
],
],
'repeatAssertionWithOther' => [
'code' => ' 1 || is_string($a)) {
if (is_string($a)) {
echo strpos($a, "e");
}
}',
'assertions' => [
'$a' => 'null|string',
],
'ignored_issues' => ['PossiblyFalseArgument'],
],
'refineOredType' => [
'code' => ' [
'code' => ' [
'code' => ' [
'code' => 'value)) {
$this->value = ["x", "y"];
echo count($this->value) - 2;
}',
'assertions' => [],
'ignored_issues' => ['MixedPropertyAssignment', 'MixedArgument'],
],
'typedStatic' => [
'code' => ' [
'code' => '
= $this->getMessage() ?>
',
],
'psalmScopeThisInTemplateFQCN' => [
'code' => '
= $this->getMessage() ?>
',
],
'psalmVarThisInTemplate' => [
'code' => '
= $this->getMessage() ?>
',
],
'psalmVarThisAbsoluteClassInTemplate' => [
'code' => '
= $this->getMessage() ?>
',
],
];
}
public function providerInvalidCodeParse(): iterable
{
return [
'possiblyUndefinedVarInIf' => [
'code' => ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:6:26 - Possibly undefined global '
. 'variable $b, first seen on line 3',
],
'possiblyUndefinedArrayInIf' => [
'code' => ' 'PossiblyUndefinedGlobalVariable - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:25 - Possibly undefined global '
. 'variable $array, first seen on line 3',
],
'invalidGlobal' => [
'code' => ' 'InvalidGlobal',
],
'thisInStatic' => [
'code' => ' 'InvalidScope',
],
'static' => [
'code' => ' 'MixedReturnStatement',
],
'staticNullRef' => [
'code' => ' 'DocblockTypeContradiction',
],
'typedStaticCannotHaveNullDefault' => [
'code' => ' 'ReferenceConstraintViolation',
],
'typedStaticCannotBeAssignedInt' => [
'code' => ' 'ReferenceConstraintViolation',
],
'typedStaticCannotBeAssignedNull' => [
'code' => ' 'ReferenceConstraintViolation',
],
];
}
}