Skip to content

Commit

Permalink
⬆️ add php 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Apr 17, 2024
1 parent 331cf9e commit 5441e62
Show file tree
Hide file tree
Showing 78 changed files with 605 additions and 450 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
symfony: ['5', '6']
php: ['8.1', '8.2', '8.3']
symfony: ['5', '6', '7']
exclude:
- symfony: '6'
php: '7.4'
- symfony: '7'
php: '8.1'
name: 'PHP ${{ matrix.php }} + Symfony: ${{ matrix.symfony }}'
steps:
- run: git config --global --add safe.directory /__w/phpsu/phpsu
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependenciess
Expand All @@ -39,12 +40,12 @@ jobs:
key: dependencies-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('composer.json') }}
- run: composer req symfony/console:^${{ matrix.symfony }}
- run: vendor/bin/grumphp run
- run: git config --global --add safe.directory /__w/phpsu/phpsu
- run: script -q -e -c "composer test"
- run: script -q -e -c "composer infection"
- run: composer phpstan
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./tests/test-results/coverage.xml

docker:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/phpsu-config.php
composer.lock
tests/.phpunit.result.cache
var/
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ you can execute any phpsu command via something like this:

The following versions of PHP are supported by this version.

* PHP `7.4`, `8.0`, `8.1`, `8.2`
* Compatible and continuously tested with symfony `5`, `6`
* PHP `8.1`, `8.2`, `8.3`
* Compatible and continuously tested with symfony `5`, `6`, `7`
* for older versions go to [version 3.1.0](https://github.com/phpsu/phpsu/tree/3.1.0)
* for older versions go to [version 2.3.0](https://github.com/phpsu/phpsu/tree/2.3.0)
* or [version 1.1.0](https://github.com/phpsu/phpsu/tree/1.1.0)

Expand Down
4 changes: 0 additions & 4 deletions box.json

This file was deleted.

86 changes: 38 additions & 48 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
{
"name": "phpsu/phpsu",
"license": "MIT",
"description": "Synchronisation Utility: File and Database",
"license": "MIT",
"type": "library",
"keywords": [
"phpsu",
"rsync",
"mysql",
"mysqldump"
],
"homepage": "https://phpsu.de/",
"config": {
"optimize-autoloader": true,
"process-timeout": 0,
"allow-plugins": {
"phpro/grumphp": true,
"infection/extension-installer": true,
"pluswerk/grumphp-config": true
}
},
"authors": [
{
"name": "Matthias Vogel",
Expand All @@ -28,19 +18,28 @@
{
"name": "Christian Rodriguez Benthake",
"email": "git@cben.co",
"role": "Developer",
"homepage": "https://cben.dev"
"homepage": "https://cben.dev",
"role": "Developer"
}
],
"bin": [
"phpsu"
],
"scripts": {
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/phpunit.xml --testdox --color=always",
"test:watch": "vendor/bin/phpunit-watcher watch -c tests/phpunit.xml --testdox",
"infection": "XDEBUG_MODE=coverage vendor/bin/infection --threads=4 --only-covered --min-msi=91 --min-covered-msi=91 --ansi",
"phpstan": "vendor/bin/phpstan --ansi"
"homepage": "https://phpsu.de/",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-json": "*",
"composer-runtime-api": "^2.0.0",
"phpsu/shellcommandbuilder": "^2.0",
"symfony/console": "^5.0 || ^6.0 || ^7.0",
"symfony/process": "^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
"infection/infection": "^0.28.1",
"phpunit/phpunit": "^10.5.18",
"pluswerk/grumphp-config": "^7.0.1"
},
"suggest": {
"bamarni/composer-bin-plugin": "Dependency-Independent use of phpsu"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"PHPSu\\": "src"
Expand All @@ -51,33 +50,24 @@
"PHPSu\\Tests\\": "tests"
}
},
"minimum-stability": "stable",
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"ext-json": "*",
"composer-runtime-api": "^2.0.0",
"phpsu/shellcommandbuilder": "^2.0",
"symfony/console": "^5.0 || ^6.0",
"symfony/process": "^5.0 || ^6.0"
},
"require-dev": {
"pluswerk/grumphp-config": "^5.0.2",
"rector/rector": "^0.12.23",
"spatie/phpunit-watcher": "^1.23.6",
"phpstan/phpstan": "^1.9.3",
"infection/infection": "^0.26.0",
"phpunit/php-invoker": "^3.1.1",
"phpunit/phpunit": "^9.5.27"
},
"suggest": {
"bamarni/composer-bin-plugin": "Dependency-Independent use of phpsu"
},
"extra": {
"pluswerk/grumphp-config": {
"auto-setting": false
"bin": [
"phpsu"
],
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"infection/extension-installer": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"pluswerk/grumphp-config": true
},
"grumphp": {
"config-default-path": "grumphp.yml"
}
"optimize-autoloader": true,
"process-timeout": 0
},
"scripts": {
"infection": "XDEBUG_MODE=coverage vendor/bin/infection --threads=4 --only-covered --min-msi=91 --min-covered-msi=91 --ansi",
"phpstan": "vendor/bin/phpstan --ansi",
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/phpunit.xml --testdox --color=always",
"test:watch": "vendor/bin/phpunit-watcher watch -c tests/phpunit.xml --testdox"
}
}
23 changes: 13 additions & 10 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
imports:
- { resource: vendor/pluswerk/grumphp-config/grumphp.yml }


grumphp:
tasks:
phpstan:
level: ~
configuration: "phpstan.neon"
ignore_patterns: [".phpstorm.meta.php"]


parameters:
convention.process_timeout: 240
convention.security_checker_blocking: true
convention.jsonlint_ignore_pattern:
- "tests/fixtures/installed/invalidJson/vendor/composer/installed.json"

convention.xmllint_ignore_pattern: { }
convention.yamllint_ignore_pattern: { }
convention.phpcslint_ignore_pattern: { }
convention.phpcslint_exclude: { }
convention.xlifflint_ignore_pattern: { }
convention.rector_ignore_pattern: { }
convention.rector_enabled: true
convention.rector_config: rector.php
convention.rector_clear-cache: false
convention.phpstan_level: null
2 changes: 2 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
13 changes: 7 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
includes:
- phpstan-baseline.neon
- vendor/andersundsehr/phpstan-git-files/extension.php

parameters:
level: max
paths:
- src
- tests
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#Access to an undefined property PHPSu\\Config\\SshConfig::\$[a-zA-Z0-9_\*]+#'
reportUnmatchedIgnoredErrors: false
universalObjectCratesClasses:
- PHPSu\Config\SshConfig
42 changes: 42 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use PLUS\GrumPHPConfig\RectorSettings;
use Rector\Config\RectorConfig;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->importShortClasses();
$rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./var/cache/rector');

$rectorConfig->paths(
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php|html|typoscript)$'")))
);

// define sets of rules
$rectorConfig->sets(
[
...RectorSettings::sets(true),
...RectorSettings::setsTypo3(false),
]
);

// remove some rules
// ignore some files
$rectorConfig->skip(
[
...RectorSettings::skip(),
...RectorSettings::skipTypo3(),

/**
* rector should not touch these files
*/
//__DIR__ . '/src/Example',
//__DIR__ . '/src/Example.php',
]
);
};
10 changes: 0 additions & 10 deletions rector.yml

