Skip to content

Commit

Permalink
Upgrade Infection to minimum PHP 8.0 using Rector (#1641)
Browse files Browse the repository at this point in the history
* Upgrade Infection to minimum PHP 8.0 using Rector

* Fix e2e tests
  • Loading branch information
maks-rafalko committed Jan 19, 2022
1 parent 07490ad commit 8042277
Show file tree
Hide file tree
Showing 138 changed files with 490 additions and 1,663 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autoreview.yaml
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']

name: Autoreview on PHP ${{ matrix.php-version }}

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -17,12 +17,11 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.4']
php-version: ['8.0']
coverage-driver: [pcov, xdebug]
e2e-runner: ['bin/infection']
include:
- { operating-system: 'windows-latest', php-version: '7.4', coverage-driver: 'xdebug', e2e-runner: 'bin/infection' }
- { operating-system: 'ubuntu-latest', php-version: '7.4', coverage-driver: 'pcov', e2e-runner: 'bin/infection' }
- { operating-system: 'windows-latest', php-version: '8.0', coverage-driver: 'xdebug', e2e-runner: 'bin/infection' }
- { operating-system: 'ubuntu-latest', php-version: '8.0', coverage-driver: 'pcov', e2e-runner: 'build/infection.phar' }
- { operating-system: 'ubuntu-latest', php-version: '8.0', coverage-driver: 'xdebug', e2e-runner: 'build/infection.phar' }
- { operating-system: 'ubuntu-latest', php-version: '8.1', coverage-driver: 'pcov', e2e-runner: 'bin/infection' }
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cs.yaml
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0

- name: Restore PHP-CS-Fixer cache
uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mt-annotations.yaml
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']

name: Mutation Testing Code Review Annotations ${{ matrix.php-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mt.yaml
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.4']
php-version: ['8.0']
coverage-driver: [pcov]

name: Mutation testing on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}
Expand Down
35 changes: 6 additions & 29 deletions Makefile
Expand Up @@ -32,7 +32,6 @@ PARATEST=vendor/bin/paratest --runner=WrapperRunner
INFECTION=./build/infection.phar

DOCKER_RUN=docker-compose run
DOCKER_RUN_74=$(DOCKER_RUN) php74 $(FLOCK) Makefile
DOCKER_RUN_80=$(DOCKER_RUN) php80 $(FLOCK) Makefile
DOCKER_FILE_IMAGE=devTools/Dockerfile.json

Expand All @@ -57,7 +56,7 @@ compile: $(INFECTION)
.PHONY: compile-docker
compile-docker: ## Bundles Infection into a PHAR using docker
compile-docker: $(DOCKER_FILE_IMAGE)
$(DOCKER_RUN_74) make compile
$(DOCKER_RUN_80) make compile

.PHONY: check_trailing_whitespaces
check_trailing_whitespaces:
Expand Down Expand Up @@ -144,11 +143,7 @@ test-unit-parallel:

.PHONY: test-unit-docker
test-unit-docker: ## Runs the unit tests on the different Docker platforms
test-unit-docker: test-unit-74-docker test-unit-80-docker

.PHONY: test-unit-74-docker
test-unit-74-docker: $(DOCKER_FILE_IMAGE) $(PHPUNIT)
$(DOCKER_RUN_74) $(PHPUNIT) --group $(PHPUNIT_GROUP)
test-unit-docker: test-unit-80-docker

.PHONY: test-unit-80-docker
test-unit-80-docker: $(DOCKER_FILE_IMAGE) $(PHPUNIT)
Expand All @@ -169,25 +164,15 @@ test-e2e-docker: ## Runs the end-to-end tests on the different Docker platforms
test-e2e-docker: test-e2e-phpdbg-docker test-e2e-xdebug-docker

.PHONY: test-e2e-phpdbg-docker
test-e2e-phpdbg-docker: test-e2e-phpdbg-74-docker test-e2e-phpdbg-80-docker

.PHONY: test-e2e-phpdbg-74-docker
test-e2e-phpdbg-74-docker: $(DOCKER_FILE_IMAGE) $(INFECTION)
$(DOCKER_RUN_74) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_74) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)
test-e2e-phpdbg-docker: test-e2e-phpdbg-80-docker

.PHONY: test-e2e-phpdbg-80-docker
test-e2e-phpdbg-80-docker: $(DOCKER_FILE_IMAGE) $(INFECTION)
$(DOCKER_RUN_80) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_80) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)

.PHONY: test-e2e-xdebug-docker
test-e2e-xdebug-docker: test-e2e-xdebug-74-docker test-e2e-xdebug-80-docker

.PHONY: test-e2e-xdebug-74-docker
test-e2e-xdebug-74-docker: $(DOCKER_FILE_IMAGE) $(INFECTION)
$(DOCKER_RUN_74) $(PHPUNIT) --group $(E2E_PHPUNIT_GROUP)
$(DOCKER_RUN_74) ./tests/e2e_tests $(INFECTION)
test-e2e-xdebug-docker: test-e2e-xdebug-80-docker

.PHONY: test-e2e-xdebug-80-docker
test-e2e-xdebug-80-docker: $(DOCKER_FILE_IMAGE) $(INFECTION)
Expand All @@ -204,22 +189,14 @@ test-infection-docker: ## Runs Infection against itself on the different Docker
test-infection-docker: test-infection-phpdbg-docker test-infection-xdebug-docker

.PHONY: test-infection-phpdbg-docker
test-infection-phpdbg-docker: test-infection-phpdbg-74-docker test-infection-phpdbg-80-docker

.PHONY: test-infection-phpdbg-74-docker
test-infection-phpdbg-74-docker: $(DOCKER_FILE_IMAGE)
$(DOCKER_RUN_74) phpdbg -qrr bin/infection --threads=4
test-infection-phpdbg-docker: test-infection-phpdbg-80-docker

