website/errors/method.internal.md
<?php declare(strict_types = 1);
namespace Vendor {
class Service {
/** @internal */
public function doInternal(): void {}
public function doPublic(): void {}
}
}
namespace App {
function test(\Vendor\Service $s): void {
$s->doInternal(); // error: Call to internal method Vendor\Service::doInternal() from outside its root namespace Vendor.
}
}
A method marked with the @internal PHPDoc tag is being called from outside its root namespace. Internal methods are implementation details that are not part of the public API. They may change or be removed without notice in future versions, and calling them from external code creates fragile dependencies.
Use the public API of the class instead of calling its internal methods:
namespace App {
function test(\Vendor\Service $s): void {
- $s->doInternal();
+ $s->doPublic();
}
}
If the class does not provide a public method for the functionality, consider requesting one from the library maintainer.