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 int&string
*/
class QueryBuilder
{
}
Why is it reported? #
The @mixin PHPDoc tag contains a type that PHPStan cannot resolve. This typically happens when the type expression evaluates to an impossible type, uses invalid type syntax, or references types in a way that produces an error during type resolution.
In the example above, int&string is an impossible intersection type – no value can be both int and string at the same time – so PHPStan cannot resolve it to a meaningful type.
How to fix it #
Reference a concrete class directly:
/**
- * @mixin int&string
+ * @mixin Connection
*/
class QueryBuilder
{
}
If the intent is to use a generic type, declare it with @template first:
+/**
+ * @template T of object
+ * @mixin T
+ */
-/**
- * @mixin int&string
- */
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