Menu

← Back to mixin.*

Error Identifier: mixin.nonObject

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
 */
class Foo
{

}

Why is it reported? #

The @mixin PHPDoc tag contains a non-object type. The @mixin tag is used to declare that a class delegates method calls and property accesses to another object. This only makes sense with object types, because scalar types like int, string, bool, or array do not have methods or properties to delegate to.

How to fix it #

Replace the non-object type with an object type in the @mixin tag:

 /**
- * @mixin int
+ * @mixin SomeClass
  */
 class Foo
 {

 }

If you do not need mixin behavior, remove the @mixin tag entirely:

-/**
- * @mixin int
- */
 class Foo
 {

 }

How to ignore this error #

You can use the identifier mixin.nonObject to ignore this error using a comment:

// @phpstan-ignore mixin.nonObject
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.nonObject

Rules that report this error #

  • PHPStan\Rules\Classes\MixinRule [1]
  • PHPStan\Rules\Classes\MixinTraitRule [1]
  • PHPStan\Rules\Classes\MixinTraitUseRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.