Skip to content

Commit

Permalink
[TASK] Raise PHP requirements to PHP 7.4.1 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertsoft authored Jan 13, 2022
1 parent a1cef85 commit 3f09964
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/.gitignore export-ignore
/.gitreview export-ignore
/.php_cs.dist export-ignore
/rector.php export-ignore
.gitkeep export-ignore

# Enforce checkout with linux lf consistent over all plattforms
Expand Down
42 changes: 39 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ jobs:
- name: Check dependencies
run: vendor/bin/composer ci:composer:require-checker

yaml_lint:
name: YAML Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: intl, zip
ini-values: memory_limit=-1, error_reporting=E_ALL, display_errors=On
php-version: latest
tools: composer

- name: Composer Cache Vars
id: composer-cache-vars
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "::set-output name=timestamp::$(date +"%s")"
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache-vars.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.composer-cache-vars.outputs.timestamp }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install ${{ env.COMPOSER_FLAGS }}

- name: Lint YAML files
run: vendor/bin/composer ci:yaml:lint

php_lint:
name: PHP Lint
runs-on: ubuntu-latest
Expand All @@ -67,7 +104,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- '7.2'
- '7.4'
- 'latest'
experimental:
- false
Expand Down Expand Up @@ -241,7 +278,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- '7.2'
- '7.4'
- 'latest'
dependencies:
- 'lowest'
Expand Down Expand Up @@ -319,7 +356,6 @@ jobs:
os:
- ubuntu-latest
php-version:
- '7.2'
- '7.4'
- 'latest'
composer-version:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"source": "https://github.com/GsTYPO3/core-patches"
},
"require": {
"php": "^7.2.5 || ^8.0",
"php": "^7.4.1 || ^8.0",
"ext-json": "*",
"composer-plugin-api": "^2.0",
"cweagans/composer-patches": "^1.7"
Expand Down Expand Up @@ -115,6 +115,7 @@
"ci:tests:functional": "echo 'phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-functional.xml --testsuite \"Functional Test Suite\"'",
"ci:tests:smoke": "echo 'phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-unit.xml --testsuite \"Smoke Test Suite\"'",
"ci:tests:unit": "echo 'phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-unit.xml --testsuite \"Unit Test Suite\"'",
"ci:yaml:lint": "yaml-lint .ddev .github",
"clean": [
"@tools:setup:clean",
"rm -fr vendor .php-cs-fixer.cache .phplint-cache composer.lock"
Expand Down Expand Up @@ -201,6 +202,6 @@
"tools:tests:functional": "phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-functional.xml --testsuite \"Functional Test Suite\"",
"tools:tests:smoke": "phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-unit.xml --testsuite \"Smoke Test Suite\"",
"tools:tests:unit": "phpunit -c phpunit.xml.dist --log-junit var/log/phpunit-unit.xml --testsuite \"Unit Test Suite\"",
"tools:yaml:lint": "yaml-lint .ddev"
"tools:yaml:lint": "yaml-lint .ddev .github"
}
}
39 changes: 39 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/*
* This file is part of TYPO3 Core Patches.
*
* (c) Gilbertsoft LLC (gilbertsoft.org)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$parameters->set(Option::BOOTSTRAP_FILES, [
__DIR__ . '/vendor/autoload.php',
]);

// Define what rule sets will be applied
$containerConfigurator->import(LevelSetList::UP_TO_PHP_74);

// get services (needed for register a single rule)
// $services = $containerConfigurator->services();

// register a single rule
// $services->set(TypedPropertyRector::class);
};
2 changes: 1 addition & 1 deletion src/Command/Typo3/Patch/ApplyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function execute(InputInterface $input, OutputInterface $output)

// Get Composer instance
if (!($composer = $this->getComposer(true)) instanceof Composer) {
throw new UnexpectedValueException('Invalid Composer instance.', 1640857365);
throw new UnexpectedValueException('Invalid Composer instance.', 1_640_857_365);
}

$io = $this->getIO();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Typo3/Patch/RemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function execute(InputInterface $input, OutputInterface $output)

// Get Composer instance
if (!($composer = $this->getComposer(true)) instanceof Composer) {
throw new UnexpectedValueException('Invalid Composer instance.', 1640857366);
throw new UnexpectedValueException('Invalid Composer instance.', 1_640_857_366);
}

$io = $this->getIO();
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\Capability\CommandProvider as ComposerCommandProvider;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;

Expand Down Expand Up @@ -54,7 +55,7 @@ public function uninstall(Composer $composer, IOInterface $io)
public function getCapabilities()
{
return [
'Composer\Plugin\Capability\CommandProvider' => 'GsTYPO3\CorePatches\CommandProvider',
ComposerCommandProvider::class => CommandProvider::class,
];
}
}
29 changes: 9 additions & 20 deletions src/Utility/ComposerUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ final class ComposerUtils
private const EXTRA_APPLIED_CHANGES = 'applied-changes';
private const EXTRA_PREFERRED_INSTALL_CHANGED = 'preferred-install-changed';

/** @var Composer */
private $composer;
/** @var IOInterface */
private $io;
/** @var Application */
private $application;
/** @var JsonFile */
private $configFile;
/** @var JsonConfigSource */
private $configSource;
private Composer $composer;
private IOInterface $io;
private Application $application;
private JsonFile $configFile;
private JsonConfigSource $configSource;

