psalm: PropertyNotSetInConstructor error for PHPunit test

Error:

ERROR: PropertyNotSetInConstructor - tests/ConfigTest.php:9:7 - Property Name\New\TestCase\ConfigTest::$backupStaticAttributes is not defined in constructor of Name\New\TestCase\ConfigTest and in any methods called in the constructor (see https://psalm.dev/074)
class ConfigTest extends TestCase

How can I fix it?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

This solved my problem:

composer require --dev psalm/plugin-phpunit
vendor/bin/psalm-plugin enable psalm/plugin-phpunit

You have to run psalm --init first if you don’t already have a config file

Replace plugin-vendor/plugin-package with psalm/plugin-phpunit. Do you have any suggestions on how we could make that more clear in the docs?

super-linter?

Never heard of it, so I won’t be able to help you with it.

And how can I enable it for github actions?

If you commit both psalm.xml and composer.lock, and run composer install as a part of your action it’s already enabled.