Analog for psalm-trace but with pretty print
$ composer require --dev klimick/psalm-show-type
$ vendor/bin/psalm-plugin enable Klimick\\PsalmShowType\\ShowTypePlugin
<?php
// With assignment:
/** @show-type */
$a = 42;
// With return statement (not supported by @psalm-trace):
$fn = function(): array {
/** @show-type */
return [
'value' => 42,
];
};
// Type from arrow fn expression (not supported by @psalm-trace):
$arrowFn = fn() => /** @show-type */ str_contains('psalm-show-type', 'show-type');
@psalm-trace: Foo\Bar\Str
@show-type: Str
@psalm-trace: SplDoublyLinkedList<int, Foo\Bar\Str>
@show-type: SplDoublyLinkedList<TKey: int, TValue: Str>
@psalm-trace: array<int, Foo\Bar\Str>
@show-type: array<TKey: int, TValue: Str>
@psalm-trace: list<Foo\Bar\Str>
@show-type: list<TValue: Str>
@psalm-trace: array{prop1: Foo\Bar\Str, prop2: SplDoublyLinkedList<int, Foo\Bar\Str>}
@show-type: array{
prop1: Str,
prop2: SplDoublyLinkedList<TKey: int, TValue: Str>,
}
@psalm-trace: callble(Foo\Bar\Num): array{prop1: Foo\Bar\Str, prop2: SplDoublyLinkedList<int, Foo\Bar\Str>}
@show-type: callble(Num): array{
prop1: Str,
prop2: SplDoublyLinkedList<TKey: int, TValue: Str>,
}