Menu

Error Identifier: interface.disallowedSubtype

← Back to interface.*

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);

/** @phpstan-sealed AllowedInterface */
interface SealedInterface
{
}

interface AllowedInterface extends SealedInterface
{
}

interface DisallowedInterface extends SealedInterface
{
}

Why is it reported? #

The interface extends another interface that has been marked as sealed using the @phpstan-sealed PHPDoc tag. A sealed interface restricts which types are allowed to extend it. The DisallowedInterface is not listed among the allowed subtypes, so PHPStan reports it.

This mechanism enforces closed hierarchies where only specific implementations are permitted, similar to sealed classes in other languages.

How to fix it #

Add the interface to the list of allowed subtypes in the sealed declaration:

-/** @phpstan-sealed AllowedInterface */
+/** @phpstan-sealed AllowedInterface|DisallowedInterface */
 interface SealedInterface
 {
 }

Or remove the sealed parent from the interface declaration if it should not extend the sealed interface:

-interface DisallowedInterface extends SealedInterface
+interface DisallowedInterface
 {
 }

How to ignore this error #

You can use the identifier interface.disallowedSubtype to ignore this error using a comment:

// @phpstan-ignore interface.disallowedSubtype
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: interface.disallowedSubtype

Rules that report this error #

  • PHPStan\Rules\Classes\AllowedSubTypesRule [1]
Theme
A
© 2026 PHPStan s.r.o.