Hi.
I am trying to run Psalm on my old yii2 basic project.
When scanning all project I see too many issues.
So I try to run it for one file, just to try.
<projectFiles>
<file name="components/FileJob.php" />
<file name="vendor/autoload.php" />
<file name="vendor/composer/autoload_classmap.php" />
<file name="vendor/composer/autoload_files.php" />
<file name="vendor/composer/autoload_namespaces.php" />
<file name="vendor/composer/autoload_psr4.php" />
<file name="vendor/composer/autoload_real.php" />
<file name="vendor/composer/autoload_static.php" />
<file name="vendor/composer/ClassLoader.php" />
<file name="vendor/composer/installed.php" />
<file name="vendor/composer/InstalledVersions.php" />
<file name="vendor/composer/platform_check.php" />
<file name="vendor/yiisoft/extensions.php" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
That is FileJob:
namespace app\components;
use yii\base\BaseObject;
use Yii;
class FileJob extends BaseObject implements \yii\queue\JobInterface
{
public $file;
public function execute($queue)
{
$file = Yii::getAlias('@runtime/queuedata1/' . $this->file);
$content = file_get_contents($file);
unlink($file);
$file = str_replace('.txt', '__done.txt', $file);
file_put_contents($file, $content . "\n\n Done", FILE_APPEND);
}
}
Psalm gives me the next error conserning the use of Yii
ERROR: UndefinedClass - components/FileJob.php:13:17 - Class, interface or enum named Yii does not exist (see https://psalm.dev/019)
$file = Yii::getAlias('@runtime/queuedata1/' . $this->file);
Why is that?