website/errors/staticMethod.internal.md
<?php declare(strict_types = 1);
namespace Vendor {
class Service {
/** @internal */
public static function doInternal(): void {}
public static function doPublic(): void {}
}
}
namespace App {
function test(): void {
\Vendor\Service::doInternal(); // error: Call to internal static method Vendor\Service::doInternal() from outside its root namespace Vendor.
}
}
A static method marked as @internal is being called from outside its root namespace. Internal methods are not part of the public API of the package and may change or be removed at any time without following semantic versioning. Calling them from external code creates a fragile dependency.
Use the public API provided by the package instead:
namespace App {
function test(): void {
- \Vendor\Service::doInternal();
+ \Vendor\Service::doPublic();
}
}
If the method is internal to the same package, the error will not be reported. The @internal restriction only applies to cross-package usage (calls from outside the root namespace).