.PHONY: test-infection-phpdbg-80-docker
test-infection-phpdbg-80-docker: $(DOCKER_FILE_IMAGE)
$(DOCKER_RUN_80) phpdbg -qrr bin/infection --threads=4

.PHONY: test-infection-xdebug-docker
test-infection-xdebug-docker: test-infection-xdebug-74-docker test-infection-xdebug-80-docker

.PHONY: test-infection-xdebug-74-docker
test-infection-xdebug-74-docker: $(DOCKER_FILE_IMAGE)
$(DOCKER_RUN_74) ./bin/infection --threads=4
test-infection-xdebug-docker: test-infection-xdebug-80-docker

.PHONY: test-infection-xdebug-80-docker
test-infection-xdebug-80-docker: $(DOCKER_FILE_IMAGE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
[![Minimum PHP version: 7.4.0](https://img.shields.io/badge/php-7.4.0%2B-blue.svg)](https://packagist.org/packages/infection/infection)
[![Minimum PHP version: 8.0.0](https://img.shields.io/badge/php-8.0.0%2B-blue.svg)](https://packagist.org/packages/infection/infection)
[![Latest Stable Version](https://poser.pugx.org/infection/infection/v/stable)](https://packagist.org/packages/infection/infection)
[![Continuous Integration](https://github.com/infection/infection/workflows/Continuous%20Integration/badge.svg)](https://github.com/infection/infection/actions)
[![Build Status](https://travis-ci.org/infection/infection.svg?branch=master)](https://travis-ci.org/infection/infection)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -42,7 +42,7 @@
}
],
"require": {
"php": "^7.4.7 || ^8.0",
"php": "^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
Expand Down Expand Up @@ -87,7 +87,7 @@
},
"config": {
"platform": {
"php": "7.4.7"
"php": "8.0.0"
},
"sort-packages": true,
"allow-plugins": {
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion devTools/phpstan-src.neon
Expand Up @@ -14,7 +14,11 @@ parameters:
- '#^Variable (method|property) (access|call) #'
-
path: '../src/Metrics/MetricsCalculator.php'
message: '#^Strict comparison using !== between array<int, Infection\\Mutant\\MutantExecutionResult> and array{} will always evaluate to true\.$#'
message: '#^Strict comparison using !== between array<int|string, Infection\\Mutant\\MutantExecutionResult> and array{} will always evaluate to true\.$#'
count: 1
-
path: '../src/Mutator/MutatorResolver.php'
message: '#^Method Infection\\Mutator\\MutatorResolver::resolveSettings\(\) has parameter \$settings with no value type specified in iterable type array\.$#'
count: 1
-
path: ../src/TestFramework/Factory.php
Expand Down
7 changes: 0 additions & 7 deletions docker-compose.yml
@@ -1,12 +1,5 @@
version: '3'
services:
php74:
build:
context: devTools
args:
PHP_VERSION: 7.4
volumes:
- .:/opt/infection
php80:
build:
context: devTools
Expand Down
5 changes: 1 addition & 4 deletions src/Console/ConsoleOutput.php
Expand Up @@ -49,11 +49,8 @@ class ConsoleOutput
private const RUNNING_WITH_DEBUGGER_NOTE = 'You are running Infection with %s enabled.';
private const MIN_MSI_CAN_GET_INCREASED_NOTICE = 'The %s is %s%% percentage points over the required %s. Consider increasing the required %s percentage the next time you run Infection.';

private ConsoleLogger $logger;

public function __construct(ConsoleLogger $logger)
public function __construct(private ConsoleLogger $logger)
{
$this->logger = $logger;
}

public function logVerbosityDeprecationNotice(string $valueToUse): void
Expand Down
5 changes: 1 addition & 4 deletions src/Console/OutputFormatter/DotFormatter.php
Expand Up @@ -49,11 +49,8 @@ final class DotFormatter extends AbstractOutputFormatter
{
private const DOTS_PER_ROW = 50;

private OutputInterface $output;

public function __construct(OutputInterface $output)
public function __construct(private OutputInterface $output)
{
$this->output = $output;
}

public function start(int $mutationCount): void
Expand Down
19 changes: 5 additions & 14 deletions src/Console/OutputFormatter/FormatterFactory.php
Expand Up @@ -36,7 +36,6 @@
namespace Infection\Console\OutputFormatter;

use function implode;
use LogicException;
use function Safe\sprintf;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -47,11 +46,8 @@
*/
final class FormatterFactory
{
private OutputInterface $output;

public function __construct(OutputInterface $output)
public function __construct(private OutputInterface $output)
{
$this->output = $output;
}

public function create(string $formatterName): OutputFormatter
Expand All @@ -65,14 +61,9 @@ public function create(string $formatterName): OutputFormatter
)
);

switch ($formatterName) {
case FormatterName::PROGRESS:
return new ProgressFormatter(new ProgressBar($this->output));

case FormatterName::DOT:
return new DotFormatter($this->output);
}

throw new LogicException('Unreachable statement');
return match ($formatterName) {
FormatterName::PROGRESS => new ProgressFormatter(new ProgressBar($this->output)),
FormatterName::DOT => new DotFormatter($this->output),
};
}
}
5 changes: 1 addition & 4 deletions src/Console/OutputFormatter/ProgressFormatter.php
Expand Up @@ -43,11 +43,8 @@
*/
final class ProgressFormatter extends AbstractOutputFormatter
{
private ProgressBar $progressBar;

public function __construct(ProgressBar $progressBar)
public function __construct(private ProgressBar $progressBar)
{
$this->progressBar = $progressBar;
}

public function start(int $mutationCount): void
Expand Down

0 comments on commit 8042277

Please sign in to comment.