3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] final class Route { public function __construct(public ?string $serializationGroups = null) {} } #[Route( name: 'show_book_with_serialization_groups', path: '/book/{id}', controller: 'app.controller.book:showAction', serializationGroups: ['sylius'] )] final class TestRoute {} $testRoute = new TestRoute; $reflection = new ReflectionObject($testRoute); $routeAttributes = $reflection->getAttributes(Route::class); var_dump($routeAttributes[0]->getArguments());
Output for 8.0.15, 8.1.23 - 8.1.34, 8.2.10 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
array(4) { ["name"]=> string(35) "show_book_with_serialization_groups" ["path"]=> string(10) "/book/{id}" ["controller"]=> string(30) "app.controller.book:showAction" ["serializationGroups"]=> array(1) { [0]=> string(6) "sylius" } }

preferences:
71.89 ms | 901 KiB | 4 Q