Error Identifier: mixin.unresolvableType
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);
/**
* @mixin T
*/
class QueryBuilder
{
}
Why is it reported? #
The @mixin PHPDoc tag contains a type that PHPStan cannot resolve. This typically happens when the type references a template type that is not declared on the current class, references an undefined class, or uses invalid type syntax.
In the example above, T is used in the @mixin tag but is not declared as a @template type parameter on the class, so PHPStan cannot determine what it refers to.
How to fix it #
If the intent is to use a generic type, declare it with @template first:
+/**
+ * @template T of Connection
+ * @mixin T
+ */
-/**
- * @mixin T
- */
class QueryBuilder
{
}
Or reference a concrete class directly:
/**
- * @mixin T
+ * @mixin Connection
*/
class QueryBuilder
{
}
How to ignore this error #
You can use the identifier mixin.unresolvableType to ignore this error using a comment:
// @phpstan-ignore mixin.unresolvableType
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: mixin.unresolvableType