3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_FUNCTION)] class FunctionAttribute { } $closure = #[FunctionAttribute] fn() => true; class Something { public function get(Closure $closure) { return (new ReflectionFunction($closure)) ->getAttributes(FunctionAttribute::class)[0] ->newInstance(); } } (new Something)->get($closure);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iDuIL
function name:  (null)
number of ops:  8
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
    8     1        ASSIGN                                                   !0, ~1
   21     2        NEW                                              $3      'Something'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $3, 'get'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iDuIL
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   <true>
          1*     > RETURN                                                   null

End of Dynamic Function 0

Class FunctionAttribute: [no user functions]
Class Something:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iDuIL
function name:  get
number of ops:  12
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        NEW                                              $1      'ReflectionFunction'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   16     4        INIT_METHOD_CALL                                         $1, 'getAttributes'
          5        SEND_VAL_EX                                              'FunctionAttribute'
          6        DO_FCALL                                      0  $3      
          7        FETCH_DIM_R                                      ~4      $3, 0
   17     8        INIT_METHOD_CALL                                         ~4, 'newInstance'
          9        DO_FCALL                                      0  $5      
         10      > RETURN                                                   $5
   18    11*     > RETURN                                                   null

End of function get

End of class Something.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.09 ms | 1008 KiB | 13 Q