Say I have a formatter function like this:
function prepareValue(mixed $value): string
{
...
return "{$value}";
}
/**
* @param array<int, array> $astTreeData
* @return string
*/
function makeFormattedDiff(array $astTreeData): string
{
$statusTree = [
'added' => function (string $path, array $node) {
{some code...}
return "Property '{$path}' was added with value: {$value}";
},
'deleted' => fn($path) => "Property '{$path}' was removed",
'nested' => function (string $path, array $node, callable $iterRender) {
{some code...}
return $iterRender($children, $path);
},
'changed' => function (string $path, array $node) {
{some code...}
return "Property '{$path}' was updated. From {$valueBefore} to {$valueAfter}";
},
'unchanged' => fn() => [],
];
/**
* @param array<int, array> $diff
* @return string
*/
$renderPlainDiff = function (array $diff, string|bool $pathComposition) use (&$renderPlainDiff, $statusTree) {
$diffCopy = $diff;
$lines = array_reduce(
$diffCopy,
/**
* @param array<int, string> $acc
* @param array<string, array> $node
* @param array|null $initial
* @return array
*/
function (array $acc, array $node, array|null $initial = []) use (
$renderPlainDiff,
$pathComposition,
$statusTree
) {
{some code...}
$diffTypeHandler = $statusTree[$status];
return flatten([$acc, $diffTypeHandler($newPath, $node, $renderPlainDiff)]);
},
[]
);
return implode("\n", $lines);
};
return $renderPlainDiff($astTreeData, false);
}
All parameters and return values are specified in detail with phpdoc and type hinting syntax but phpStan gives an error message phpstan: Function Differ\Formatters\plainFormatter\makeFormattedDiff() has parameter $astTreeData with no value type specified in iterable type array
What iterable type array values need to be described?