3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $name; public $lastName; private $methods = array(); public function __construct($namae,$myozi) { $this->name = $namae; $this->lastName = $myozi; } function method() { return print "姓:".$this->lastName."名:".$this->name; } public function registerMethod($name, Closure $method) { $this->methods[$name] = $method; } public function __call($name, $arguments) { if (array_key_exists($name, $this->methods)) { $this->methods[$name](); } else { throw new BadMethodCallException('No such method: ' . $name); } } } $test = new Test("太郎","田中"); $test->registerMethod( 'aaaa', function() { print 'aaaa'; } ); $test->aaaa(); $test->bbbb();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2sdnJ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'Test'
          1        SEND_VAL_EX                                              '%E5%A4%AA%E9%83%8E'
          2        SEND_VAL_EX                                              '%E7%94%B0%E4%B8%AD'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   32     5        INIT_METHOD_CALL                                         !0, 'registerMethod'
   33     6        SEND_VAL_EX                                              'aaaa'
   34     7        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   36     8        SEND_VAL_EX                                              ~4
   32     9        DO_FCALL                                      0          
   39    10        INIT_METHOD_CALL                                         !0, 'aaaa'
         11        DO_FCALL                                      0          
   40    12        INIT_METHOD_CALL                                         !0, 'bbbb'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2sdnJ
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ECHO                                                     'aaaa'
   36     1      > RETURN                                                   null

End of Dynamic Function 0

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2sdnJ
function name:  __construct
number of ops:  7
compiled vars:  !0 = $namae, !1 = $myozi
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN_OBJ                                               'name'
          3        OP_DATA                                                  !0
   10     4        ASSIGN_OBJ                                               'lastName'
          5        OP_DATA                                                  !1
   11     6      > RETURN                                                   null

End of function __construct

Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2sdnJ
function name:  method
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'lastName'
          1        CONCAT                                           ~1      '%E5%A7%93%3A', ~0
          2        CONCAT                                           ~2      ~1, '%E5%90%8D%3A'
          3        FETCH_OBJ_R                                      ~3      'name'
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
          6      > RETURN                                                   1
   15     7*     > RETURN                                                   null

End of function method

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

End of function registermethod

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/2sdnJ
function name:  __call
number of ops:  16
compiled vars:  !0 = $name, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        FETCH_OBJ_R                                      ~2      'methods'
          3        ARRAY_KEY_EXISTS                                         !0, ~2
          4      > JMPZ                                                     ~3, ->10
   23     5    >   FETCH_OBJ_R                                      ~4      'methods'
          6        FETCH_DIM_R                                      ~5      ~4, !0
          7        INIT_DYNAMIC_CALL                                        ~5
          8        DO_FCALL                                      0          
   22     9      > JMP                                                      ->15
   25    10    >   NEW                                              $7      'BadMethodCallException'
         11        CONCAT                                           ~8      'No+such+method%3A+', !0
         12        SEND_VAL_EX                                              ~8
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $7
   27    15    > > RETURN                                                   null

End of function __call

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.09 ms | 1000 KiB | 13 Q