website/errors/new.internalEnum.md
<?php declare(strict_types = 1);
namespace Vendor {
/** @internal */
enum CacheDriver {
case Redis;
case Memcached;
}
}
namespace App {
$driver = new \Vendor\CacheDriver(); // error: Instantiation of internal enum Vendor\CacheDriver.
}
In practice, this is typically reported as Cannot instantiate enum (new.enum) because enums cannot be instantiated at all. The new.internalEnum identifier is reported when the internal access violation is the primary concern.
An internal enum is being used in an instantiation context from outside its root namespace. Enums marked as @internal are not part of the public API of the package that defines them and are intended to be used only within that package. They may change or be removed without notice in future versions.
Use the public API provided by the package instead of directly referencing the internal enum:
namespace App {
- $driver = new \Vendor\CacheDriver();
+ $driver = \Vendor\CacheFactory::create();
}
If no public alternative exists, contact the package maintainer to request a public API for the functionality needed.