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());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fOejp
function name:  (null)
number of ops:  18
compiled vars:  !0 = $testRoute, !1 = $reflection, !2 = $routeAttributes
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   NEW                                                  $3      'TestRoute'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $3
   21     3        NEW                                                  $6      'ReflectionObject'
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $6
   23     7        INIT_METHOD_CALL                                             !1, 'getAttributes'
          8        SEND_VAL_EX                                                  'Route'
          9        DO_FCALL                                          0  $9      
         10        ASSIGN                                                       !2, $9
   25    11        INIT_FCALL                                                   'var_dump'
         12        FETCH_DIM_R                                          ~11     !2, 0
         13        INIT_METHOD_CALL                                             ~11, 'getArguments'
         14        DO_FCALL                                          0  $12     
         15        SEND_VAR                                                     $12
         16        DO_ICALL                                                     
         17      > RETURN                                                       1

Class Route:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fOejp
function name:  __construct
number of ops:  4
compiled vars:  !0 = $serializationGroups
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV_INIT                                            !0      null
          1        ASSIGN_OBJ                                                   'serializationGroups'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       null

End of function __construct

End of class Route.

Class TestRoute: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.59 ms | 1522 KiB | 14 Q