3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $myName; public function getMyName() { return $this->$myName; } public function __set($key, $value) { if (isset($this->$key)) $this->$key = $value; // throw new Exception() could be added here } public function __get($key) { return isset($this->$key) ? $this->$key : null; } public function __call($name, $arguments) { $matches = array(); $pattern = '/^set([A-Za-z0-9]+)/'; if (preg_match($pattern, $name, $matches)) { //var_dump($arguments, $matches); $property = $matches[1]; $property = strtolower($property[0]) . substr($property, 1, strlen($property)-1); var_dump($property, isset($this->$property)); $this->__set($property, $arguments[0]); } } } $test = new Test; $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/JEX3h
function name:  (null)
number of ops:  12
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   39     3        INIT_METHOD_CALL                                         !0, 'setMyName'
          4        SEND_VAL_EX                                              25
          5        DO_FCALL                                      0          
   40     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'getMyName'
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Class Test:
Function getmyname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JEX3h
function name:  getMyName
number of ops:  3
compiled vars:  !0 = $myName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~1      !0
          1      > RETURN                                                   ~1
   10     2*     > RETURN                                                   null

End of function getmyname

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/JEX3h
function name:  __set
number of ops:  7
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        ISSET_ISEMPTY_PROP_OBJ                                   !0
          3      > JMPZ                                                     ~2, ->6
   15     4    >   ASSIGN_OBJ                                               !0
          5        OP_DATA                                                  !1
   17     6    > > RETURN                                                   null

End of function __set

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

End of function __call

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.15 ms | 1400 KiB | 21 Q