website/errors/classConstant.internalClass.md
<?php declare(strict_types = 1);
namespace Vendor {
/** @internal */
class InternalConfig {
public const VERSION = '1.0';
}
}
namespace App {
function test(): string {
return \Vendor\InternalConfig::VERSION; // error: Access to constant VERSION of internal class Vendor\InternalConfig from outside its root namespace Vendor.
}
}
A constant is being accessed on a class that is marked as @internal. Internal classes are not meant to be used outside the package or namespace where they are defined. Accessing constants on internal classes creates a dependency on implementation details that may change without notice.
Use a public (non-internal) API to access the information:
namespace App {
function test(): string {
- return \Vendor\InternalConfig::VERSION;
+ return \Vendor\Application::getVersion();
}
}
If no public API exists, consider requesting one from the library maintainers. Relying on internal classes is fragile and may break on library updates.