File tree Expand file tree Collapse file tree 10 files changed +53
-53
lines changed
Expand file tree Collapse file tree 10 files changed +53
-53
lines changed Original file line number Diff line number Diff line change 3434 ],
3535 "require" : {
3636 "php" : " >=8.1" ,
37- "spiral/core" : " ^3.16 " ,
38- "spiral/files" : " ^3.16 " ,
39- "spiral/config" : " ^3.16 " ,
40- "spiral/debug" : " ^3.16 " ,
41- "spiral/exceptions" : " ^3.16 " ,
37+ "spiral/core" : " ^3.17 " ,
38+ "spiral/files" : " ^3.17 " ,
39+ "spiral/config" : " ^3.17 " ,
40+ "spiral/debug" : " ^3.17 " ,
41+ "spiral/exceptions" : " ^3.17 " ,
4242 "spiral/attributes" : " ^2.8|^3.0" ,
43- "spiral/events" : " ^3.16 "
43+ "spiral/events" : " ^3.17 "
4444 },
4545 "require-dev" : {
4646 "phpunit/phpunit" : " ^10.5.41" ,
6262 },
6363 "extra" : {
6464 "branch-alias" : {
65- "dev-master" : " 3.16 .x-dev"
65+ "dev-master" : " 3.17 .x-dev"
6666 }
6767 },
6868 "config" : {
Original file line number Diff line number Diff line change 66
77/**
88 * Abstract base class for method attributes used in bootloaders.
9- *
9+ *
1010 * This abstract class serves as a base for all method-level attributes in the bootloader system,
1111 * providing common functionality for managing binding aliases.
1212 *
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute to define additional aliases for a method.
9- *
9+ *
1010 * This attribute allows defining multiple aliases for a method in a bootloader class.
1111 * It can be used to bind a method's return value to multiple interface or class names.
12- *
12+ *
1313 * This attribute can be applied multiple times to the same method.
14- *
14+ *
1515 * Example usage:
1616 * ```php
1717 * class MyBootloader extends Bootloader
2424 * }
2525 * }
2626 * ```
27- *
28- * The above example binds the returned Logger instance to LoggerInterface,
27+ *
28+ * The above example binds the returned Logger instance to LoggerInterface,
2929 * PsrLoggerInterface, and MonologLoggerInterface.
3030 */
3131#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE )]
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute for marking methods that provide container bindings.
9- *
9+ *
1010 * Methods marked with this attribute will be invoked each time the container
1111 * needs to resolve the dependency, creating a new instance each time.
1212 * The return value of the method will be bound to the specified alias
1313 * or to all interfaces/classes in the return type.
14- *
14+ *
1515 * Example usage:
1616 * ```php
1717 * class MyBootloader extends Bootloader
2222 * {
2323 * return new HttpClient();
2424 * }
25- *
25+ *
2626 * // Method will be called each time the container resolves DbFactory
2727 * // instead of its return type (DatabaseFactory)
2828 * #[BindMethod(alias: DbFactory::class)]
2929 * public function createDatabaseFactory(): DatabaseFactory
3030 * {
3131 * return new DatabaseFactory();
3232 * }
33- *
33+ *
3434 * // Method will be called each time the container resolves either
3535 * // LogManagerInterface or its return type (LogManager)
3636 * #[BindMethod(alias: LogManagerInterface::class, aliasesFromReturnType: true)]
4040 * }
4141 * }
4242 * ```
43- *
43+ *
4444 * This attribute is similar to defining bindings via the `defineBindings()` method,
4545 * but with a more expressive and type-safe approach.
46- *
46+ *
4747 * @see SingletonMethod For binding singleton instances
4848 * @see InjectorMethod For binding injector methods
4949 */
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute for marking methods that should be called during the boot phase.
9- *
9+ *
1010 * Methods marked with this attribute will be called during the bootloader's
1111 * boot phase, after all initialization methods have been called.
1212 * The boot phase is where you typically configure services, register event listeners,
1313 * or perform other setup tasks.
14- *
14+ *
1515 * The priority parameter determines the order in which boot methods are called.
1616 * Higher priority values are executed first.
17- *
17+ *
1818 * Example usage:
1919 * ```php
2020 * class MyBootloader extends Bootloader
2525 * {
2626 * $router->addRoute('home', '/');
2727 * }
28- *
28+ *
2929 * // Called during boot phase with high priority (10)
3030 * #[BootMethod(priority: 10)]
3131 * public function configureDatabase(DatabaseInterface $db): void
3232 * {
3333 * $db->setDefaultConnection('default');
3434 * }
35- *
35+ *
3636 * // Called during boot phase with low priority (-10)
3737 * #[BootMethod(priority: -10)]
3838 * public function registerEventListeners(EventDispatcherInterface $dispatcher): void
4141 * }
4242 * }
4343 * ```
44- *
44+ *
4545 * Boot methods are executed after all bootloaders' init methods have been called.
46- *
46+ *
4747 * @see InitMethod For methods to be called during initialization phase
4848 */
4949#[\Attribute(\Attribute::TARGET_METHOD )]
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute to configure bootloader behavior.
9- *
9+ *
1010 * This attribute allows defining configuration for bootloaders, including
1111 * constructor arguments, enabling/disabling based on environment variables,
1212 * and controlling how configuration overrides work.
13- *
13+ *
1414 * Example usage:
1515 * ```php
1616 * // Basic configuration with constructor arguments
2020 * public function __construct(
2121 * private readonly string $defaultConnection
2222 * ) {}
23- *
23+ *
2424 * // ...
2525 * }
26- *
26+ *
2727 * // Conditionally enable based on environment
2828 * #[BootloadConfig(
2929 * allowEnv: ['APP_ENV' => ['local', 'development']],
3434 * // Only loaded in local or development environments
3535 * // And not when TESTING is true
3636 * }
37- *
37+ *
3838 * // Prevent runtime configuration from overriding attribute configuration
3939 * #[BootloadConfig(args: ['debug' => true], override: false)]
4040 * class DebugBootloader extends Bootloader
4343 * // configuration is provided at runtime
4444 * }
4545 * ```
46- *
46+ *
4747 * When a bootloader has both runtime configuration and a BootloadConfig attribute,
4848 * the override parameter controls which configuration takes precedence.
4949 */
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute for marking methods that should be called during the initialization phase.
9- *
9+ *
1010 * Methods marked with this attribute will be called during the bootloader's
1111 * initialization phase, before the boot phase begins. This is where you typically
1212 * set up container bindings, register services, or perform other initialization tasks.
13- *
13+ *
1414 * The priority parameter determines the order in which init methods are called.
1515 * Higher priority values are executed first.
16- *
16+ *
1717 * Example usage:
1818 * ```php
1919 * class MyBootloader extends Bootloader
2424 * {
2525 * $container->bindSingleton(MyService::class, MyServiceImplementation::class);
2626 * }
27- *
27+ *
2828 * // Called during initialization phase with high priority (10)
2929 * #[InitMethod(priority: 10)]
3030 * public function setupCore(): void
3131 * {
3232 * // Setup core components first
3333 * }
34- *
34+ *
3535 * // Called during initialization phase with low priority (-10)
3636 * #[InitMethod(priority: -10)]
3737 * public function setupExtensions(): void
4040 * }
4141 * }
4242 * ```
43- *
43+ *
4444 * Init methods are executed before any bootloader's boot methods are called.
45- *
45+ *
4646 * @see BootMethod For methods to be called during boot phase
4747 */
4848#[\Attribute(\Attribute::TARGET_METHOD )]
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute for marking methods that provide a custom injector.
9- *
9+ *
1010 * Methods marked with this attribute will be used as injectors for the specified
1111 * alias type. An injector is responsible for creating and configuring instances
1212 * of a specific type when they're requested from the container.
13- *
13+ *
1414 * Unlike BindMethod and SingletonMethod which bind the return value of the method,
1515 * InjectorMethod binds the method itself as an injector for the specified type.
16- *
16+ *
1717 * Example usage:
1818 * ```php
1919 * class MyBootloader extends Bootloader
2424 * {
2525 * return new Logger($channel);
2626 * }
27- *
27+ *
2828 * // Method will be used as injector for ConnectionInterface
2929 * #[InjectorMethod(ConnectionInterface::class)]
3030 * public function createDatabaseConnection(string $name = null): ConnectionInterface
3535 * }
3636 * }
3737 * ```
38- *
38+ *
3939 * With the above example, any time a LoggerInterface is requested from the container,
4040 * the createLogger method will be called with any provided constructor arguments.
41- *
41+ *
4242 * Injectors are powerful for types that need custom creation logic or that
4343 * accept additional parameters during construction.
44- *
44+ *
4545 * @see BindMethod For simple method bindings
4646 * @see SingletonMethod For singleton method bindings
4747 */
Original file line number Diff line number Diff line change 66
77/**
88 * Attribute for marking methods that provide singleton container bindings.
9- *
9+ *
1010 * Methods marked with this attribute will be invoked only once, and the
1111 * return value will be cached and reused for subsequent resolutions.
1212 * The return value of the method will be bound to the specified alias
1313 * or to all interfaces/classes in the return type.
14- *
14+ *
1515 * Example usage:
1616 * ```php
1717 * class MyBootloader extends Bootloader
2222 * {
2323 * return new HttpClient();
2424 * }
25- *
25+ *
2626 * // Method will be called once and the result will be bound to DbFactory
2727 * // instead of its return type (DatabaseFactory)
2828 * #[SingletonMethod(alias: DbFactory::class)]
2929 * public function createDatabaseFactory(): DatabaseFactory
3030 * {
3131 * return new DatabaseFactory();
3232 * }
33- *
33+ *
3434 * // Method will be called once and the result will be bound to both
3535 * // LogManagerInterface and its return type (LogManager)
3636 * #[SingletonMethod(alias: LogManagerInterface::class, aliasesFromReturnType: true)]
4040 * }
4141 * }
4242 * ```
43- *
43+ *
4444 * This attribute is similar to defining singletons via the `defineSingletons()` method,
4545 * but with a more expressive and type-safe approach.
46- *
46+ *
4747 * @see BindMethod For non-singleton bindings
4848 * @see InjectorMethod For binding injector methods
4949 */
Original file line number Diff line number Diff line change 1212use UnitEnum ;
1313
1414/**
15- * @implements InjectorInterface<UnitEnum>
15+ * @implements InjectorInterface<\ UnitEnum>
1616 *
1717 * @internal
1818 */
You can’t perform that action at this time.
0 commit comments