This file was deleted.

7 changes: 1 addition & 6 deletions src/Cli/AbstractCliCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
*/
abstract class AbstractCliCommand extends Command
{
protected ConfigurationLoaderInterface $configurationLoader;
protected ControllerInterface $controller;

public function __construct(ConfigurationLoaderInterface $configurationLoader, ControllerInterface $controller)
public function __construct(protected ConfigurationLoaderInterface $configurationLoader, protected ControllerInterface $controller)
{
parent::__construct();
$this->configurationLoader = $configurationLoader;
$this->controller = $controller;
}
}
1 change: 1 addition & 0 deletions src/Cli/InfoCliCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$symfonyStyle = new SymfonyStyle($input, $output);
$symfonyStyle->title('List of all dependencies and their versions');

$environmentUtility = new EnvironmentUtility();
$output->writeln('<info>Locally installed</info>');
$symfonyStyle->table(
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/MysqlCliCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
$output->writeln('You selected: ' . $destination);
$input->setArgument('instance', $destination);
}

$default = $input->hasOption('database') ? $input->getOption('database') : '';

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Symfony: 5

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Symfony: 6

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 5

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 6

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 6

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 7

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 5

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);

Check warning on line 61 in src/Cli/MysqlCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 7

Escaped Mutant for Mutator "Ternary": --- Original +++ New @@ @@ $output->writeln('You selected: ' . $destination); $input->setArgument('instance', $destination); } - $default = $input->hasOption('database') ? $input->getOption('database') : ''; + $default = $input->hasOption('database') ? '' : $input->getOption('database'); $instance = $input->getArgument('instance'); assert(is_string($instance)); $databases = $this->getDatabasesForAppInstance($instance);
$instance = $input->getArgument('instance');
assert(is_string($instance));
Expand Down Expand Up @@ -100,11 +101,11 @@ private function getAppInstancesWithHost(): array
if ($this->instances === null) {
$this->instances = $this->configurationLoader->getConfig()->getAppInstanceNames();
}

return $this->instances;
}

/**
* @param string $appInstance
* @return string[]
*/
private function getDatabasesForAppInstance(string $appInstance): array
Expand Down
9 changes: 5 additions & 4 deletions src/Cli/SshCliCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
protected function interact(InputInterface $input, OutputInterface $output): void
{
$default = $input->hasArgument('destination') ? $input->getArgument('destination') : '';
if (empty($this->getAppInstancesWithHost())) {
if (!$this->getAppInstancesWithHost()) {
throw new Exception('You need to define at least one AppInstance besides local');
}

if (!in_array($default, $this->getAppInstancesWithHost(), true)) {
$question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost());
$question->setErrorMessage('AppInstance %s not found in Config.');

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Symfony: 5

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Symfony: 6

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 5

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 6

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 6

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 7

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Symfony: 5

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);

Check warning on line 59 in src/Cli/SshCliCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Symfony: 7

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } if (!in_array($default, $this->getAppInstancesWithHost(), true)) { $question = new ChoiceQuestion('Please select one of the AppInstances', $this->getAppInstancesWithHost()); - $question->setErrorMessage('AppInstance %s not found in Config.'); + $questionHelper = $this->getHelper('question'); assert($questionHelper instanceof QuestionHelper); $destination = $questionHelper->ask($input, $output, $question);
Expand All @@ -76,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($commandArray as $command) {
$builder->addSingle($command, true);
}

return $this->controller->ssh(
$output,
$this->configurationLoader->getConfig(),
Expand All @@ -92,10 +94,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function getAppInstancesWithHost(): array
{
if ($this->instances === null) {
$this->instances = $this->configurationLoader->getConfig()->getAppInstanceNames(static function (AppInstance $instance) {
return $instance->getHost() !== '';
});
$this->instances = $this->configurationLoader->getConfig()->getAppInstanceNames(static fn(AppInstance $instance): bool => $instance->getHost() !== '');
}

return $this->instances;
}
}
Loading

0 comments on commit 5441e62

Please sign in to comment.