3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = [ "testA" => true, "testB" => 22, 0 => 0 ]; class Processor { public $systemVarA; public $systemVarB; private function validators() { return [ 'testA' => function($value) { if (!is_bool($value)) throw new \Exception( "Configuration '$name' must be boolean."); $this->systemVarA = $value; }, 'testB' => function($value) { if (!is_int($value)) throw new \Exception( "Configuration '$name' must be integer."); $this->systemVarB = $value; } ]; } public function validate($array) { $validators = $this->validators(); foreach($array as $key => $value) if(is_callable($validators[$key])) $validators[$key]($value); } } $proc = new Processor; $proc->validate($config); var_dump($proc);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYHWA
function name:  (null)
number of ops:  11
compiled vars:  !0 = $config, !1 = $proc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        NEW                                              $3      'Processor'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   37     4        INIT_METHOD_CALL                                         !1, 'validate'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   38     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class Processor:
Function validators:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYHWA
function name:  validators
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_LAMBDA_FUNCTION                          ~0      [0]
   20     1        INIT_ARRAY                                       ~1      ~0, 'testA'
   21     2        DECLARE_LAMBDA_FUNCTION                          ~2      [1]
   24     3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'testB'
          4      > RETURN                                                   ~1
   26     5*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYHWA
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $value, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        TYPE_CHECK                                   12  ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->11
          4    >   NEW                                              $4      'Exception'
          5        ROPE_INIT                                     3  ~6      'Configuration+%27'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%27+must+be+boolean.'
          8        SEND_VAL_EX                                              ~5
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $4
   19    11    >   FETCH_THIS                                       $9      
         12        ASSIGN_OBJ                                               $9, 'systemVarA'
         13        OP_DATA                                                  !0
   20    14      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYHWA
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $value, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        TYPE_CHECK                                   16  ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->11
          4    >   NEW                                              $4      'Exception'
          5        ROPE_INIT                                     3  ~6      'Configuration+%27'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%27+must+be+integer.'
          8        SEND_VAL_EX                                              ~5
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $4
   23    11    >   FETCH_THIS                                       $9      
         12        ASSIGN_OBJ                                               $9, 'systemVarB'
         13        OP_DATA                                                  !0
   24    14      > RETURN                                                   null

End of Dynamic Function 1

End of function validators

Function validate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/uYHWA
function name:  validate
number of ops:  19
compiled vars:  !0 = $array, !1 = $validators, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        INIT_METHOD_CALL                                         'validators'
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !1, $4
   30     4      > FE_RESET_R                                       $6      !0, ->17
          5    > > FE_FETCH_R                                       ~7      $6, !2, ->17
          6    >   ASSIGN                                                   !3, ~7
   31     7        INIT_FCALL                                               'is_callable'
          8        FETCH_DIM_R                                      ~9      !1, !3
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11      > JMPZ                                                     $10, ->16
   32    12    >   FETCH_DIM_R                                      ~11     !1, !3
         13        INIT_DYNAMIC_CALL                                        ~11
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
   30    16    > > JMP                                                      ->5
         17    >   FE_FREE                                                  $6
   33    18      > RETURN                                                   null

End of function validate

End of class Processor.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
278.01 ms | 1020 KiB | 15 Q