When using an imported type in @psalm-assert-if-true a third-party consumer doesn't get the type correctly and I can't reproduce it in the sandbox or in separate files.
/**
* @psalm-import-type TraceFrame from TraceFrameValue
*/
final class Utils
{
/**
* @psalm-assert-if-true list<TraceFrame> $trace
*/
public static function isTrace(array $trace): bool
{
...
Then when this is used in another piece of code the type is traced as list<type-alias(Kint\Zval\TraceFrameValue::TraceFrame)> and causes errors.
The full code can be viewed in jnvsor/kint@5f5e69d2c28e821221ee5e60b16f7541feb1fce0
Please ignore the deluge of errors, it's a refactor in progress... The relevant traces and errors are below:
ERROR: Trace - src/Parser/TracePlugin.php:100:13 - $trace: list<type-alias(Kint\Zval\TraceFrameValue::TraceFrame)> (see https://psalm.dev/224)
/**
* @psalm-trace $trace
* @psalm-trace $index
* @psalm-trace $trace[$index]
*/
if (!isset($trace[$index]['file'])) {
continue;
}
ERROR: Trace - src/Parser/TracePlugin.php:100:13 - $index: int|string (see https://psalm.dev/224)
/**
* @psalm-trace $trace
* @psalm-trace $index
* @psalm-trace $trace[$index]
*/
if (!isset($trace[$index]['file'])) {
continue;
}
ERROR: Trace - src/Parser/TracePlugin.php:100:13 - $trace[$index]: mixed (see https://psalm.dev/224)
/**
* @psalm-trace $trace
* @psalm-trace $index
* @psalm-trace $trace[$index]
*/
if (!isset($trace[$index]['file'])) {
continue;
}
ERROR: InvalidArrayAccess - src/Parser/TracePlugin.php:100:24 - Cannot access array value on non-array variable $trace[$index] of type type-alias(Kint\Zval\TraceFrameValue::TraceFrame) (see https://psalm.dev/005)
if (!isset($trace[$index]['file'])) {
Even if $trace[$index] is a non-existent index (Which should be a different error) it should be null|TraceFrame not mixed as in the trace, and the actual error doesn't recognise that the type-alias(...) is an array
When using an imported type in
@psalm-assert-if-true
a third-party consumer doesn't get the type correctly and I can't reproduce it in the sandbox or in separate files.The type
TraceFrame
is defined as:And imported and used in:
Then when this is used in another piece of code the type is traced as
list<type-alias(Kint\Zval\TraceFrameValue::TraceFrame)>
and causes errors.The full code can be viewed in jnvsor/kint@5f5e69d2c28e821221ee5e60b16f7541feb1fce0
Please ignore the deluge of errors, it's a refactor in progress... The relevant traces and errors are below:
Even if
$trace[$index]
is a non-existent index (Which should be a different error) it should benull|TraceFrame
notmixed
as in the trace, and the actual error doesn't recognise that thetype-alias(...)
is an array