Skip to content

Commit

Permalink
Merge pull request #119 from acelaya-forks/feature/php-8
Browse files Browse the repository at this point in the history
Dropped support for PHP 7.4, and added experimental builds on PHP 8.1
  • Loading branch information
acelaya authored Aug 1, 2021
2 parents fa6a4ca + 041b1de commit 0ddcc3d
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 84 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -46,7 +46,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4', '8.0']
php-version: ['8.0', '8.1']
continue-on-error: ${{ matrix.php-version == '8.1' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -56,9 +57,9 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: composer
coverage: none
- if: ${{ matrix.php-version == '8.0' }}
- if: ${{ matrix.php-version == '8.1' }}
run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
- if: ${{ matrix.php-version != '8.0' }}
- if: ${{ matrix.php-version != '8.1' }}
run: composer install --no-interaction --prefer-dist
- run: composer test:ci
- uses: actions/upload-artifact@v2
Expand All @@ -72,7 +73,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4', '8.0']
php-version: ['8.0', '8.1']
continue-on-error: ${{ matrix.php-version == '8.1' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -82,9 +84,9 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: composer
coverage: none
- if: ${{ matrix.php-version == '8.0' }}
- if: ${{ matrix.php-version == '8.1' }}
run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
- if: ${{ matrix.php-version != '8.0' }}
- if: ${{ matrix.php-version != '8.1' }}
run: composer install --no-interaction --prefer-dist
- uses: actions/download-artifact@v2
with:
Expand All @@ -98,7 +100,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -123,7 +125,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ['7.4', '8.0']
php-version: ['8.0', '8.1']
steps:
- uses: geekyeggo/delete-artifact@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* [#115](https://github.com/shlinkio/shlink-installer/issues/115) Added support for `append_extra_path` config option.

### Changed
* *Nothing*
* [#117](https://github.com/shlinkio/shlink-installer/issues/117) Added experimental builds under PHP 8.1
* [#120](https://github.com/shlinkio/shlink-installer/issues/120) Increased required PHPStan level to 8.

### Deprecated
* *Nothing*

### Removed
* *Nothing*
* [#118](https://github.com/shlinkio/shlink-installer/issues/118) Dropped support for PHP 7.4

### Fixed
* *Nothing*
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"laminas/laminas-config": "^3.2",
"laminas/laminas-config-aggregator": "^1.2",
"laminas/laminas-servicemanager": "^3.4",
"laminas/laminas-stdlib": "^3.2",
"php": "^8.0",
"laminas/laminas-config": "^3.5",
"laminas/laminas-config-aggregator": "^1.5",
"laminas/laminas-servicemanager": "^3.7",
"laminas/laminas-stdlib": "^3.4",
"lstrojny/functional-php": "^1.17",
"shlinkio/shlink-config": "^1.2",
"symfony/console": "^5.2",
"symfony/filesystem": "^5.2",
"symfony/process": "^5.2"
"symfony/console": "^5.3",
"symfony/filesystem": "^5.3",
"symfony/process": "^5.3"
},
"require-dev": {
"devster/ubench": "^2.0",
"infection/infection": "^0.23.0",
"infection/infection": "^0.24.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12.52",
"phpstan/phpstan": "^0.12.92",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.1.1",
"symfony/var-dumper": "^5.2"
"symfony/var-dumper": "^5.3"
},
"autoload": {
"psr-4": {
Expand All @@ -52,11 +52,11 @@
],
"cs": "phpcs",
"cs:fix": "phpcbf",
"stan": "phpstan analyse src --level=7",
"stan": "phpstan analyse src --level=8",
"test": "phpdbg -qrr vendor/bin/phpunit --order-by=random --testdox --colors=always",
"test:ci": "@test --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/junit.xml",
"test:pretty": "@test --coverage-html build/coverage-html",
"infect": "infection --threads=4 --min-msi=90 --log-verbosity=default --only-covered",
"infect": "infection --threads=4 --min-msi=90 --log-verbosity=default --only-covered --only-covering-test-cases",
"infect:ci": "@infect --coverage=build --skip-initial-tests",
"infect:show": "@infect --show-mutations",
"infect:show:ci": "@infect --show-mutations --coverage=build",
Expand Down
17 changes: 4 additions & 13 deletions src/Command/AbstractInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@

abstract class AbstractInstallCommand extends Command
{
private WriterInterface $configWriter;
private ShlinkAssetsHandlerInterface $assetsHandler;
private ConfigGeneratorInterface $configGenerator;
private InstallationCommandsRunnerInterface $commandsRunner;

public function __construct(
WriterInterface $configWriter,
ShlinkAssetsHandlerInterface $assetsHandler,
ConfigGeneratorInterface $configGenerator,
InstallationCommandsRunnerInterface $commandsRunner
private WriterInterface $configWriter,
private ShlinkAssetsHandlerInterface $assetsHandler,
private ConfigGeneratorInterface $configGenerator,
private InstallationCommandsRunnerInterface $commandsRunner
) {
parent::__construct();
$this->configWriter = $configWriter;
$this->assetsHandler = $assetsHandler;
$this->configGenerator = $configGenerator;
$this->commandsRunner = $commandsRunner;
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
16 changes: 4 additions & 12 deletions src/Command/SetOptionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,18 @@ class SetOptionCommand extends Command
{
public const NAME = 'set-option';

private WriterInterface $configWriter;
private ShlinkAssetsHandlerInterface $assetsHandler;
private ConfigOptionsManagerInterface $optionsManager;
private Filesystem $filesystem;
private array $groups;
private string $generatedConfigPath;

public function __construct(
WriterInterface $configWriter,
ShlinkAssetsHandlerInterface $assetsHandler,
ConfigOptionsManagerInterface $optionsManager,
Filesystem $filesystem,
private WriterInterface $configWriter,
private ShlinkAssetsHandlerInterface $assetsHandler,
private ConfigOptionsManagerInterface $optionsManager,
private Filesystem $filesystem,
array $groups,
?array $enabledOptions
) {
parent::__construct();
$this->configWriter = $configWriter;
$this->assetsHandler = $assetsHandler;
$this->optionsManager = $optionsManager;
$this->filesystem = $filesystem;
$this->groups = array_filter(
iterator_to_array($this->flattenGroupsWithTitle($groups)),
static fn (string $configOption) => $enabledOptions === null || contains($enabledOptions, $configOption),
Expand Down
13 changes: 3 additions & 10 deletions src/Config/ConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@

class ConfigGenerator implements ConfigGeneratorInterface
{
private ConfigOptionsManagerInterface $configOptionsManager;
private array $configOptionsGroups;
private ?array $enabledOptions;

public function __construct(
ConfigOptionsManagerInterface $configOptionsManager,
array $configOptionsGroups,
?array $enabledOptions
private ConfigOptionsManagerInterface $configOptionsManager,
private array $configOptionsGroups,
private ?array $enabledOptions
) {
$this->configOptionsManager = $configOptionsManager;
$this->configOptionsGroups = $configOptionsGroups;
$this->enabledOptions = $enabledOptions;
}

public function generateConfigInteractively(StyleInterface $io, array $previousConfig): PathCollection
Expand Down
5 changes: 4 additions & 1 deletion src/Factory/ApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public function __invoke(ContainerInterface $container, string $requestedName, ?
{
$defaultCommand = $options['command'] ?? null;
$commandMap = $container->get('config')['installer']['commands'] ?? [];
$app = new Application('Shlink installer', InstalledVersions::getVersion('shlinkio/shlink-installer'));
$app = new Application(
'Shlink installer',
InstalledVersions::getPrettyVersion('shlinkio/shlink-installer') ?? '',
);

$app->setCommandLoader(new ContainerCommandLoader($container, $commandMap));
if ($defaultCommand !== null) {
Expand Down
7 changes: 1 addition & 6 deletions src/Model/ImportedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

final class ImportedConfig
{
private string $importPath;
private array $importedConfig;

private function __construct(string $importPath, array $importedConfig)
private function __construct(private string $importPath, private array $importedConfig)
{
$this->importPath = $importPath;
$this->importedConfig = $importedConfig;
}

public static function notImported(): self
Expand Down
11 changes: 5 additions & 6 deletions src/Service/InstallationCommandsRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

class InstallationCommandsRunner implements InstallationCommandsRunnerInterface
{
private ProcessHelper $processHelper;
private array $commandsMapping;
private string $phpBinary;

public function __construct(ProcessHelper $processHelper, PhpExecutableFinder $phpFinder, array $commandsMapping)
{
$this->processHelper = $processHelper;
$this->commandsMapping = $commandsMapping;
public function __construct(
private ProcessHelper $processHelper,
PhpExecutableFinder $phpFinder,
private array $commandsMapping
) {
$this->phpBinary = $phpFinder->find(false) ?: 'php';
}

Expand Down
7 changes: 2 additions & 5 deletions src/Service/ShlinkAssetsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ class ShlinkAssetsHandler implements ShlinkAssetsHandlerInterface
private const SQLITE_DB_PATH = 'data/database.sqlite';
private const GEO_LITE_DB_PATH = 'data/GeoLite2-City.mmdb';

private Filesystem $filesystem;

public function __construct(Filesystem $filesystem)
public function __construct(private Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}

/**
Expand Down Expand Up @@ -111,7 +108,7 @@ private function importGeoLiteDbIfNeeded(StyleInterface $io, string $fileToImpor

try {
$this->filesystem->copy($fileToImport, self::GEO_LITE_DB_PATH);
} catch (IOException $e) {
} catch (IOException) {
$io->note('It was not possible to import GeoLite db. Skipping and letting regular update take care of it.');
}
}
Expand Down
5 changes: 1 addition & 4 deletions test/Config/ConfigGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ public function pluginsAreAskedInProperOrder(): void
ConfigOptionInterface,
DependentConfigOptionInterface
{
/** @var array */
private array $orderedAskedOptions;
private string $regularPluginClass;

public function __construct(array &$orderedAskedOptions, string $regularPluginClass)
public function __construct(array &$orderedAskedOptions, private string $regularPluginClass)
{
$this->orderedAskedOptions = &$orderedAskedOptions;
$this->regularPluginClass = $regularPluginClass;
}

public function getConfigPath(): array
Expand Down
4 changes: 2 additions & 2 deletions test/Service/ShlinkAssetsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Filesystem\Filesystem;

use function Functional\each;
use function strpos;
use function str_starts_with;

class ShlinkAssetsHandlerTest extends TestCase
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public function configIsImportedOnlyIfExistingPathIsProvided(bool $exists): void
$confirm = $this->io->confirm(Argument::any())->will(function (array $args) use (&$count) {
[$argument] = $args;

if (strpos($argument, 'Do you want to import configuration from previous installation?') === 0) {
if (str_starts_with($argument, 'Do you want to import configuration from previous installation?')) {
return true;
}

Expand Down

0 comments on commit 0ddcc3d

Please sign in to comment.