Skip to content

Commit 050c8b3

Browse files
authored
Keyset as string or integer (#437)
1 parent 1403e77 commit 050c8b3

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

rector.php

+15-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Rector\Config\RectorConfig;
66
use Rector\Core\ValueObject\PhpVersion;
77
use Rector\Doctrine\Set\DoctrineSetList;
8-
use Rector\Php74\Rector\Property\TypedPropertyRector;
98
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
109
use Rector\PHPUnit\Set\PHPUnitSetList;
1110
use Rector\Set\ValueObject\LevelSetList;
@@ -14,22 +13,21 @@
1413
use Rector\Symfony\Set\SymfonySetList;
1514

1615
return static function (RectorConfig $config): void {
17-
$config->sets([
18-
SetList::DEAD_CODE,
19-
LevelSetList::UP_TO_PHP_81,
20-
SymfonyLevelSetList::UP_TO_SYMFONY_54,
21-
SymfonySetList::SYMFONY_CODE_QUALITY,
22-
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
23-
SymfonySetList::SYMFONY_STRICT,
24-
DoctrineSetList::DOCTRINE_CODE_QUALITY,
25-
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
26-
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
27-
PHPUnitLevelSetList::UP_TO_PHPUNIT_100,
28-
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
29-
PHPUnitSetList::PHPUNIT_EXCEPTION,
30-
PHPUnitSetList::REMOVE_MOCKS,
31-
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
32-
]);
16+
$config->import(SetList::DEAD_CODE);
17+
$config->import(LevelSetList::UP_TO_PHP_81);
18+
$config->import(SymfonyLevelSetList::UP_TO_SYMFONY_54);
19+
$config->import(SymfonySetList::SYMFONY_CODE_QUALITY);
20+
$config->import(SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION);
21+
$config->import(SymfonySetList::SYMFONY_STRICT);
22+
$config->import(SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES);
23+
$config->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);
24+
$config->import(DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES);
25+
$config->import(PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD);
26+
$config->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_90);
27+
$config->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
28+
$config->import(PHPUnitSetList::PHPUNIT_EXCEPTION);
29+
$config->import(PHPUnitSetList::REMOVE_MOCKS);
30+
$config->import(PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER);
3331
$config->parallel();
3432
$config->paths([__DIR__ . '/src', __DIR__ . '/performance', __DIR__ . '/tests']);
3533
$config->skip([
@@ -40,7 +38,4 @@
4038
$config->phpVersion(PhpVersion::PHP_81);
4139
$config->importNames();
4240
$config->importShortClasses();
43-
44-
$services = $config->services();
45-
$services->set(TypedPropertyRector::class);
4641
};

src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSource/JWKSet.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSource;
66

7+
use function is_int;
8+
use function is_string;
79
use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource;
810
use Jose\Component\Core\JWK;
911
use Jose\Component\KeyManagement\JWKFactory;
@@ -41,7 +43,11 @@ public function addConfiguration(NodeDefinition $node): void
4143
->info('The key set service.')
4244
->isRequired()
4345
->end()
44-
->integerNode('index')
46+
->variableNode('index')
47+
->validate()
48+
->ifTrue(fn (mixed $v): bool => ! is_int($v) && ! is_string($v))
49+
->thenInvalid('Invalid keyset index.')
50+
->end()
4551
->info('The index of the key in the key set.')
4652
->isRequired()
4753
->end()

0 commit comments

Comments
 (0)