Menu

← Back to staticProperty.*

Error Identifier: staticProperty.internalTrait

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

// Defined in a third-party package:
// namespace ThirdParty;
// /** @internal */
// trait InternalConfig {
//     public static string $debugMode = 'off';
// }

use ThirdParty\InternalConfig;

$mode = InternalConfig::$debugMode;

Why is it reported? #

A static property is being accessed on a trait that is marked as @internal. Internal traits are not part of the public API of the package that defines them. They may change or be removed in any version without notice. Accessing static properties on internal traits creates a dependency on implementation details that should not be relied upon.

How to fix it #

Use the public API of the package instead of accessing static properties on internal traits:

 <?php declare(strict_types = 1);
 
 namespace App;

-use ThirdParty\InternalConfig;
+use ThirdParty\PublicConfig;

-$mode = InternalConfig::$debugMode;
+$mode = PublicConfig::getDebugMode();

If the trait is internal to the same package, the error will not be reported. The @internal restriction only applies to cross-package usage.

How to ignore this error #

You can use the identifier staticProperty.internalTrait to ignore this error using a comment:

// @phpstan-ignore staticProperty.internalTrait
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: staticProperty.internalTrait

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.