public function __construct(Composer $composer, IOInterface $io)
{
Expand Down Expand Up @@ -216,9 +211,7 @@ private function removeAppliedChange(int $numericId): void
return;
}

$currentValue = array_filter($currentValue, function ($value) use ($numericId) {
return $value !== $numericId;
});
$currentValue = array_filter($currentValue, fn ($value) => $value !== $numericId);
sort($currentValue);

$this->configSource->addProperty(
Expand Down Expand Up @@ -262,9 +255,7 @@ private function removePreferredInstallChanged(string $packageName): void
return;
}

$currentValue = array_filter($currentValue, function ($value) use ($packageName) {
return $value !== $packageName;
});
$currentValue = array_filter($currentValue, fn ($value) => $value !== $packageName);
sort($currentValue);

$this->configSource->addProperty(
Expand Down Expand Up @@ -347,7 +338,7 @@ public function addPatches(array $changeIds, string $destination, bool $includeT
$this->addPatchesToConfigFile($patches);
$this->addAppliedChange($numericId);

$affectedPackages = array_merge($affectedPackages, array_keys($patches));
$affectedPackages = [...$affectedPackages, ...array_keys($patches)];

$patchesCount += $patchesCreated;
}
Expand Down Expand Up @@ -377,9 +368,7 @@ public function addPatches(array $changeIds, string $destination, bool $includeT
$promises[] = $this->uninstallPackage($package);

// Remove package from the array
$affectedPackages = array_filter($affectedPackages, function ($value) use ($packageName) {
return $value !== $packageName;
});
$affectedPackages = array_filter($affectedPackages, fn ($value) => $value !== $packageName);
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/Utility/GerritUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ final class GerritUtils
{
private const BASE_URL = 'https://review.typo3.org/';

/** @var HttpDownloader */
private $downloader;
private HttpDownloader $downloader;
/** @var array<string, array<string, mixed>>|null */
private $changeInfo;
private ?array $changeInfo = null;

/**
* @param HttpDownloader $downloader A HttpDownloader instance
Expand Down Expand Up @@ -68,10 +67,10 @@ public function getChange(string $changeId): array
$body = substr($body, 4);
}

$changeInfo = json_decode(trim($body), true);
$changeInfo = json_decode(trim($body), true, 512, JSON_THROW_ON_ERROR);

if ($changeInfo === null || !is_array($changeInfo)) {
throw new InvalidResponseException('Error invalid response.', 1640784346);
throw new InvalidResponseException('Error invalid response.');
}
$this->changeInfo[$changeId] = $changeInfo;
}
Expand All @@ -93,11 +92,11 @@ public function getSubject(string $changeId): string
$changeInfo = $this->getChange($changeId);

if (!is_string($subject = ($changeInfo['subject'] ?? null))) {
throw new UnexpectedValueException('Subject was not found.', 1640944473);
throw new UnexpectedValueException('Subject was not found.');
}

if (($normalizedSubject = preg_replace('/^\[.+?\] /', '', $subject)) === null) {
throw new UnexpectedValueException(sprintf('Subject "%s" could not be normalized.', $subject), 1640944474);
throw new UnexpectedValueException(sprintf('Subject "%s" could not be normalized.', $subject));
}

return $normalizedSubject;
Expand All @@ -117,7 +116,7 @@ public function getNumericId(string $changeId): int
$changeInfo = $this->getChange($changeId);

if (!is_int($numericId = ($changeInfo['_number'] ?? null))) {
throw new UnexpectedValueException('Number was not found.', 1640944475);
throw new UnexpectedValueException('Number was not found.');
}

return $numericId;
Expand Down
6 changes: 2 additions & 4 deletions src/Utility/PatchUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

final class PatchUtils
{
/** @var Composer */
private $composer;
/** @var IOInterface */
private $io;
private Composer $composer;
private IOInterface $io;

public function __construct(Composer $composer, IOInterface $io)
{
Expand Down

0 comments on commit 3f09964

Please sign in to comment.