3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const X = [ 'code' => 101, 'reason' => 'reason 101', ]; const Y = [ 'code' => 102, 'reason' => 'reason 102', ]; public function getFooConstant($code) { $class = new \ReflectionClass(__CLASS__); $constants = $class->getConstants(); var_dump( $constants ); return array_filter($constants, function($v, $k) use ($code) { return $v['code'] == $code; }, ARRAY_FILTER_USE_BOTH); } } $foo = new Foo(); var_dump( $foo->getFooConstant(101) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ek6ga
function name:  (null)
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   31     3        INIT_FCALL                                               'var_dump'
   32     4        INIT_METHOD_CALL                                         !0, 'getFooConstant'
          5        SEND_VAL_EX                                              101
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   33     9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fek6ga%3A24%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ek6ga
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v, !1 = $k, !2 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   25     3        FETCH_DIM_R                                      ~3      !0, 'code'
          4        IS_EQUAL                                         ~4      !2, ~3
          5      > RETURN                                                   ~4
   26     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fek6ga%3A24%240

Class Foo:
Function getfooconstant:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ek6ga
function name:  getFooConstant
number of ops:  20
compiled vars:  !0 = $code, !1 = $class, !2 = $constants
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        NEW                                              $3      'ReflectionClass'
          2        SEND_VAL_EX                                              'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   18     5        INIT_METHOD_CALL                                         !1, 'getConstants'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   20     8        INIT_FCALL                                               'var_dump'
   21     9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
   24    11        INIT_FCALL                                               'array_filter'
         12        SEND_VAR                                                 !2
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fek6ga%3A24%240'
         14        BIND_LEXICAL                                             ~9, !0
   26    15        SEND_VAL                                                 ~9
         16        SEND_VAL                                                 1
         17        DO_ICALL                                         $10     
         18      > RETURN                                                   $10
   27    19*     > RETURN                                                   null

End of function getfooconstant

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.37 ms | 1400 KiB | 17 Q