Refactor package stage handling and update class structures for improved flexibility

This commit is contained in:
crazywhalecc
2025-12-09 14:58:11 +08:00
parent e004d10861
commit 808aed2a66
29 changed files with 416 additions and 115 deletions

View File

@@ -10,5 +10,5 @@ namespace StaticPHP\Attribute\Package;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
readonly class AfterStage
{
public function __construct(public string $package_name, public string $stage, public ?string $only_when_package_resolved = null) {}
public function __construct(public string $package_name, public array|string $stage, public ?string $only_when_package_resolved = null) {}
}

View File

@@ -8,7 +8,12 @@ namespace StaticPHP\Attribute\Package;
* Indicates that the annotated method should be executed before a specific stage of the build process for a given package.
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
readonly class BeforeStage
class BeforeStage
{
public function __construct(public string $package_name, public string $stage, public ?string $only_when_package_resolved = null) {}
public readonly array|string $stage;
public function __construct(public string $package_name = '', array|callable|string $stage = '', public ?string $only_when_package_resolved = null)
{
$this->stage = $stage;
}
}

View File

@@ -10,5 +10,5 @@ namespace StaticPHP\Attribute\Package;
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
readonly class Stage
{
public function __construct(public string $name) {}
public function __construct(public ?string $function = null) {}
}