3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Mammal { function mate(Mammal $with) { $thisClass = get_class($this); $withClass = get_class($with); $class = substr($thisClass, 0, -rand(1, strlen($thisClass) - 1)) . substr($withClass, rand(1, strlen($withClass) - 1)); eval("class $class extends Mammal {}"); return new $class; } } class Panda extends Mammal {} class Dolphin extends Mammal {} class Squirrel extends Mammal {} class Kangaroo extends Mammal {} $mingmong = new Panda; $charles = new Dolphin; $charlimong = $mingmong->mate($charles); var_dump($charlimong);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  (null)
number of ops:  14
compiled vars:  !0 = $mingmong, !1 = $charles, !2 = $charlimong
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'Panda'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        NEW                                              $6      'Dolphin'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   21     6        INIT_METHOD_CALL                                         !0, 'mate'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   23    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class Mammal:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  mate
number of ops:  39
compiled vars:  !0 = $with, !1 = $thisClass, !2 = $withClass, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_THIS                                       ~4      
          2        GET_CLASS                                        ~5      ~4
          3        ASSIGN                                                   !1, ~5
    6     4        GET_CLASS                                        ~7      !0
          5        ASSIGN                                                   !2, ~7
    7     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        INIT_FCALL                                               'rand'
         10        SEND_VAL                                                 1
         11        STRLEN                                           ~9      !1
         12        SUB                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                         $11     
         15        MUL                                              ~12     $11, -1
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'rand'
         21        SEND_VAL                                                 1
         22        STRLEN                                           ~14     !2
         23        SUB                                              ~15     ~14, 1
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     $13, $17
         29        ASSIGN                                                   !3, ~18
    8    30        ROPE_INIT                                     3  ~21     'class+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '+extends+Mammal+%7B%7D'
         33        INCLUDE_OR_EVAL                                          ~20, EVAL
    9    34        FETCH_CLASS                                   0  $24     !3
         35        NEW                                              $25     $24
         36        DO_FCALL                                      0          
         37      > RETURN                                                   $25
   10    38*     > RETURN                                                   null

End of function mate

End of class Mammal.

Class Panda:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  mate
number of ops:  39
compiled vars:  !0 = $with, !1 = $thisClass, !2 = $withClass, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_THIS                                       ~4      
          2        GET_CLASS                                        ~5      ~4
          3        ASSIGN                                                   !1, ~5
    6     4        GET_CLASS                                        ~7      !0
          5        ASSIGN                                                   !2, ~7
    7     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        INIT_FCALL                                               'rand'
         10        SEND_VAL                                                 1
         11        STRLEN                                           ~9      !1
         12        SUB                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                         $11     
         15        MUL                                              ~12     $11, -1
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'rand'
         21        SEND_VAL                                                 1
         22        STRLEN                                           ~14     !2
         23        SUB                                              ~15     ~14, 1
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     $13, $17
         29        ASSIGN                                                   !3, ~18
    8    30        ROPE_INIT                                     3  ~21     'class+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '+extends+Mammal+%7B%7D'
         33        INCLUDE_OR_EVAL                                          ~20, EVAL
    9    34        FETCH_CLASS                                   0  $24     !3
         35        NEW                                              $25     $24
         36        DO_FCALL                                      0          
         37      > RETURN                                                   $25
   10    38*     > RETURN                                                   null

End of function mate

End of class Panda.

Class Dolphin:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  mate
number of ops:  39
compiled vars:  !0 = $with, !1 = $thisClass, !2 = $withClass, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_THIS                                       ~4      
          2        GET_CLASS                                        ~5      ~4
          3        ASSIGN                                                   !1, ~5
    6     4        GET_CLASS                                        ~7      !0
          5        ASSIGN                                                   !2, ~7
    7     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        INIT_FCALL                                               'rand'
         10        SEND_VAL                                                 1
         11        STRLEN                                           ~9      !1
         12        SUB                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                         $11     
         15        MUL                                              ~12     $11, -1
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'rand'
         21        SEND_VAL                                                 1
         22        STRLEN                                           ~14     !2
         23        SUB                                              ~15     ~14, 1
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     $13, $17
         29        ASSIGN                                                   !3, ~18
    8    30        ROPE_INIT                                     3  ~21     'class+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '+extends+Mammal+%7B%7D'
         33        INCLUDE_OR_EVAL                                          ~20, EVAL
    9    34        FETCH_CLASS                                   0  $24     !3
         35        NEW                                              $25     $24
         36        DO_FCALL                                      0          
         37      > RETURN                                                   $25
   10    38*     > RETURN                                                   null

End of function mate

End of class Dolphin.

Class Squirrel:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  mate
number of ops:  39
compiled vars:  !0 = $with, !1 = $thisClass, !2 = $withClass, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_THIS                                       ~4      
          2        GET_CLASS                                        ~5      ~4
          3        ASSIGN                                                   !1, ~5
    6     4        GET_CLASS                                        ~7      !0
          5        ASSIGN                                                   !2, ~7
    7     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        INIT_FCALL                                               'rand'
         10        SEND_VAL                                                 1
         11        STRLEN                                           ~9      !1
         12        SUB                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                         $11     
         15        MUL                                              ~12     $11, -1
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'rand'
         21        SEND_VAL                                                 1
         22        STRLEN                                           ~14     !2
         23        SUB                                              ~15     ~14, 1
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     $13, $17
         29        ASSIGN                                                   !3, ~18
    8    30        ROPE_INIT                                     3  ~21     'class+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '+extends+Mammal+%7B%7D'
         33        INCLUDE_OR_EVAL                                          ~20, EVAL
    9    34        FETCH_CLASS                                   0  $24     !3
         35        NEW                                              $25     $24
         36        DO_FCALL                                      0          
         37      > RETURN                                                   $25
   10    38*     > RETURN                                                   null

End of function mate

End of class Squirrel.

Class Kangaroo:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KW2uq
function name:  mate
number of ops:  39
compiled vars:  !0 = $with, !1 = $thisClass, !2 = $withClass, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_THIS                                       ~4      
          2        GET_CLASS                                        ~5      ~4
          3        ASSIGN                                                   !1, ~5
    6     4        GET_CLASS                                        ~7      !0
          5        ASSIGN                                                   !2, ~7
    7     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 0
          9        INIT_FCALL                                               'rand'
         10        SEND_VAL                                                 1
         11        STRLEN                                           ~9      !1
         12        SUB                                              ~10     ~9, 1
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                         $11     
         15        MUL                                              ~12     $11, -1
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'rand'
         21        SEND_VAL                                                 1
         22        STRLEN                                           ~14     !2
         23        SUB                                              ~15     ~14, 1
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     $13, $17
         29        ASSIGN                                                   !3, ~18
    8    30        ROPE_INIT                                     3  ~21     'class+'
         31        ROPE_ADD                                      1  ~21     ~21, !3
         32        ROPE_END                                      2  ~20     ~21, '+extends+Mammal+%7B%7D'
         33        INCLUDE_OR_EVAL                                          ~20, EVAL
    9    34        FETCH_CLASS                                   0  $24     !3
         35        NEW                                              $25     $24
         36        DO_FCALL                                      0          
         37      > RETURN                                                   $25
   10    38*     > RETURN                                                   null

End of function mate

End of class Kangaroo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.2 ms | 1417 KiB | 19 Q