3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Magic { private $vars; public function __get($name) { return $this->get($name); } public function __set($name, $value) { $this->set($name, $value); } public function get($name) { return $this->vars[$name](); } public function set($name, $value) { $this->vars[$name] = $value; } } $magic = new Magic(); $magic->a = function () use($magic) { $magic->b; }; $magic->b = function () use ($magic) { $magic->a; // Почему тут не может найти свойство, оно ЕСТЬ смотри строку 22 (Notice) }; $magic->a; // Должна быть бесконечный вызов функций (на уровне вложенности 10 по умолчанию должна быть ошибка) // А вот тут тоже самое но без использования магии и ведет себя как надо(Fatal Error) $magic->set('a', function () use($magic) { $magic->get('b'); }); $magic->set('b', function () use($magic) { $magic->get('a'); }); $magic->get('a');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  (null)
number of ops:  29
compiled vars:  !0 = $magic
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'Magic'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8o8st%3A22%240'
          4        BIND_LEXICAL                                             ~5, !0
          5        ASSIGN_OBJ                                               !0, 'a'
   24     6        OP_DATA                                                  ~5
   25     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8o8st%3A25%241'
          8        BIND_LEXICAL                                             ~7, !0
          9        ASSIGN_OBJ                                               !0, 'b'
   27    10        OP_DATA                                                  ~7
   28    11        FETCH_OBJ_R                                      ~8      !0, 'a'
         12        FREE                                                     ~8
   31    13        INIT_METHOD_CALL                                         !0, 'set'
         14        SEND_VAL_EX                                              'a'
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8o8st%3A31%242'
         16        BIND_LEXICAL                                             ~9, !0
   33    17        SEND_VAL_EX                                              ~9
         18        DO_FCALL                                      0          
   34    19        INIT_METHOD_CALL                                         !0, 'set'
         20        SEND_VAL_EX                                              'b'
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8o8st%3A34%243'
         22        BIND_LEXICAL                                             ~11, !0
   36    23        SEND_VAL_EX                                              ~11
         24        DO_FCALL                                      0          
   37    25        INIT_METHOD_CALL                                         !0, 'get'
         26        SEND_VAL_EX                                              'a'
         27        DO_FCALL                                      0          
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8o8st%3A22%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $magic
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   BIND_STATIC                                              !0
   23     1        FETCH_OBJ_R                                      ~1      !0, 'b'
          2        FREE                                                     ~1
   24     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8o8st%3A22%240

Function %00%7Bclosure%7D%2Fin%2F8o8st%3A25%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $magic
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   BIND_STATIC                                              !0
   26     1        FETCH_OBJ_R                                      ~1      !0, 'a'
          2        FREE                                                     ~1
   27     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8o8st%3A25%241

Function %00%7Bclosure%7D%2Fin%2F8o8st%3A31%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $magic
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   BIND_STATIC                                              !0
   32     1        INIT_METHOD_CALL                                         !0, 'get'
          2        SEND_VAL_EX                                              'b'
          3        DO_FCALL                                      0          
   33     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8o8st%3A31%242

Function %00%7Bclosure%7D%2Fin%2F8o8st%3A34%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $magic
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   BIND_STATIC                                              !0
   35     1        INIT_METHOD_CALL                                         !0, 'get'
          2        SEND_VAL_EX                                              'a'
          3        DO_FCALL                                      0          
   36     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8o8st%3A34%243

Class Magic:
Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  __get
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_METHOD_CALL                                         'get'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    8     5*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  __set
number of ops:  7
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_METHOD_CALL                                         'set'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
   11     6      > RETURN                                                   null

End of function __set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  get
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'vars'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        INIT_DYNAMIC_CALL                                        ~2
          4        DO_FCALL                                      0  $3      
          5      > RETURN                                                   $3
   15     6*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8o8st
function name:  set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        FETCH_OBJ_W                                      $2      'vars'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   18     5      > RETURN                                                   null

End of function set

End of class Magic.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.04 ms | 1403 KiB | 13 Q