diff --git a/.github/workflows/common-console-actions.yml b/.github/workflows/common-console-actions.yml index 89f88cb..399c525 100644 --- a/.github/workflows/common-console-actions.yml +++ b/.github/workflows/common-console-actions.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - php-version: [ '7.4' ] + php-version: [ '8.1' ] steps: # This step checks out a copy of your repository. - name: Checkout diff --git a/commoncli.services.yml b/commoncli.services.yml index 82f9276..0330696 100644 --- a/commoncli.services.yml +++ b/commoncli.services.yml @@ -90,7 +90,7 @@ services: # Platform Bootstraps bootstrap.drupal: class: EclipseGc\CommonConsole\EventSubscriber\Bootstrap\Drupal - arguments: ['%autoloader%'] + arguments: ['@autoloader'] tags: - { name: kernel.event_subscriber } diff --git a/composer.json b/composer.json index 0f24ff7..c1c3309 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "symfony/filesystem": ">=4.4", "symfony/process": ">=4.4", "symfony/yaml": ">=4.4", - "php": ">=7.3", + "php": ">=8.1", "ext-json": "*" }, "require-dev": { diff --git a/includes/container.php b/includes/container.php index d703f31..69bba58 100644 --- a/includes/container.php +++ b/includes/container.php @@ -61,7 +61,7 @@ public function getContainer() { $locations = array_merge($this->getComposerDirs(), $this->getInstalledDirectories()); $loader = new ServicesFileLoader($container, new FileLocator($locations)); $loader->load('commoncli.services.yml'); - $container->setParameter('autoloader', $this->autoloader); + $container->set('autoloader', $this->autoloader); $container->setParameter('autoload.file', $this->autoloaderFile); $container->addCompilerPass(new RegisterListenersPass()); $container->addCompilerPass(new CommandCompilerPass()); diff --git a/src/Event/PlatformArgumentInjectionEvent.php b/src/Event/PlatformArgumentInjectionEvent.php index eccebf5..00b0ff4 100644 --- a/src/Event/PlatformArgumentInjectionEvent.php +++ b/src/Event/PlatformArgumentInjectionEvent.php @@ -125,6 +125,7 @@ public function getDecoratedInput(): array { */ public function setDecoratedInput(array $arguments): void { $args = $this->input->getArguments(); + unset($args['alias']); $options = $this->input->getOptions(); $definition = $this->command->getDefinition(); foreach ($options as $key => $val) { @@ -136,7 +137,7 @@ public function setDecoratedInput(array $arguments): void { else { // Insert the option into the array IF it was actually used. if ((bool) $val === TRUE) { - $options["--$key"] = NULL; + $options["--$key"] = ''; } } diff --git a/src/EventSubscriber/ConsoleCommand/AliasFinder.php b/src/EventSubscriber/ConsoleCommand/AliasFinder.php index d9a4e47..9f7ed3f 100644 --- a/src/EventSubscriber/ConsoleCommand/AliasFinder.php +++ b/src/EventSubscriber/ConsoleCommand/AliasFinder.php @@ -59,7 +59,7 @@ public function onConsoleCommand(ConsoleCommandEvent $event): void { $command = $event->getCommand(); $platform_input = $this->getPlatformInput($input); foreach ($input->getArguments() as $name => $argument) { - if (preg_match(self::ALIAS_PATTERN, $argument)) { + if (preg_match(self::ALIAS_PATTERN, $argument ?? '')) { $alias = substr($argument, 1); $findAliasEvent = new FindAliasEvent($alias, $event); $this->dispatcher->dispatch($findAliasEvent, CommonConsoleEvents::ALIAS_FIND); @@ -100,7 +100,7 @@ protected function getPlatformInput(InputInterface $input) { $definition = $property->getValue($input); $arrayInput = ['command' => $input->getArgument('command')]; foreach ($input->getArguments() as $key => $argument) { - if (preg_match(self::ALIAS_PATTERN, $argument)) { + if (preg_match(self::ALIAS_PATTERN, $argument ?? '')) { continue; } $arrayInput[$key] = $argument; diff --git a/src/OutputFormatter/BareOutputFormatter.php b/src/OutputFormatter/BareOutputFormatter.php index 4784ac7..50e6a05 100644 --- a/src/OutputFormatter/BareOutputFormatter.php +++ b/src/OutputFormatter/BareOutputFormatter.php @@ -21,7 +21,7 @@ public function setDecorated($decorated) { /** * {@inheritDoc} */ - public function isDecorated() { + public function isDecorated(): bool { return FALSE; } @@ -35,21 +35,21 @@ public function setStyle($name, OutputFormatterStyleInterface $style) { /** * {@inheritDoc} */ - public function hasStyle($name) { + public function hasStyle($name): bool { return FALSE; } /** * {@inheritDoc} */ - public function getStyle($name) { + public function getStyle($name): OutputFormatterStyleInterface { throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name)); } /** * {@inheritDoc} */ - public function format($message) { + public function format($message): ?string { return $message; } diff --git a/src/ServicesFileLoader.php b/src/ServicesFileLoader.php index c72a2cb..3479768 100644 --- a/src/ServicesFileLoader.php +++ b/src/ServicesFileLoader.php @@ -56,7 +56,7 @@ protected function getPrivateProperty($property, $value) { /** * {@inheritdoc} */ - public function load($resource, $type = NULL) { + public function load(mixed $resource, string $type = NULL): mixed { $paths = $this->locator->locate($resource, NULL, FALSE); foreach ($paths as $path) { @@ -66,7 +66,7 @@ public function load($resource, $type = NULL) { // Empty file. if (NULL === $content) { - return; + return NULL; } // Imports. @@ -101,6 +101,7 @@ public function load($resource, $type = NULL) { } } } + return NULL; } } diff --git a/tests/CommonConsoleTestBase.php b/tests/CommonConsoleTestBase.php index 8615f5a..c4e7da9 100644 --- a/tests/CommonConsoleTestBase.php +++ b/tests/CommonConsoleTestBase.php @@ -102,35 +102,35 @@ public function setVerbosity($level) {} /** * Get verbosity overide. */ - public function getVerbosity() { + public function getVerbosity(): int { return self::VERBOSITY_QUIET; } /** * isQuiet override. */ - public function isQuiet() { + public function isQuiet(): bool { return TRUE; } /** * isVerbose override. */ - public function isVerbose() { + public function isVerbose(): bool { return FALSE; } /** * isVeryVerbose override. */ - public function isVeryVerbose() { + public function isVeryVerbose(): bool { return FALSE; } /** * isDebug override. */ - public function isDebug() { + public function isDebug(): bool { return FALSE; } @@ -144,7 +144,7 @@ public function setDecorated($decorated) { /** * isDecorated override. */ - public function isDecorated() { + public function isDecorated(): bool { return FALSE; } @@ -156,7 +156,7 @@ public function setFormatter(OutputFormatterInterface $formatter) {} /** * getFormatter override. */ - public function getFormatter() { + public function getFormatter(): OutputFormatterInterface { return new BareOutputFormatter(); }