Auto-append prefix for php-extension packages

This commit is contained in:
crazywhalecc 2025-12-04 21:19:55 +08:00
parent e9d3f7e7eb
commit 20892ab194
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680

View File

@ -8,7 +8,12 @@ namespace StaticPHP\Attribute\Package;
* Indicates that the annotated class defines a PHP extension.
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
readonly class Extension
class Extension
{
public function __construct(public string $name) {}
public function __construct(public string $name)
{
if (!str_starts_with($name, 'ext-')) {
$this->name = "ext-{$name}";
}
}
}