Skip to content

Commit

Permalink
Bump min to PHP 7.2 (#1955)
Browse files Browse the repository at this point in the history
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
  • Loading branch information
TomasVotruba and samsonasik committed Mar 24, 2022
1 parent 6ebf140 commit 278cd56
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_scoped_rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ jobs:
# 3. prefix classes
- run: sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded

# 4. lint the code for PHP 7.1 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
# 4. lint the code for PHP 7.2 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
-
uses: shivammathur/setup-php@v2
with:
php-version: 7.1
php-version: 7.2
coverage: none
- run: composer global require php-parallel-lint/php-parallel-lint
- run: /home/runner/.composer/vendor/bin/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/rector/rector-nette/tests --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/tracy/tracy/examples --exclude rector-prefixed-downgraded/vendor/ssch/typo3-rector/templates/maker --exclude rector-prefixed-downgraded/vendor/symfony/console/Event --exclude rector-prefixed-downgraded/vendor/symfony/console/EventListener --exclude rector-prefixed-downgraded/vendor/symfony/console/Tester --exclude rector-prefixed-downgraded/vendor/rector/rector-generator/templates --exclude rector-prefixed-downgraded/vendor/symfony/contracts/Cache/ItemInterface.php --exclude rector-prefixed-downgraded/vendor/symfony/dependency-injection/ExpressionLanguageProvider.php
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Head to [`rectorphp/rector`](http://github.com/rectorphp/rector) for documentati

## Building `rectorphp/rector`

Code of this repository requires PHP 8. For `rector/rector` package user the build downgrades code to PHP 7.1 and higher.
Code of this repository requires PHP 8. For `rector/rector` package user the build downgrades code to PHP 7.2 and higher.

## How to Contribute

Expand Down
13 changes: 1 addition & 12 deletions build/config/config-downgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

use Rector\Core\Configuration\Option;
use Rector\Core\Stubs\PHPStanStubLoader;
use Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

$phpStanStubLoader = new PHPStanStubLoader();
Expand All @@ -25,15 +22,7 @@
$parameters->set(Option::SKIP, DowngradeRectorConfig::DEPENDENCY_EXCLUDE_PATHS);
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan-for-downgrade.neon');

$containerConfigurator->import(DowngradeLevelSetList::DOWN_TO_PHP_71);

$services = $containerConfigurator->services();

$services->set(DowngradeParameterTypeWideningRector::class)
->configure([
LoaderInterface::class => ['load'],
Loader::class => ['import'],
]);
$containerConfigurator->import(DowngradeLevelSetList::DOWN_TO_PHP_72);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']
commands:
-
name: 'Composer Dependency'
Expand Down
2 changes: 1 addition & 1 deletion build/target-repository/.github/workflows/bare_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion build/target-repository/.github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']
directory:
- 'e2e/attributes'
- 'e2e/define-constant'
Expand Down
2 changes: 1 addition & 1 deletion build/target-repository/.github/workflows/e2e_global.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']
directory:
- 'e2e/global-install'

Expand Down
4 changes: 2 additions & 2 deletions build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"bin/rector"
],
"require": {
"php": "^7.1|^8.0",
"phpstan/phpstan": "^1.4.8"
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.5"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"nikic/php-parser": "^4.13.2",
"ondram/ci-detector": "^4.1",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpstan": "^1.4.8",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-phpunit": "^1.0",
"psr/log": "^2.0",
"react/child-process": "^0.6.4",
Expand Down
22 changes: 11 additions & 11 deletions full_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ sh build/downgrade-rector.sh rector-build

cd rector-build

# avoid syntax error in php 7.1 and 7.2
# avoid syntax error in php 7.2
rm rector.php

cp ../build/target-repository/bootstrap.php .
cp ../preload.php .

# Check php 7.1 can be used locally with PHP71_BIN_PATH env
# Check php 7.2 can be used locally with PHP72_BIN_PATH env
# Prefixing build only works on php < 8.0, can be used locally with PHP80_BIN_PATH env

#
# usage:
#
# export PHP71_BIN_PATH=/opt/homebrew/Cellar/php@7.1/7.1.33_4/bin/php PHP80_BIN_PATH=/opt/homebrew/Cellar/php@8.0/8.0.14/bin/php && sh ./full_build.sh
# export PHP72_BIN_PATH=/opt/homebrew/Cellar/php@7.2/7.2.34_4/bin/php PHP80_BIN_PATH=/opt/homebrew/Cellar/php@8.0/8.0.17/bin/php && sh ./full_build.sh
#
if test -z ${PHP71_BIN_PATH+y}; then
if test -z ${PHP72_BIN_PATH+y}; then
bin/rector list --ansi;
else
echo "verify downgraded rector with specify PHP71_BIN_PATH env";
$PHP71_BIN_PATH bin/rector list --ansi;
echo "verify downgraded rector with specify PHP72_BIN_PATH env";
$PHP72_BIN_PATH bin/rector list --ansi;
fi

cd ..
Expand All @@ -59,16 +59,16 @@ cd rector-prefixed-downgraded
cp ../build/target-repository/bootstrap.php .
cp ../preload.php .

if test -z ${PHP71_BIN_PATH+y}; then
if test -z ${PHP72_BIN_PATH+y}; then
bin/rector list --ansi;
bin/rector process vendor/symfony/string/Slugger/ --dry-run;
else
echo "verify scoped rector with specify PHP71_BIN_PATH env";
$PHP71_BIN_PATH bin/rector list --ansi;
$PHP71_BIN_PATH bin/rector process vendor/symfony/string/Slugger/ --dry-run;
echo "verify scoped rector with specify PHP72_BIN_PATH env";
$PHP72_BIN_PATH bin/rector list --ansi;
$PHP72_BIN_PATH bin/rector process vendor/symfony/string/Slugger/ --dry-run;
fi

cd ..

rm -rf rector-prefixed-downgraded
rm -rf rector-build
rm -rf rector-build
4 changes: 0 additions & 4 deletions src/Stubs/PHPStanStubLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public function loadStubs(): void
continue;
}

if ($vendorPath === '') {
continue;
}

foreach (self::STUBS as $stub) {
$path = $this->getStubPath($vendorPath, $stub);
if ($path === null) {
Expand Down

0 comments on commit 278cd56

Please sign in to comment.