Skip to content

Commit

Permalink
LCH-6217: Fix PHP8 deprecations, remove 7.4 job and include 8.1 job i…
Browse files Browse the repository at this point in the history
…n GA. (#50)

* LCH-6217: Fix PHP8 deprecations and include 8.1 job in GA.

* LCH-7217: Change function declaration.

* LCH-6217: Make container.php compatible with v6 symfony.

* LCH-6217: Change minimum PHP version to 8.1 in composer.json.

* LCH-6217: Remove 7.4 job from GA.

* LCH-6217: Fix null entry to Input.php
  • Loading branch information
amangrover90 authored Oct 19, 2022
1 parent 13763f8 commit f5987a1
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/common-console-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commoncli.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ services:
# Platform Bootstraps
bootstrap.drupal:
class: EclipseGc\CommonConsole\EventSubscriber\Bootstrap\Drupal
arguments: ['%autoloader%']
arguments: ['@autoloader']
tags:
- { name: kernel.event_subscriber }

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion includes/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/Event/PlatformArgumentInjectionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"] = '';
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/EventSubscriber/ConsoleCommand/AliasFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/OutputFormatter/BareOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setDecorated($decorated) {
/**
* {@inheritDoc}
*/
public function isDecorated() {
public function isDecorated(): bool {
return FALSE;
}

Expand All @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/ServicesFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -66,7 +66,7 @@ public function load($resource, $type = NULL) {

// Empty file.
if (NULL === $content) {
return;
return NULL;
}

// Imports.
Expand Down Expand Up @@ -101,6 +101,7 @@ public function load($resource, $type = NULL) {
}
}
}
return NULL;
}

}
14 changes: 7 additions & 7 deletions tests/CommonConsoleTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -144,7 +144,7 @@ public function setDecorated($decorated) {
/**
* isDecorated override.
*/
public function isDecorated() {
public function isDecorated(): bool {
return FALSE;
}

Expand All @@ -156,7 +156,7 @@ public function setFormatter(OutputFormatterInterface $formatter) {}
/**
* getFormatter override.
*/
public function getFormatter() {
public function getFormatter(): OutputFormatterInterface {
return new BareOutputFormatter();
}

Expand Down

0 comments on commit f5987a1

Please sign in to comment.