Menu

← Back to requireImplements.*

Error Identifier: requireImplements.internalClass

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

// In package vendor/some-lib:

/** @internal */
class InternalHelper
{
}

// In your code:

/**
 * @phpstan-require-implements InternalHelper
 */
interface HelperAware
{
}

Why is it reported? #

The @phpstan-require-implements PHPDoc tag references a class that is marked as @internal. Internal classes are not meant to be used outside the package or namespace they belong to. Referencing an internal class in a @phpstan-require-implements tag creates a dependency on an implementation detail that may change without notice.

How to fix it #

Replace the internal class with a public API type that serves the same purpose:

 <?php declare(strict_types = 1);
 
 /**
- * @phpstan-require-implements InternalHelper
+ * @phpstan-require-implements PublicHelperInterface
  */
 interface HelperAware
 {
 }

If the internal class is within the same package and the usage is intentional, the @internal tag may need to be reconsidered, or the @phpstan-require-implements tag should be removed in favor of a different design approach.

How to ignore this error #

You can use the identifier requireImplements.internalClass to ignore this error using a comment:

// @phpstan-ignore requireImplements.internalClass
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: requireImplements.internalClass

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.