3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Mammal { function mate(Mammal $with) { $class = substr($this.get_class(), 0, -1) . substr($with.get_class(), 1); eval("class $class extends Mammal {}"); return new $class; } } class Cheval extends Mammal {} class Poney extends Mammal {} $mingmong = new Cheval; $charles = new Poney; $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/YPcll
function name:  (null)
number of ops:  14
compiled vars:  !0 = $mingmong, !1 = $charles, !2 = $charlimong
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $3      'Cheval'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   15     3        NEW                                              $6      'Poney'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   17     6        INIT_METHOD_CALL                                         !0, 'mate'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   19    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/YPcll
function name:  mate
number of ops:  26
compiled vars:  !0 = $with, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'substr'
          2        FETCH_THIS                                       ~2      
          3        GET_CLASS                                        ~3      
          4        CONCAT                                           ~4      ~2, ~3
          5        SEND_VAL                                                 ~4
          6        SEND_VAL                                                 0
          7        SEND_VAL                                                 -1
          8        DO_ICALL                                         $5      
          9        INIT_FCALL                                               'substr'
         10        GET_CLASS                                        ~6      
         11        CONCAT                                           ~7      !0, ~6
         12        SEND_VAL                                                 ~7
         13        SEND_VAL                                                 1
         14        DO_ICALL                                         $8      
         15        CONCAT                                           ~9      $5, $8
         16        ASSIGN                                                   !1, ~9
    6    17        ROPE_INIT                                     3  ~12     'class+'
         18        ROPE_ADD                                      1  ~12     ~12, !1
         19        ROPE_END                                      2  ~11     ~12, '+extends+Mammal+%7B%7D'
         20        INCLUDE_OR_EVAL                                          ~11, EVAL
    7    21        FETCH_CLASS                                   0  $15     !1
         22        NEW                                              $16     $15
         23        DO_FCALL                                      0          
         24      > RETURN                                                   $16
    8    25*     > RETURN                                                   null

End of function mate

End of class Mammal.

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

End of function mate

End of class Cheval.

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

End of function mate

End of class Poney.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.06 ms | 1409 KiB | 17 Q