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; $suqidgy = new Squirrel; $wanger = new Kangeroo; $charlimong = $mingmong->mate($charles); $wangy = $wanger->mate($squidgy); $wangimong = $wanger->mate($charlimong); var_dump($wangimong);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lERMX
function name:  (null)
number of ops:  28
compiled vars:  !0 = $mingmong, !1 = $charles, !2 = $suqidgy, !3 = $wanger, !4 = $charlimong, !5 = $wangy, !6 = $squidgy, !7 = $wangimong
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $8      'Panda'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $8
   19     3        NEW                                              $11     'Dolphin'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $11
   20     6        NEW                                              $14     'Squirrel'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $14
   21     9        NEW                                              $17     'Kangeroo'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $17
   23    12        INIT_METHOD_CALL                                         !0, 'mate'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0  $20     
         15        ASSIGN                                                   !4, $20
   24    16        INIT_METHOD_CALL                                         !3, 'mate'
         17        SEND_VAR_EX                                              !6
         18        DO_FCALL                                      0  $22     
         19        ASSIGN                                                   !5, $22
   26    20        INIT_METHOD_CALL                                         !3, 'mate'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0  $24     
         23        ASSIGN                                                   !7, $24
   28    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !7
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class Mammal:
Function mate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lERMX
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/lERMX
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/lERMX
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/lERMX
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/lERMX
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:
153.56 ms | 1416 KiB | 19 Q