From ece5a5242f249290b10c57c3b08c613a342256bb Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 14 Feb 2024 15:08:04 +0100 Subject: [PATCH 1/3] Allow installation alongside PHPUnit 11 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e8f1361..37767e4 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "illuminate/contracts": "^9 || ^10", "illuminate/support": "^9 || ^10", "laminas/laminas-code": "^3.4 || ^4", - "nikic/php-parser": "^4.13" + "nikic/php-parser": "^4.13 || ^5" }, "require-dev": { "doctrine/dbal": "^3.4", @@ -42,7 +42,7 @@ "phpstan/phpstan": "^1.8.2", "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-phpunit": "^1.1.1", - "phpunit/phpunit": "^9.5.21 || ^10", + "phpunit/phpunit": "^9.5.21 || ^10 || ^11", "rector/rector": "^0.19", "symplify/rule-doc-generator": "^11 || ^12" }, From 0f538fb5f3279d39e433406825ec06ce8091e473 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 14 Feb 2024 15:10:35 +0100 Subject: [PATCH 2/3] fix codestyle --- src/Commands/EnumAnnotateCommand.php | 2 +- src/Enum.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/EnumAnnotateCommand.php b/src/Commands/EnumAnnotateCommand.php index 000c989..e8dcaa1 100644 --- a/src/Commands/EnumAnnotateCommand.php +++ b/src/Commands/EnumAnnotateCommand.php @@ -149,7 +149,7 @@ protected function getDocblockWithoutTags(DocBlockReflection $docBlockReflection * * @return array<\Laminas\Code\Generator\DocBlock\Tag\TagInterface> */ - protected function getDocblockTags(DocBlockGenerator|null $originalDocblock, \ReflectionClass $reflectionClass): array + protected function getDocblockTags(?DocBlockGenerator $originalDocblock, \ReflectionClass $reflectionClass): array { $constants = $reflectionClass->getConstants(); $constantKeys = array_keys($constants); diff --git a/src/Enum.php b/src/Enum.php index 600d813..6f1c996 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -273,7 +273,7 @@ public static function getKeys(mixed $values = null): array * * @return array */ - public static function getValues(string|array $keys = null): array + public static function getValues(string|array|null $keys = null): array { if ($keys === null) { return array_values(static::getConstants()); From 85bd295f00f98c3c2e612de86e1be1abab5cd495 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 14 Feb 2024 15:10:47 +0100 Subject: [PATCH 3/3] Fix nikic/php-parser 5 compat --- src/Rector/ToNativeUsagesRector.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Rector/ToNativeUsagesRector.php b/src/Rector/ToNativeUsagesRector.php index 69a59f8..4224508 100644 --- a/src/Rector/ToNativeUsagesRector.php +++ b/src/Rector/ToNativeUsagesRector.php @@ -280,7 +280,7 @@ protected function refactorFromKey(StaticCall $call): ?Node $enumInstanceMatchesKey = new ArrowFunction([ 'params' => [new Param($paramVariable, null, $class)], - 'returnType' => 'bool', + 'returnType' => new Identifier('bool'), 'expr' => new Identical( new PropertyFetch($paramVariable, 'name'), $key, @@ -309,7 +309,7 @@ protected function refactorFromKey(StaticCall $call): ?Node return new ArrowFunction([ 'static' => true, - 'params' => [new Param($keyVariable, null, 'string')], + 'params' => [new Param($keyVariable, null, new Identifier('string'))], 'returnType' => $class, 'expr' => $makeFromKey($keyVariable), ]); @@ -354,7 +354,7 @@ protected function refactorGetKeys(StaticCall $call): ?Node new ArrowFunction([ 'static' => true, 'params' => [new Param($paramVariable, null, $class)], - 'returnType' => 'string', + 'returnType' => new Identifier('string'), 'expr' => new PropertyFetch($paramVariable, 'name'), ]) ), @@ -449,8 +449,8 @@ protected function refactorHasValue(StaticCall $call): ?Node return new ArrowFunction([ 'static' => true, - 'params' => [new Param($valueVariable, null, 'mixed')], - 'returnType' => 'bool', + 'params' => [new Param($valueVariable, null, new Identifier('mixed'))], + 'returnType' => new Identifier('bool'), 'expr' => $expr, ]); } @@ -571,8 +571,8 @@ protected function refactorIsOrIsNot(MethodCall|NullsafeMethodCall $call, bool $ $param = new Variable('value'); return new ArrowFunction([ - 'params' => [new Param($param, null, 'mixed')], - 'returnType' => 'bool', + 'params' => [new Param($param, null, new Identifier('mixed'))], + 'returnType' => new Identifier('bool'), 'expr' => new $comparison($call->var, $param, [self::COMPARED_AGAINST_ENUM_INSTANCE => true]), ]); } @@ -607,7 +607,7 @@ protected function refactorInOrNotIn(MethodCall|NullsafeMethodCall $call, bool $ $haystackValue = $haystack->value; if ($haystackValue instanceof Array_) { foreach ($haystackValue->items as $item) { - $item?->setAttribute(self::COMPARED_AGAINST_ENUM_INSTANCE, true); + $item->setAttribute(self::COMPARED_AGAINST_ENUM_INSTANCE, true); } }