Using psalm in .phtml files

90 views Asked by At

I'm trying to make psalm work on .phtml files. Everything goes well, except for one thing. All classes (which should be autoloaded) are undefined. In normal php classes they get loaded by psalm.

Following gives UndefinedDocblockClass for CustomBlocks.

//my-template.phtml

<?php 
use MyNamespace\Block\CustomBlocks

/** @var CustomBlocks $block */
?>

Whilst adding OneRandomClass it doesn't give that error anymore.

//my-template.phtml

<?php 
use MyNamespace\Block\CustomBlocks

/** @var CustomBlocks $block */

class OneRandomClass {

}
?>

Update; the 2nd example doesn't give that error because the docblock is associated with the following class & the @var is ignored in class docblocks.

0

There are 0 answers