3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { public function myMethod($foo) { $reflection = new ReflectionMethod(__CLASS__, __FUNCTION__); $arg_names = []; foreach ($reflection->getParameters() as $parameter) { $arg_names[] = $parameter->name; } if (!in_array('args', $arg_names)) { echo "This is where the deprecation message would be set"; $args = func_get_args(); unset($args[0]); } echo $foo . "\n"; print_r($args); } } class ChildClass extends MyClass { public function myMethod($foo, ...$args) { $reflection = new ReflectionMethod(__CLASS__, __FUNCTION__); $arg_names = []; foreach ($reflection->getParameters() as $parameter) { $arg_names[] = $parameter->name; } if (!in_array('args', $arg_names)) { echo "This is where the deprecation message would be set"; $args = func_get_args(); unset($args[0]); } echo $foo . "\n"; print_r($args); } } $myClass = new MyClass(); $myClass->myMethod("Hi", "here", "are","some", "args"); echo "\n"; $childClass = new ChildClass(); $childClass->myMethod("Hi", "here", "are","some", "args");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FNdOm
function name:  (null)
number of ops:  22
compiled vars:  !0 = $myClass, !1 = $childClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $2      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   38     3        INIT_METHOD_CALL                                         !0, 'myMethod'
          4        SEND_VAL_EX                                              'Hi'
          5        SEND_VAL_EX                                              'here'
          6        SEND_VAL_EX                                              'are'
          7        SEND_VAL_EX                                              'some'
          8        SEND_VAL_EX                                              'args'
          9        DO_FCALL                                      0          
   39    10        ECHO                                                     '%0A'
   40    11        NEW                                              $6      'ChildClass'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $6
   41    14        INIT_METHOD_CALL                                         !1, 'myMethod'
         15        SEND_VAL_EX                                              'Hi'
         16        SEND_VAL_EX                                              'here'
         17        SEND_VAL_EX                                              'are'
         18        SEND_VAL_EX                                              'some'
         19        SEND_VAL_EX                                              'args'
         20        DO_FCALL                                      0          
         21      > RETURN                                                   1

Class MyClass:
Function mymethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 15
filename:       /in/FNdOm
function name:  myMethod
number of ops:  32
compiled vars:  !0 = $foo, !1 = $reflection, !2 = $arg_names, !3 = $parameter, !4 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        NEW                                              $5      'ReflectionMethod'
          2        SEND_VAL_EX                                              'MyClass'
          3        SEND_VAL_EX                                              'myMethod'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
    6     6        ASSIGN                                                   !2, <array>
    7     7        INIT_METHOD_CALL                                         !1, 'getParameters'
          8        DO_FCALL                                      0  $9      
          9      > FE_RESET_R                                       $10     $9, ->15
         10    > > FE_FETCH_R                                               $10, !3, ->15
    8    11    >   FETCH_OBJ_R                                      ~12     !3, 'name'
         12        ASSIGN_DIM                                               !2
         13        OP_DATA                                                  ~12
    7    14      > JMP                                                      ->10
         15    >   FE_FREE                                                  $10
   10    16        INIT_FCALL                                               'in_array'
         17        SEND_VAL                                                 'args'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $13     
         20        BOOL_NOT                                         ~14     $13
         21      > JMPZ                                                     ~14, ->26
   11    22    >   ECHO                                                     'This+is+where+the+deprecation+message+would+be+set'
   12    23        FUNC_GET_ARGS                                    ~15     
         24        ASSIGN                                                   !4, ~15
   13    25        UNSET_DIM                                                !4, 0
   15    26    >   CONCAT                                           ~17     !0, '%0A'
         27        ECHO                                                     ~17
   16    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                                 
   17    31      > RETURN                                                   null

End of function mymethod

End of class MyClass.

Class ChildClass:
Function mymethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 16
filename:       /in/FNdOm
function name:  myMethod
number of ops:  33
compiled vars:  !0 = $foo, !1 = $args, !2 = $reflection, !3 = $arg_names, !4 = $parameter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   22     2        NEW                                              $5      'ReflectionMethod'
          3        SEND_VAL_EX                                              'ChildClass'
          4        SEND_VAL_EX                                              'myMethod'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $5
   23     7        ASSIGN                                                   !3, <array>
   24     8        INIT_METHOD_CALL                                         !2, 'getParameters'
          9        DO_FCALL                                      0  $9      
         10      > FE_RESET_R                                       $10     $9, ->16
         11    > > FE_FETCH_R                                               $10, !4, ->16
   25    12    >   FETCH_OBJ_R                                      ~12     !4, 'name'
         13        ASSIGN_DIM                                               !3
         14        OP_DATA                                                  ~12
   24    15      > JMP                                                      ->11
         16    >   FE_FREE                                                  $10
   27    17        INIT_FCALL                                               'in_array'
         18        SEND_VAL                                                 'args'
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                         $13     
         21        BOOL_NOT                                         ~14     $13
         22      > JMPZ                                                     ~14, ->27
   28    23    >   ECHO                                                     'This+is+where+the+deprecation+message+would+be+set'
   29    24        FUNC_GET_ARGS                                    ~15     
         25        ASSIGN                                                   !1, ~15
   30    26        UNSET_DIM                                                !1, 0
   32    27    >   CONCAT                                           ~17     !0, '%0A'
         28        ECHO                                                     ~17
   33    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
   34    32      > RETURN                                                   null

End of function mymethod

End of class ChildClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.9 ms | 1446 KiB | 15 Q