- Issue created by @adamps
Automatically closed - issue fixed for 2 weeks with no activity.
It's already efficient however we can make it a little better.
Currently we copy all the parent params:
/**
* Constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler to invoke the alter hook with.
*
* @internal
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
protected readonly RendererInterface $renderer,
protected readonly ModuleHandlerInterface $moduleHandler,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
It takes up extra lines that are just copied, and it also our code depends on the exact params of the parent.
We can hide the parent args in an elipsis, like this.
/**
* Constructor.
*
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler to invoke the alter hook with.
* @param mixed ...$args
* Parent constructor arguments.
*
* @internal
*/
public function __construct(
protected readonly RendererInterface $renderer,
protected readonly ModuleHandlerInterface $moduleHandler,
...$args,
) {
parent::__construct(...$args);
}
Active
2.0
Code
Automatically closed - issue fixed for 2 weeks with no activity.