Menu

Error Identifier: class.extendsInternalClass

← Back to class.*

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

namespace Vendor {
	/** @internal */
	class InternalBase {}
}

namespace App {
	class MyClass extends \Vendor\InternalBase {}
}

Why is it reported? #

The class extends another class that is marked as @internal by its declaring library. Internal classes are implementation details not meant to be extended by external code. The library may change, rename, or remove internal classes without notice, which would break any code that extends them.

How to fix it #

Extend a public base class provided by the library instead:

-class MyClass extends \Vendor\InternalBase {}
+class MyClass extends \Vendor\PublicBase {}

Or implement a public interface instead of extending the internal class:

-class MyClass extends \Vendor\InternalBase {}
+class MyClass implements \Vendor\PublicInterface {}

How to ignore this error #

You can use the identifier class.extendsInternalClass to ignore this error using a comment:

// @phpstan-ignore class.extendsInternalClass
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: class.extendsInternalClass

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]
Theme
A
© 2026 PHPStan s.r.o.