Menu

← Back to classConstant.*

Error Identifier: classConstant.internalInterface

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-library:

/** @internal */
interface InternalConfig
{
    public const MAX_RETRIES = 3;
}

// In your code:

echo InternalConfig::MAX_RETRIES;

Why is it reported? #

The code accesses a class constant on an interface that is marked with the @internal PHPDoc tag. Internal interfaces are not part of the public API and are intended to be used only within the package or root namespace where they are defined. Accessing constants on an internal interface from outside its root namespace creates a dependency on an implementation detail that may change or be removed without notice.

How to fix it #

Use a constant from a public (non-internal) interface or class instead:

 <?php declare(strict_types = 1);
 
-echo InternalConfig::MAX_RETRIES;
+echo PublicConfig::MAX_RETRIES;

If no public alternative exists, contact the library maintainer to request a public API for the constant, or define the constant directly in the application code.

How to ignore this error #

You can use the identifier classConstant.internalInterface to ignore this error using a comment:

// @phpstan-ignore classConstant.internalInterface
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: classConstant.internalInterface

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassConstantUsageExtension [1] [2]
  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.