Skip to content

bump to php-parser 5.4 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

# composer install cache - https://github.com/ramsey/composer-install
Expand Down
23 changes: 9 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
"description": "Print Symfony services array with configuration to to plain PHP file format thanks to this simple php-parser wrapper",
"license": "MIT",
"require": {
"php": ">=8.1",
"php": ">=8.2",
"nette/utils": "^3.2",
"nikic/php-parser": "^4.18",
"nikic/php-parser": "^5.3",
"symfony/yaml": "^6.4"
},
"require-dev": {
"myclabs/php-enum": "^1.8",
"phpstan/extension-installer": "^1.3",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.18.12",
"symplify/easy-coding-standard": "^12.0",
"rector/rector": "^2.0",
"phpecs/phpecs": "^2.0",
"symplify/easy-testing": "^11.1",
"symplify/phpstan-extensions": "^11.2",
"tomasvotruba/class-leak": "^0.2"
"symplify/phpstan-extensions": "^12.0",
"tomasvotruba/class-leak": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -32,20 +33,14 @@
"tests/Printer/SmartPhpConfigPrinter/Source/custom_inline_object_function.php"
]
},
"extra": {
"branch-alias": {
"dev-main": "11.2-dev"
}
},
"scripts": {
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
"phpstan": "vendor/bin/phpstan analyse --ansi",
"rector": "vendor/bin/rector process --dry-run --ansi"
},
"config": {
"sort-packages": true,
"platform-check": false,
"allow-plugins": {
"cweagans/composer-patches": true,
"phpstan/extension-installer": true
Expand Down
17 changes: 5 additions & 12 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/ecs.php',
__DIR__ . '/rector.php',
return ECSConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$ecsConfig->sets([
SetList::COMMON,
SetList::PSR_12,
]);
};
])
->withRootFiles()
->withPreparedSets(common: true, psr12: true);
14 changes: 12 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
parameters:
level: 6
level: 8

errorFormat: symplify
treatPhpDocTypesAsCertain: false

paths:
- src
Expand All @@ -11,4 +14,11 @@ parameters:
- '*/tests/**/data/*'

ignoreErrors:
- '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array<PhpParser\\Node\\Expr\\ArrayItem\|null>, array<PhpParser\\Node\\Arg> given#'

# php version depends on runtime
-
message: '#Comparison operation ">=" between int<(.*?), 80499> and 80000 is always true#'
path: src/NodeFactory/ArgsNodeFactory.php

# unclear what to do
- '#Parameter \#1 \$items of class PhpParser\\Node\\Expr\\Array_ constructor expects array<PhpParser\\Node\\ArrayItem>, array<PhpParser\\Node\\Arg> given#'
36 changes: 10 additions & 26 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,16 @@

use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
PHPUnitSetList::PHPUNIT_100,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
LevelSetList::UP_TO_PHP_81,
SetList::CODING_STYLE,
SetList::TYPE_DECLARATION,
SetList::NAMING,
SetList::PRIVATIZATION,
SetList::EARLY_RETURN,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);

