3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $myName; public function __set($key, $value) { if (property_exists($this, $key)) $this->$key = $value; return null; } public function __get($key) { return property_exists($this, $key) ? $this->$key : null; } public function __call($name, $arguments) { $matches = array(); $pattern = '/^set([A-Za-z0-9]+)/'; if (preg_match($pattern, $name, $matches)) { return $this->__set($this->getProp($matches[1]), $arguments[0]); } $pattern = '/^get([A-Za-z0-9]+)/'; if (preg_match($pattern, $name, $matches)) { return $this->__get($this->getProp($matches[1])); } } protected function getProp($matches) { return strtolower($matches[0]) . substr($matches, 1, strlen($matches)-1); } } $test = new Test; var_dump($test->getMyName()); $test->setMyName(25); var_dump($test->getMyName());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cb0VS
function name:  (null)
number of ops:  17
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   40     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getMyName'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   41     8        INIT_METHOD_CALL                                         !0, 'setMyName'
          9        SEND_VAL_EX                                              25
         10        DO_FCALL                                      0          
   42    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getMyName'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class Test:
Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/cb0VS
function name:  __set
number of ops:  12
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'property_exists'
          3        FETCH_THIS                                       ~2      
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7      > JMPZ                                                     $3, ->10
   10     8    >   ASSIGN_OBJ                                               !0
          9        OP_DATA                                                  !1
   11    10    > > RETURN                                                   null
   12    11*     > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cb0VS
function name:  __get
number of ops:  13
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'property_exists'
          2        FETCH_THIS                                       ~1      
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->10
          7    >   FETCH_OBJ_R                                      ~3      !0
          8        QM_ASSIGN                                        ~4      ~3
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~4      null
         11    > > RETURN                                                   ~4
   17    12*     > RETURN                                                   null

End of function __get

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cb0VS
function name:  __call
number of ops:  39
compiled vars:  !0 = $name, !1 = $arguments, !2 = $matches, !3 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        ASSIGN                                                   !2, <array>
   22     3        ASSIGN                                                   !3, '%2F%5Eset%28%5BA-Za-z0-9%5D%2B%29%2F'
   23     4        INIT_FCALL                                               'preg_match'
          5        SEND_VAR                                                 !3
          6        SEND_VAR                                                 !0
          7        SEND_REF                                                 !2
          8        DO_ICALL                                         $6      
          9      > JMPZ                                                     $6, ->22
   24    10    >   INIT_METHOD_CALL                                         '__set'
         11        INIT_METHOD_CALL                                         'getProp'
         12        CHECK_FUNC_ARG                                           
         13        FETCH_DIM_FUNC_ARG                               $7      !2, 1
         14        SEND_FUNC_ARG                                            $7
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR_NO_REF_EX                                       $8
         17        CHECK_FUNC_ARG                                           
         18        FETCH_DIM_FUNC_ARG                               $9      !1, 0
         19        SEND_FUNC_ARG                                            $9
         20        DO_FCALL                                      0  $10     
         21      > RETURN                                                   $10
   26    22    >   ASSIGN                                                   !3, '%2F%5Eget%28%5BA-Za-z0-9%5D%2B%29%2F'
   27    23        INIT_FCALL                                               'preg_match'
         24        SEND_VAR                                                 !3
         25        SEND_VAR                                                 !0
         26        SEND_REF                                                 !2
         27        DO_ICALL                                         $12     
         28      > JMPZ                                                     $12, ->38
   28    29    >   INIT_METHOD_CALL                                         '__get'
         30        INIT_METHOD_CALL                                         'getProp'
         31        CHECK_FUNC_ARG                                           
         32        FETCH_DIM_FUNC_ARG                               $13     !2, 1
         33        SEND_FUNC_ARG                                            $13
         34        DO_FCALL                                      0  $14     
         35        SEND_VAR_NO_REF_EX                                       $14
         36        DO_FCALL                                      0  $15     
         37      > RETURN                                                   $15
   30    38    > > RETURN                                                   null

End of function __call

Function getprop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cb0VS
function name:  getProp
number of ops:  15
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   34     1        INIT_FCALL                                               'strtolower'
          2        FETCH_DIM_R                                      ~1      !0, 0
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 1
          8        STRLEN                                           ~3      !0
          9        SUB                                              ~4      ~3, 1
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                         $5      
         12        CONCAT                                           ~6      $2, $5
         13      > RETURN                                                   ~6
   35    14*     > RETURN                                                   null

End of function getprop

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.67 ms | 1396 KiB | 23 Q