Menu

← Back to phpstanPlayground.*

Error Identifier: phpstanPlayground.traitUnused

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

trait MyTrait
{
	public function hello(): string
	{
		return 'Hello';
	}
}

Why is it reported? #

PHPStan analyses traits only through the classes that use them. A trait that is declared but never used with a use statement in any class is not analysed at all, meaning bugs inside it remain undetected.

This error is specific to the PHPStan Playground, where the analysed code is limited to what is pasted. It warns that the trait will not be covered by the analysis.

Learn more: How PHPStan Analyses Traits

How to fix it #

Add a class that uses the trait so PHPStan can analyse it:

 trait MyTrait
 {
 	public function hello(): string
 	{
 		return 'Hello';
 	}
 }

+class MyClass
+{
+	use MyTrait;
+}

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Playground\NotAnalysedTraitRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.