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/i9Jh2
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/i9Jh2
function name:  mate
number of ops:  41
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        FETCH_CONSTANT                                   ~9      'thisClass'
          8        SEND_VAL                                                 ~9
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 1
         12        FETCH_CONSTANT                                   ~10     'thisClass'
         13        STRLEN                                           ~11     ~10
         14        SUB                                              ~12     ~11, 1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        MUL                                              ~14     $13, -1
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'rand'
         23        SEND_VAL                                                 1
         24        STRLEN                                           ~16     !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        CONCAT                                           ~20     $15, $19
         31        ASSIGN                                                   !3, ~20
    8    32        ROPE_INIT                                     3  ~23     'class+'
         33        ROPE_ADD                                      1  ~23     ~23, !3
         34        ROPE_END                                      2  ~22     ~23, '+extends+Mammal+%7B%7D'
         35        INCLUDE_OR_EVAL                                          ~22, EVAL
    9    36        FETCH_CLASS                                   0  $26     !3
         37        NEW                                              $27     $26
         38        DO_FCALL                                      0          
         39      > RETURN                                                   $27
   10    40*     > 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/i9Jh2
function name:  mate
number of ops:  41
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        FETCH_CONSTANT                                   ~9      'thisClass'
          8        SEND_VAL                                                 ~9
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 1
         12        FETCH_CONSTANT                                   ~10     'thisClass'
         13        STRLEN                                           ~11     ~10
         14        SUB                                              ~12     ~11, 1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        MUL                                              ~14     $13, -1
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'rand'
         23        SEND_VAL                                                 1
         24        STRLEN                                           ~16     !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        CONCAT                                           ~20     $15, $19
         31        ASSIGN                                                   !3, ~20
    8    32        ROPE_INIT                                     3  ~23     'class+'
         33        ROPE_ADD                                      1  ~23     ~23, !3
         34        ROPE_END                                      2  ~22     ~23, '+extends+Mammal+%7B%7D'
         35        INCLUDE_OR_EVAL                                          ~22, EVAL
    9    36        FETCH_CLASS                                   0  $26     !3
         37        NEW                                              $27     $26
         38        DO_FCALL                                      0          
         39      > RETURN                                                   $27
   10    40*     > 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/i9Jh2
function name:  mate
number of ops:  41
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        FETCH_CONSTANT                                   ~9      'thisClass'
          8        SEND_VAL                                                 ~9
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 1
         12        FETCH_CONSTANT                                   ~10     'thisClass'
         13        STRLEN                                           ~11     ~10
         14        SUB                                              ~12     ~11, 1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        MUL                                              ~14     $13, -1
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'rand'
         23        SEND_VAL                                                 1
         24        STRLEN                                           ~16     !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        CONCAT                                           ~20     $15, $19
         31        ASSIGN                                                   !3, ~20
    8    32        ROPE_INIT                                     3  ~23     'class+'
         33        ROPE_ADD                                      1  ~23     ~23, !3
         34        ROPE_END                                      2  ~22     ~23, '+extends+Mammal+%7B%7D'
         35        INCLUDE_OR_EVAL                                          ~22, EVAL
    9    36        FETCH_CLASS                                   0  $26     !3
         37        NEW                                              $27     $26
         38        DO_FCALL                                      0          
         39      > RETURN                                                   $27
   10    40*     > 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/i9Jh2
function name:  mate
number of ops:  41
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        FETCH_CONSTANT                                   ~9      'thisClass'
          8        SEND_VAL                                                 ~9
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 1
         12        FETCH_CONSTANT                                   ~10     'thisClass'
         13        STRLEN                                           ~11     ~10
         14        SUB                                              ~12     ~11, 1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        MUL                                              ~14     $13, -1
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'rand'
         23        SEND_VAL                                                 1
         24        STRLEN                                           ~16     !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        CONCAT                                           ~20     $15, $19
         31        ASSIGN                                                   !3, ~20
    8    32        ROPE_INIT                                     3  ~23     'class+'
         33        ROPE_ADD                                      1  ~23     ~23, !3
         34        ROPE_END                                      2  ~22     ~23, '+extends+Mammal+%7B%7D'
         35        INCLUDE_OR_EVAL                                          ~22, EVAL
    9    36        FETCH_CLASS                                   0  $26     !3
         37        NEW                                              $27     $26
         38        DO_FCALL                                      0          
         39      > RETURN                                                   $27
   10    40*     > 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/i9Jh2
function name:  mate
number of ops:  41
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        FETCH_CONSTANT                                   ~9      'thisClass'
          8        SEND_VAL                                                 ~9
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 1
         12        FETCH_CONSTANT                                   ~10     'thisClass'
         13        STRLEN                                           ~11     ~10
         14        SUB                                              ~12     ~11, 1
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        MUL                                              ~14     $13, -1
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'rand'
         23        SEND_VAL                                                 1
         24        STRLEN                                           ~16     !2
         25        SUB                                              ~17     ~16, 1
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        DO_ICALL                                         $19     
         30        CONCAT                                           ~20     $15, $19
         31        ASSIGN                                                   !3, ~20
    8    32        ROPE_INIT                                     3  ~23     'class+'
         33        ROPE_ADD                                      1  ~23     ~23, !3
         34        ROPE_END                                      2  ~22     ~23, '+extends+Mammal+%7B%7D'
         35        INCLUDE_OR_EVAL                                          ~22, EVAL
    9    36        FETCH_CLASS                                   0  $26     !3
         37        NEW                                              $27     $26
         38        DO_FCALL                                      0          
         39      > RETURN                                                   $27
   10    40*     > RETURN                                                   null

End of function mate

End of class Kangaroo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.93 ms | 1416 KiB | 19 Q