From 9cb5a459e3675b7a116b18948a911296c7f65305 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Tue, 30 Apr 2024 09:05:30 -0400 Subject: [PATCH] PHPStan Level 2 fixes, more (#5974) * PHPStan Level 2 fixes, more * Chasing D11 theme extension list --- phpstan.neon.dist | 6 ++++- src/Boot/BaseBoot.php | 3 ++- src/Boot/BootstrapManager.php | 8 +++---- src/Boot/DrupalBoot.php | 4 ---- src/Boot/DrupalBoot8.php | 5 +++-- src/Commands/config/ConfigImportCommands.php | 13 +++++++++-- src/Commands/core/DeployCommands.php | 2 +- src/Commands/core/EntityCreateCommands.php | 4 ++-- src/Commands/core/MigrateRunnerCommands.php | 5 ++--- src/Commands/core/MkCommands.php | 1 + src/Commands/core/WatchdogCommands.php | 2 +- src/Commands/help/ListCommands.php | 6 +++-- src/Config/ConfigLocator.php | 19 +++++----------- src/Drush.php | 8 +++---- src/Exec/ExecTrait.php | 2 +- src/Preflight/ArgsPreprocessor.php | 6 +++-- src/Preflight/PreflightArgs.php | 14 +++++------- src/Psysh/DrushHelpCommand.php | 22 +------------------ src/Psysh/Shell.php | 7 +++--- src/Runtime/LegacyServiceInstantiator.php | 23 ++++++++------------ src/Runtime/ServiceManager.php | 6 ++--- 21 files changed, 72 insertions(+), 94 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 478976573d..925101c565 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,7 +6,11 @@ parameters: paths: - src drupal: - drupal_root: sut + drupal_root: %currentWorkingDirectory%/sut + universalObjectCratesClasses: + # Useful until we have https://www.drupal.org/project/drupal/issues/2024043 + - Drupal\Core\Extension\Extension + - Drupal\views\ViewExecutable excludePaths: # Deliberately calls optional external code. - src/Psysh/Caster.php diff --git a/src/Boot/BaseBoot.php b/src/Boot/BaseBoot.php index ff8d97ce0a..c104802e4a 100644 --- a/src/Boot/BaseBoot.php +++ b/src/Boot/BaseBoot.php @@ -49,8 +49,9 @@ public function validRoot(?string $path): bool return false; } - public function getVersion($root) + public function getVersion(string $root) { + return null; } public function commandDefaults() diff --git a/src/Boot/BootstrapManager.php b/src/Boot/BootstrapManager.php index 8c13c6227c..80c9f1d2ad 100644 --- a/src/Boot/BootstrapManager.php +++ b/src/Boot/BootstrapManager.php @@ -58,7 +58,7 @@ protected function setPhase(int $phase): void /** * Add a bootstrap object to the list of candidates. * - * @param \Drush\Boot\Boot|Array + * @param \Drush\Boot\Boot|array $candidateList * List of boot candidates */ public function add($candidateList): void @@ -126,7 +126,7 @@ public function setUri($uri): void /** * Crete the bootstrap object if necessary, then return it. */ - public function bootstrap(): Boot + public function bootstrap(): DrupalBoot8 { if (!$this->bootstrap) { $this->bootstrap = $this->bootstrapObjectForRoot($this->getRoot()); @@ -382,14 +382,14 @@ public function bootstrapToPhaseIndex(int $max_phase_index, ?AnnotationData $ann /** * Bootstrap to the highest level possible, without triggering any errors. * - * @param int $max_phase_index + * @param $max_phase_index * (optional) Only attempt bootstrap to the specified level. * @param AnnotationData $annotationData * Optional annotation data from the command. * * The maximum phase to which we bootstrapped. */ - public function bootstrapMax($max_phase_index = false, ?AnnotationData $annotationData = null): int + public function bootstrapMax(bool|int|null $max_phase_index = false, ?AnnotationData $annotationData = null): int { // Bootstrap as far as we can without throwing an error, but log for // debugging purposes. diff --git a/src/Boot/DrupalBoot.php b/src/Boot/DrupalBoot.php index 422836501b..5aea40d5e0 100644 --- a/src/Boot/DrupalBoot.php +++ b/src/Boot/DrupalBoot.php @@ -45,10 +45,6 @@ protected function scanUpForUri($root, $scan) return false; } - public function getVersion($drupal_root) - { - } - public function confPath(bool $require_settings = true, bool $reset = false): ?string { return null; diff --git a/src/Boot/DrupalBoot8.php b/src/Boot/DrupalBoot8.php index b5330711e6..1af96b673e 100644 --- a/src/Boot/DrupalBoot8.php +++ b/src/Boot/DrupalBoot8.php @@ -16,6 +16,7 @@ use Drush\Runtime\LegacyServiceFinder; use Drush\Runtime\LegacyServiceInstantiator; use Drush\Runtime\ServiceManager; +use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Robo\Robo; use Symfony\Component\HttpFoundation\Request; @@ -58,7 +59,7 @@ public function getKernel(): DrupalKernelInterface */ public function setLogger(LoggerInterface $logger): void { - if ($this->drupalLoggerAdapter) { + if ($this->drupalLoggerAdapter && $this->drupalLoggerAdapter instanceof LoggerAwareInterface) { $this->drupalLoggerAdapter->setLogger($logger); } parent::setLogger($logger); @@ -79,7 +80,7 @@ public function validRoot(?string $path): bool return false; } - public function getVersion($drupal_root): string + public function getVersion($root): string { return \Drupal::VERSION; } diff --git a/src/Commands/config/ConfigImportCommands.php b/src/Commands/config/ConfigImportCommands.php index cb365256f8..4e1596637b 100644 --- a/src/Commands/config/ConfigImportCommands.php +++ b/src/Commands/config/ConfigImportCommands.php @@ -20,6 +20,7 @@ use Drupal\Core\Extension\ModuleExtensionList; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleInstallerInterface; +use Drupal\Core\Extension\ThemeExtensionList; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Site\Settings; @@ -119,6 +120,11 @@ public function getModuleExtensionList(): ModuleExtensionList return $this->moduleExtensionList; } + public function getThemeExtensionList(): ThemeExtensionList + { + return $this->themeExtensionList; + } + public function __construct( protected ConfigManagerInterface $configManager, protected StorageInterface $configStorage, @@ -130,7 +136,8 @@ public function __construct( protected ModuleInstallerInterface $moduleInstaller, protected ThemeHandlerInterface $themeHandler, protected TranslationInterface $stringTranslation, - protected ModuleExtensionList $moduleExtensionList + protected ModuleExtensionList $moduleExtensionList, + protected ThemeExtensionList $themeExtensionList ) { parent::__construct(); } @@ -149,6 +156,7 @@ public static function create(ContainerInterface $container): self $container->get('theme_handler'), $container->get('string_translation'), $container->get('extension.list.module'), + $container->get('extension.list.theme') ); if ($container->has('config.import_transformer')) { @@ -240,7 +248,8 @@ public function doImport($storage_comparer): void $this->getModuleInstaller(), $this->getThemeHandler(), $this->getStringTranslation(), - $this->getModuleExtensionList() + $this->getModuleExtensionList(), + $this->getThemeExtensionList() ); if ($config_importer->alreadyImporting()) { $this->logger()->warning('Another request may be synchronizing configuration already.'); diff --git a/src/Commands/core/DeployCommands.php b/src/Commands/core/DeployCommands.php index 24a93a4b1e..3f1c284da0 100644 --- a/src/Commands/core/DeployCommands.php +++ b/src/Commands/core/DeployCommands.php @@ -6,13 +6,13 @@ use Consolidation\SiteAlias\SiteAlias; use Consolidation\SiteAlias\SiteAliasManagerInterface; -use Consolidation\SiteProcess\ProcessManager; use Drush\Attributes as CLI; use Drush\Boot\DrupalBootLevels; use Drush\Commands\AutowireTrait; use Drush\Commands\config\ConfigImportCommands; use Drush\Commands\DrushCommands; use Drush\Drush; +use Drush\SiteAlias\ProcessManager; #[CLI\Bootstrap(DrupalBootLevels::NONE)] final class DeployCommands extends DrushCommands diff --git a/src/Commands/core/EntityCreateCommands.php b/src/Commands/core/EntityCreateCommands.php index 5747e4dc3f..41e9a6de72 100644 --- a/src/Commands/core/EntityCreateCommands.php +++ b/src/Commands/core/EntityCreateCommands.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityConstraintViolationListInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Session\AccountSwitcherInterface; @@ -56,6 +55,7 @@ public function __construct( public function createEntity(string $entity_type, $bundle, array $options = ['validate' => true, 'uid' => self::REQ, 'skip-fields' => self::REQ]): string { $bundleKey = $this->entityTypeManager->getDefinition($entity_type)->getKey('bundle'); + /** @var ContentEntityInterface $entity */ $entity = $this->entityTypeManager->getStorage($entity_type)->create([$bundleKey => $bundle]); $instances = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle); $skip_fields = StringUtils::csvToArray($options['skip-fields']); @@ -211,7 +211,7 @@ private function filterViolations(EntityConstraintViolationListInterface &$viola } } - protected function setValue(EntityInterface $entity, int|string $name, mixed $value): void + protected function setValue(ContentEntityInterface $entity, int|string $name, mixed $value): void { switch ($entity->get($name)->getFieldDefinition()->getType()) { case 'timestamp': diff --git a/src/Commands/core/MigrateRunnerCommands.php b/src/Commands/core/MigrateRunnerCommands.php index 2c9a002084..03d6de343e 100644 --- a/src/Commands/core/MigrateRunnerCommands.php +++ b/src/Commands/core/MigrateRunnerCommands.php @@ -4,7 +4,6 @@ namespace Drush\Commands\core; -use Drush\Drupal\Migrate\ValidateMigrationId; use Consolidation\AnnotatedCommand\CommandData; use Consolidation\AnnotatedCommand\CommandError; use Consolidation\AnnotatedCommand\Hooks\HookManager; @@ -22,10 +21,10 @@ use Drush\Attributes as CLI; use Drush\Commands\AutowireTrait; use Drush\Commands\DrushCommands; -use Drush\Drupal\Migrate; use Drush\Drupal\Migrate\MigrateExecutable; use Drush\Drupal\Migrate\MigrateMessage; use Drush\Drupal\Migrate\MigrateUtils; +use Drush\Drupal\Migrate\ValidateMigrationId; use Drush\Drush; use Drush\Utils\StringUtils; use Symfony\Component\DependencyInjection\Attribute\Autowire; @@ -202,7 +201,7 @@ protected function getMigrationSourceRowsCount(MigrationInterface $migration): ? * @param MigrationInterface $migration * The migration plugin instance. * - * @return int|null + * @return int * The number of items that needs update. */ protected function getMigrationNeedingUpdateCount(MigrationInterface $migration): int diff --git a/src/Commands/core/MkCommands.php b/src/Commands/core/MkCommands.php index 6098ada8e1..8d04eb4ee6 100644 --- a/src/Commands/core/MkCommands.php +++ b/src/Commands/core/MkCommands.php @@ -113,6 +113,7 @@ protected static function appendTopics(AnnotatedCommand $command, string $dir_co $body = "#### Topics\n\n"; foreach ($topics as $name) { $value = "- `drush $name`\n"; + /** @var AnnotatedCommand $topic_command */ $topic_command = Drush::getApplication()->find($name); $topic_description = $topic_command->getDescription(); if ($docs_relative = $topic_command->getAnnotationData()->get('topic')) { diff --git a/src/Commands/core/WatchdogCommands.php b/src/Commands/core/WatchdogCommands.php index 8758579586..39f736ffee 100644 --- a/src/Commands/core/WatchdogCommands.php +++ b/src/Commands/core/WatchdogCommands.php @@ -348,7 +348,7 @@ protected function where(?string $type = null, $severity = null, ?string $filter * A database result object. * @param $extended * Return extended message details. - * @return + * @return \stdClass * The result object with some attributes themed. */ protected function formatResult(\stdClass $result, bool $extended = false): \stdClass diff --git a/src/Commands/help/ListCommands.php b/src/Commands/help/ListCommands.php index 91e06ca4c9..10b9c37c5d 100644 --- a/src/Commands/help/ListCommands.php +++ b/src/Commands/help/ListCommands.php @@ -67,10 +67,12 @@ public function helpList($options = ['format' => 'listcli', 'raw' => false, 'fil return null; } elseif ($options['format'] == 'xml') { $descriptor = new XmlDescriptor(); - return $descriptor->describe($this->output, $application, []); + $descriptor->describe($this->output, $application, []); + return null; } elseif ($options['format'] == 'json') { $descriptor = new JsonDescriptor(); - return $descriptor->describe($this->output, $application, []); + $descriptor->describe($this->output, $application, []); + return null; } else { // No longer used. Works for XML, but gives error for JSON. // $dom = $this->buildDom($namespaced, $application); diff --git a/src/Config/ConfigLocator.php b/src/Config/ConfigLocator.php index 01e7f4630c..1458533975 100644 --- a/src/Config/ConfigLocator.php +++ b/src/Config/ConfigLocator.php @@ -5,11 +5,10 @@ namespace Drush\Config; use Consolidation\Config\ConfigInterface; -use Robo\Config\Config; use Consolidation\Config\Loader\ConfigLoaderInterface; -use Drush\Config\Loader\YamlConfigLoader; use Consolidation\Config\Loader\ConfigProcessor; use Consolidation\Config\Util\EnvConfig; +use Drush\Config\Loader\YamlConfigLoader; use Symfony\Component\Filesystem\Path; /** @@ -192,8 +191,6 @@ public function config(): ConfigInterface * it to the configuration. The Environment object itself is only * available during preflight; the information exported here may be * obtained by commands et. al. as needed. @see Environment::exportConfigData() - * - * @param Environment $environent */ public function addEnvironment(Environment $environment): self { @@ -203,10 +200,8 @@ public function addEnvironment(Environment $environment): self /** * Add config paths defined in preflight configuration. - * - * @param array $paths */ - public function addPreflightConfigFiles($filepaths): self + public function addPreflightConfigFiles(array $filepaths): self { $this->addConfigPaths(self::PREFLIGHT_CONTEXT, (array) $filepaths); return $this; @@ -253,10 +248,8 @@ public function addDrushConfig(string $drushProjectDir): self /** * Add any configuration files found around the Drupal root of the * selected site. - * - * @param Path to the selected Drupal site */ - public function addSitewideConfig($siteRoot): ?self + public function addSitewideConfig(string $siteRoot): ?self { // There might not be a site. if (!is_dir($siteRoot)) { @@ -503,8 +496,8 @@ function ($item) use ($prefix) { * @param array $candidates * An array filenames that are considered config files. * - * @return - * An array whose first item is an array of files, and the second item is an + * @return array + * The first item is an array of files, and the second item is an * array of dirs. */ protected function findConfigFiles(array $paths, array $candidates): array @@ -538,7 +531,7 @@ protected function findConfigFiles(array $paths, array $candidates): array * @param $siteConfig * The site-specific config file. * - * @return + * @return bool * Whether the config exists and was processed. */ public static function addSiteSpecificConfig(DrushConfig $config, $siteConfig): bool diff --git a/src/Drush.php b/src/Drush.php index 3ca549f651..7ac08e2699 100644 --- a/src/Drush.php +++ b/src/Drush.php @@ -10,8 +10,8 @@ use Consolidation\SiteAlias\SiteAliasManager; use Consolidation\SiteProcess\ProcessBase; use Consolidation\SiteProcess\SiteProcess; -use Drush\Boot\Boot; use Drush\Boot\BootstrapManager; +use Drush\Boot\DrupalBoot8; use Drush\Config\DrushConfig; use Drush\Preflight\PreflightArgs; use Drush\Runtime\DependencyInjection; @@ -360,10 +360,10 @@ public static function process($commandline, $cwd = null, $env = null, $input = * @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * - * @return + * @return ProcessBase * A wrapper around Symfony Process. */ - public static function shell(string $command, $cwd = null, ?array $env = null, $input = null, $timeout = 60): ProcessBase + public static function shell(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, int|float|null $timeout = 60): ProcessBase { return self::processManager()->shell($command, $cwd, $env, $input, $timeout); } @@ -433,7 +433,7 @@ public static function bootstrapManager(): BootstrapManager /** * Return the Bootstrap object. */ - public static function bootstrap(): Boot + public static function bootstrap(): DrupalBoot8 { return self::bootstrapManager()->bootstrap(); } diff --git a/src/Exec/ExecTrait.php b/src/Exec/ExecTrait.php index e2c11a70d6..2eb84c7149 100644 --- a/src/Exec/ExecTrait.php +++ b/src/Exec/ExecTrait.php @@ -21,7 +21,7 @@ trait ExecTrait * Optional URI or site path to open in browser. If omitted, or if a site path * is specified, the current site home page uri will be prepended if the site's * hostname resolves. - * @return + * @return bool * TRUE if browser was opened. FALSE if browser was disabled by the user or a * default browser could not be found. */ diff --git a/src/Preflight/ArgsPreprocessor.php b/src/Preflight/ArgsPreprocessor.php index e71fd346fc..feaaf1af8f 100644 --- a/src/Preflight/ArgsPreprocessor.php +++ b/src/Preflight/ArgsPreprocessor.php @@ -126,7 +126,8 @@ protected function isAliasOrSiteSpec(string $arg): bool * @param $optionsTable Table of option names and the name of the * method that should be called to process that option. * @param $opt The option string to check - * @return [$methodName, $optionValue, $acceptsValueFromNextArg] + * @return array + * [$methodName, $optionValue, $acceptsValueFromNextArg] */ protected function findMethodForOptionWithValues(array $optionsTable, string $opt): array { @@ -156,7 +157,8 @@ protected function findMethodForOptionWithValues(array $optionsTable, string $op * '--'. If $key ends with '=', then the option must have a value. * Otherwise, it cannot be supplied with a value, and always defaults * to 'true'. - * @return [$methodName, $optionValue, $acceptsValueFromNextArg] + * @return array + * [$methodName, $optionValue, $acceptsValueFromNextArg] */ protected function checkMatchingOption(string $opt, string $keyParam, string $methodName): array { diff --git a/src/Preflight/PreflightArgs.php b/src/Preflight/PreflightArgs.php index bb96298498..57f98af0cb 100644 --- a/src/Preflight/PreflightArgs.php +++ b/src/Preflight/PreflightArgs.php @@ -4,12 +4,12 @@ namespace Drush\Preflight; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Input\InputInterface; use Consolidation\Config\Config; use Consolidation\Config\ConfigInterface; -use Drush\Utils\StringUtils; use Drush\Symfony\LessStrictArgvInput; +use Drush\Utils\StringUtils; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\InputInterface; /** * Storage for arguments preprocessed during preflight. @@ -399,10 +399,8 @@ public function isSimulated() /** * Set simulated mode - * - * @param bool $simulated */ - public function setSimulate($simulate): self + public function setSimulate(bool $simulate): self { return $this->set(self::SIMULATE, $simulate); } @@ -417,10 +415,8 @@ public function coverageFile() /** * Set the coverage file path. - * - * @param string */ - public function setCoverageFile($coverageFile): self + public function setCoverageFile(string $coverageFile): self { return $this->set(self::COVERAGE_FILE, StringUtils::replaceTilde($coverageFile, $this->homeDir())); } diff --git a/src/Psysh/DrushHelpCommand.php b/src/Psysh/DrushHelpCommand.php index 29640623fe..f46bf22724 100644 --- a/src/Psysh/DrushHelpCommand.php +++ b/src/Psysh/DrushHelpCommand.php @@ -6,7 +6,6 @@ use Drush\Commands\DrushCommands; use Psy\Command\Command as BaseCommand; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -26,13 +25,6 @@ class DrushHelpCommand extends BaseCommand */ const PSYSH_CATEGORY = 'PsySH'; - /** - * The currently set subcommand. - * - * @var \Symfony\Component\Console\Command\Command - */ - protected $command; - /** * {@inheritdoc} */ @@ -47,24 +39,12 @@ protected function configure(): void ->setDescription('Show a list of commands. Type `help [foo]` for information about [foo].'); } - /** - * Helper for setting a subcommand to retrieve help for. - */ - public function setCommand(Command $command): void - { - $this->command = $command; - } - /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output): int { - if ($this->command !== null) { - // Help for an individual command. - $output->page($this->command->asText()); - $this->command = null; - } elseif ($name = $input->getArgument('command_name')) { + if ($name = $input->getArgument('command_name')) { // Help for an individual command. $output->page($this->getApplication()->get($name)->asText()); } else { diff --git a/src/Psysh/Shell.php b/src/Psysh/Shell.php index 113e6cd2d9..25e3db55e6 100644 --- a/src/Psysh/Shell.php +++ b/src/Psysh/Shell.php @@ -5,21 +5,20 @@ namespace Drush\Psysh; use Psy\Shell as BaseShell; +use Symfony\Component\Console\Command\Command as BaseCommand; use Symfony\Component\Console\Input\StringInput; class Shell extends BaseShell { /** * Get a command (if one exists) for the current input string. - * - * - * @return null|string */ - protected function getCommand(string $input) + protected function getCommand(string $input): ?BaseCommand { if ($name = $this->getCommandFromInput($input)) { return $this->get($name); } + return null; } /** diff --git a/src/Runtime/LegacyServiceInstantiator.php b/src/Runtime/LegacyServiceInstantiator.php index 5ac4dd96c8..5962576cc7 100644 --- a/src/Runtime/LegacyServiceInstantiator.php +++ b/src/Runtime/LegacyServiceInstantiator.php @@ -4,17 +4,11 @@ namespace Drush\Runtime; -use Drush\Log\Logger; use League\Container\Container; -use Drush\Drush; -use Symfony\Component\Console\Application; -use Composer\Autoload\ClassLoader; -use Drush\Command\DrushCommandInfoAlterer; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\Yaml\Yaml; -use Robo\Robo; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; +use Symfony\Component\Yaml\Yaml; /** * Use the Symfony Dependency Injection Container to instantiate services. @@ -109,7 +103,7 @@ protected function allServicesHaveClassElement(string $serviceFile, array $servi * The services created may be retrieved via the `taggedServices()` * method. * - * @param array $serviceFiles List of drush.services.yml files + * @param array $services List of drush services */ public function instantiateServices(array $services) { @@ -159,12 +153,12 @@ public function taggedServices($tagName) * * @param string $class Class containing implementation * @param string[] $arguments Parameters to class constructor - * @param array Method names and arguments to call after object is instantiated + * @param array $calls Method names and arguments to call after object is instantiated * * @return object * Instantiated command handler from the service file */ - public function create($class, array $arguments, array $calls) + public function create(string $class, array $arguments, array $calls) { $instance = $this->instantiateObject($class, $arguments); foreach ($calls as $callInfo) { @@ -222,7 +216,7 @@ protected function resolveArguments(array $arguments) * Look up one argument in the appropriate container, or * return it as-is. * - * @param array $argument Argument to resolve + * @param array $arg Argument to resolve * * @return object * Argument after it has been resolved by DI container @@ -265,7 +259,8 @@ protected function resolveArgument($arg) * @param Container $container Drupal DI container * @param string $arg Argument to resolve * - * @param object Resolved object from DI container + * @return object + * Resolved object from DI container */ protected function resolveFromContainer($container, string $arg) { @@ -307,12 +302,12 @@ protected function isRequired(string $arg) * resolved. `set` methods with non-required DI container references * are not called at all if the optional references are not in the container. * - * @param string $arg Name of reference + * @param array $args Names of references * * @return bool * True if at least one argument is not empty */ - protected function atLeastOneValue($args) + protected function atLeastOneValue(array $args): bool { foreach ($args as $arg) { if ($arg) { diff --git a/src/Runtime/ServiceManager.php b/src/Runtime/ServiceManager.php index 13b0a8a783..24e8bcb50a 100644 --- a/src/Runtime/ServiceManager.php +++ b/src/Runtime/ServiceManager.php @@ -22,12 +22,13 @@ use Grasmash\YamlCli\Command\UnsetKeyCommand; use Grasmash\YamlCli\Command\UpdateKeyCommand; use Grasmash\YamlCli\Command\UpdateValueCommand; -use Psr\Container\ContainerInterface as DrushContainer; +use League\Container\Container as DrushContainer; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Robo\ClassDiscovery\RelativeNamespaceDiscovery; use Robo\Contract\ConfigAwareInterface; use Robo\Contract\OutputAwareInterface; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputAwareInterface; /** @@ -63,7 +64,7 @@ public function __construct( * Ensure that any discovered class that is not part of the autoloader * is, in fact, included. * - * @param array Associative array mapping path => class. + * @param array $commandClasses Associative array mapping path => class. */ protected function loadCommandClasses(array $commandClasses): void { @@ -296,7 +297,6 @@ public function instantiateYamlCliCommands(): array * instantiate it via 'new $class' * * @param string[] $bootstrapCommandClasses Classes to instantiate. - * @param Drupal\Component\DependencyInjection\ContainerInterface $container * * @return object[] * List of instantiated service objects