$rectorConfig->paths([
return RectorConfig::configure()
->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true, typeDeclarations: true, naming: true, privatization: true)
->withRootFiles()
->withPhpSets()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->importNames();

$rectorConfig->skip([
])
->withSkip([
'*/Source/*',
'*/Fixture/*',
// keep prefix
Expand All @@ -38,7 +22,7 @@
__DIR__ . '/src/NodeFactory/ContainerConfiguratorReturnClosureFactory.php',
],

// preference
\Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class,
// old value is needed
\Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector::class,

]);
};
8 changes: 4 additions & 4 deletions src/CaseConverter/AliasCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class AliasCaseConverter implements CaseConverterInterface
final readonly class AliasCaseConverter implements CaseConverterInterface
{
/**
* @see https://regex101.com/r/BwXkfO/2/
Expand All @@ -36,9 +36,9 @@ final class AliasCaseConverter implements CaseConverterInterface
private const NAMED_ALIAS_REGEX = '#\w+\s+\$\w+#';

public function __construct(
private readonly CommonNodeFactory $commonNodeFactory,
private readonly ArgsNodeFactory $argsNodeFactory,
private readonly ServiceOptionNodeFactory $serviceOptionNodeFactory,
private CommonNodeFactory $commonNodeFactory,
private ArgsNodeFactory $argsNodeFactory,
private ServiceOptionNodeFactory $serviceOptionNodeFactory,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/CaseConverter/ClassServiceCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class ClassServiceCaseConverter implements CaseConverterInterface
final readonly class ClassServiceCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly ArgsNodeFactory $argsNodeFactory,
private readonly ServiceOptionNodeFactory $serviceOptionNodeFactory
private ArgsNodeFactory $argsNodeFactory,
private ServiceOptionNodeFactory $serviceOptionNodeFactory
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/CaseConverter/ConfiguredServiceCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class ConfiguredServiceCaseConverter implements CaseConverterInterface
final readonly class ConfiguredServiceCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly ArgsNodeFactory $argsNodeFactory,
private readonly ServiceOptionNodeFactory $serviceOptionNodeFactory
private ArgsNodeFactory $argsNodeFactory,
private ServiceOptionNodeFactory $serviceOptionNodeFactory
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/CaseConverter/ImportCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* imports: <---
*/
final class ImportCaseConverter implements CaseConverterInterface
final readonly class ImportCaseConverter implements CaseConverterInterface
{
/**
* @see https://regex101.com/r/hOTdIE/1
Expand All @@ -36,8 +36,8 @@ final class ImportCaseConverter implements CaseConverterInterface
private const INPUT_SUFFIX_REGEX = '#\.(yml|yaml|xml)$#';

public function __construct(
private readonly YamlArgumentSorter $yamlArgumentSorter,
private readonly CommonNodeFactory $commonNodeFactory
private YamlArgumentSorter $yamlArgumentSorter,
private CommonNodeFactory $commonNodeFactory
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/CaseConverter/NameOnlyServiceCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class NameOnlyServiceCaseConverter implements CaseConverterInterface
final readonly class NameOnlyServiceCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly CommonNodeFactory $commonNodeFactory
private CommonNodeFactory $commonNodeFactory
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class InstanceOfNestedCaseConverter
final readonly class InstanceOfNestedCaseConverter
{
public function __construct(
private readonly CommonNodeFactory $commonNodeFactory,
private readonly ServiceOptionNodeFactory $serviceOptionNodeFactory
private CommonNodeFactory $commonNodeFactory,
private ServiceOptionNodeFactory $serviceOptionNodeFactory
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/CaseConverter/ParameterCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
*
* parameters: <---
*/
final class ParameterCaseConverter implements CaseConverterInterface
final readonly class ParameterCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly ArgsNodeFactory $argsNodeFactory,
private readonly CurrentFilePathProvider $currentFilePathProvider,
private readonly CommonNodeFactory $commonNodeFactory
private ArgsNodeFactory $argsNodeFactory,
private CurrentFilePathProvider $currentFilePathProvider,
private CommonNodeFactory $commonNodeFactory
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/CaseConverter/ResourceCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use Symplify\PhpConfigPrinter\NodeFactory\Service\ServicesPhpNodeFactory;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class ResourceCaseConverter implements CaseConverterInterface
final readonly class ResourceCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly ServicesPhpNodeFactory $servicesPhpNodeFactory
private ServicesPhpNodeFactory $servicesPhpNodeFactory
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/CaseConverter/ServicesDefaultsCaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use Symplify\PhpConfigPrinter\ValueObject\VariableName;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;

final class ServicesDefaultsCaseConverter implements CaseConverterInterface
final readonly class ServicesDefaultsCaseConverter implements CaseConverterInterface
{
public function __construct(
private readonly AutoBindNodeFactory $autoBindNodeFactory
private AutoBindNodeFactory $autoBindNodeFactory
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/ExprResolver/ServiceReferenceExprResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use PhpParser\Node\Name\FullyQualified;
use Symplify\PhpConfigPrinter\ValueObject\FunctionName;

final class ServiceReferenceExprResolver
final readonly class ServiceReferenceExprResolver
{
public function __construct(
private readonly StringExprResolver $stringExprResolver
private StringExprResolver $stringExprResolver
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/ExprResolver/StringExprResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symplify\PhpConfigPrinter\NodeFactory\ConstantNodeFactory;
use Symplify\PhpConfigPrinter\ValueObject\FunctionName;

final class StringExprResolver
final readonly class StringExprResolver
{
/**
* @see https://regex101.com/r/laf2wR/1
Expand All @@ -25,8 +25,8 @@ final class StringExprResolver
private const TWIG_HTML_XML_SUFFIX_REGEX = '#\.(twig|html|xml)$#';

public function __construct(
private readonly ConstantNodeFactory $constantNodeFactory,
private readonly CommonNodeFactory $commonNodeFactory
private ConstantNodeFactory $constantNodeFactory,
private CommonNodeFactory $commonNodeFactory
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/ExprResolver/TaggedReturnsCloneResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Symplify\PhpConfigPrinter\ExprResolver;

use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use Symfony\Component\Yaml\Tag\TaggedValue;
use Symplify\PhpConfigPrinter\ValueObject\FunctionName;

final class TaggedReturnsCloneResolver
final readonly class TaggedReturnsCloneResolver
{
public function __construct(
private readonly ServiceReferenceExprResolver $serviceReferenceExprResolver
private ServiceReferenceExprResolver $serviceReferenceExprResolver
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/ExprResolver/TaggedServiceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use Symfony\Component\Yaml\Tag\TaggedValue;
use Symplify\PhpConfigPrinter\ValueObject\FunctionName;

final class TaggedServiceResolver
final readonly class TaggedServiceResolver
{
public function __construct(
private readonly ServiceReferenceExprResolver $serviceReferenceExprResolver
private ServiceReferenceExprResolver $serviceReferenceExprResolver
) {
}

Expand Down
Loading
Loading