Set getter methods as static

This commit is contained in:
Art4 2025-01-03 09:09:15 +00:00
parent 0b1325f297
commit 1924cc61a0
4 changed files with 15 additions and 15 deletions

View file

@ -25,13 +25,13 @@ final class Addon
public function getRequiredDependencies(): array
{
return $this->bootstrap->getRequiredDependencies();
return $this->bootstrap::getRequiredDependencies();
}
public function getProvidedDependencyRules(): array
{
if ($this->bootstrap instanceof DependencyProvider) {
return $this->bootstrap->provideDependencyRules();
return $this->bootstrap::provideDependencyRules();
}
return [];

View file

@ -25,12 +25,7 @@ interface AddonBootstrap
* return [LoggerInterface::class];
* ```
*/
public function getRequiredDependencies(): array;
/**
* Init the addon with the required dependencies.
*/
public function initAddon(AddonStartEvent $event): void;
public static function getRequiredDependencies(): array;
/**
* Return an array of events to subscribe to.
@ -46,5 +41,10 @@ interface AddonBootstrap
*
* @return array<string, string>
*/
public function getSubscribedEvents(): array;
public static function getSubscribedEvents(): array;
/**
* Init the addon with the required dependencies.
*/
public function initAddon(AddonStartEvent $event): void;
}

View file

@ -17,10 +17,10 @@ interface DependencyProvider
/**
* Returns an array of Dice rules.
*/
public function provideDependencyRules(): array;
public static function provideDependencyRules(): array;
/**
* Returns an array of strategy rules.
*/
public function provideStrategyRules(): array;
public static function provideStrategyRules(): array;
}

View file

@ -35,7 +35,7 @@ class HelloAddon implements AddonBootstrap, DependencyProvider
*
* The dependencies will be passed to the initAddon() method via AddonStartEvent::getDependencies().
*/
public function getRequiredDependencies(): array
public static function getRequiredDependencies(): array
{
return [
LoggerInterface::class,
@ -56,7 +56,7 @@ class HelloAddon implements AddonBootstrap, DependencyProvider
*
* @return array<string, string>
*/
public function getSubscribedEvents(): array
public static function getSubscribedEvents(): array
{
return [
HtmlFilterEvent::PAGE_END => 'onPageEnd',
@ -66,7 +66,7 @@ class HelloAddon implements AddonBootstrap, DependencyProvider
/**
* Returns an array of Dice rules.
*/
public function provideDependencyRules(): array
public static function provideDependencyRules(): array
{
// or return require($path_to_dependencies_file);
return [
@ -80,7 +80,7 @@ class HelloAddon implements AddonBootstrap, DependencyProvider
/**
* Returns an array of strategy rules.
*/
public function provideStrategyRules(): array
public static function provideStrategyRules(): array
{
// or return require($path_to_strategies_file);
return [];