Psalm: Is the incomplete phpdoc @var documented anywhere?

Created on 26 Aug 2019  路  3Comments  路  Source: vimeo/psalm

In my desperate attempts to type a line with $data assignment in the following code https://psalm.dev/r/c73a7e3d1c

<?php

/** @var mixed $data */
$data = 42;

$arr = [];
/** @var array{k: mixed} */
$arr['k'] = $data;

echo count($arr);

I accidentally found that an "incomplete" (not sure it's a thing, I could not find any references to it) @var notation works for that code.

While a "complete" version does not: /** @var array{k: mixed} $arr */

I believe the "complete" notation should work in this case.

And should the "short" one even be valid?

bug

All 3 comments

The short one should be valid - at least, it鈥檚 used a lot in the wild (though some linters prevent it). But the long version should also work, and that鈥檚 a bug.

This also works (no spaces): https://psalm.dev/r/69ce009611

This appears to work now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muglug picture muglug  路  3Comments

muglug picture muglug  路  3Comments

orklah picture orklah  路  3Comments

ErikBooijCB picture ErikBooijCB  路  4Comments

Pierstoval picture Pierstoval  路  3Comments