mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-15 02:25:40 +00:00
Bump to PHP 8.0+
PHP 7.4 was end of life November 2022, it's time to bump to PHP 8 standard 🎉
- updated starting code to PHP 8 standard
- upgraded tooling (code quality, static analysis) to the latest versions
- tested with PHP 8.0, 8.1 and 8.2
- the fixture is working
- the example test is failing, as expected
- code quality is as expected
- static analysis is ok
This commit is contained in:
1 parent
f7a3312e6b
commit
081c69b864
11 files changed
+87
-4602
No files matched your search
+32
-21
@@ -3,34 +3,45 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\EasyCodingStandard\ValueObject\Option;
|
||||
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
|
||||
use Symplify\EasyCodingStandard\Config\ECSConfig;
|
||||
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ArraySyntaxFixer::class)
|
||||
->call('configure', [[
|
||||
'syntax' => 'short',
|
||||
]]);
|
||||
// composer require --dev symplify/easy-coding-standard
|
||||
// vendor/bin/ecs init
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PATHS, [
|
||||
__DIR__ . '/fixtures',
|
||||
return static function (ECSConfig $ecsConfig): void {
|
||||
$ecsConfig->paths([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests',
|
||||
__DIR__ . '/ecs.php', // check this file too!
|
||||
]);
|
||||
|
||||
$parameters->set
|
||||
(Option::SETS,
|
||||
[
|
||||
SetList::CLEAN_CODE,
|
||||
SetList::COMMON,
|
||||
SetList::PSR_12,
|
||||
]
|
||||
);
|
||||
$ecsConfig->skip([
|
||||
// rules to skip
|
||||
]);
|
||||
|
||||
$parameters->set(Option::INDENTATION, "spaces");
|
||||
// run and fix, one by one
|
||||
$ecsConfig->sets([
|
||||
SetList::SPACES,
|
||||
SetList::ARRAY,
|
||||
SetList::DOCBLOCK,
|
||||
SetList::NAMESPACES,
|
||||
SetList::CONTROL_STRUCTURES,
|
||||
SetList::CLEAN_CODE,
|
||||
SetList::STRICT,
|
||||
SetList::PSR_12,
|
||||
SetList::PHPUNIT,
|
||||
]);
|
||||
|
||||
$parameters->set(Option::LINE_ENDING, "\n");
|
||||
// add declare(strict_types=1); to all php files:
|
||||
$ecsConfig->rule(DeclareStrictTypesFixer::class);
|
||||
|
||||
// change $array = array(); to $array = [];
|
||||
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
|
||||
'syntax' => 'short',
|
||||
]);
|
||||
|
||||
// [default: PHP_EOL]; other options: "\n"
|
||||
$ecsConfig->lineEnding("\n");
|
||||
};
|
||||
Reference in new issue
Block a user