3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Mammal { function mate(Mammal $with) { $class = substr(get_class($this), -1) . substr(get_class($with), 1); eval("class $class extends Mammal {}"); return new $class; } } class Panda extends Mammal {} class Dolphin 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/X2cHv
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      'Panda'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   15     3        NEW                                              $6      'Dolphin'
          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/X2cHv
function name:  mate
number of ops:  23
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      ~2
          4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 -1
          6        DO_ICALL                                         $4      
          7        INIT_FCALL                                               'substr'
          8        GET_CLASS                                        ~5      !0
          9        SEND_VAL                                                 ~5
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $6      
         12        CONCAT                                           ~7      $4, $6
         13        ASSIGN                                                   !1, ~7
    6    14        ROPE_INIT                                     3  ~10     'class+'
         15        ROPE_ADD                                      1  ~10     ~10, !1
         16        ROPE_END                                      2  ~9      ~10, '+extends+Mammal+%7B%7D'
         17        INCLUDE_OR_EVAL                                          ~9, EVAL
    7    18        FETCH_CLASS                                   0  $13     !1
         19        NEW                                              $14     $13
         20        DO_FCALL                                      0          
         21      > RETURN                                                   $14
    8    22*     > 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/X2cHv
function name:  mate
number of ops:  23
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      ~2
          4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 -1
          6        DO_ICALL                                         $4      
          7        INIT_FCALL                                               'substr'
          8        GET_CLASS                                        ~5      !0
          9        SEND_VAL                                                 ~5
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $6      
         12        CONCAT                                           ~7      $4, $6
         13        ASSIGN                                                   !1, ~7
    6    14        ROPE_INIT                                     3  ~10     'class+'
         15        ROPE_ADD                                      1  ~10     ~10, !1
         16        ROPE_END                                      2  ~9      ~10, '+extends+Mammal+%7B%7D'
         17        INCLUDE_OR_EVAL                                          ~9, EVAL
    7    18        FETCH_CLASS                                   0  $13     !1
         19        NEW                                              $14     $13
         20        DO_FCALL                                      0          
         21      > RETURN                                                   $14
    8    22*     > 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/X2cHv
function name:  mate
number of ops:  23
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      ~2
          4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 -1
          6        DO_ICALL                                         $4      
          7        INIT_FCALL                                               'substr'
          8        GET_CLASS                                        ~5      !0
          9        SEND_VAL                                                 ~5
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $6      
         12        CONCAT                                           ~7      $4, $6
         13        ASSIGN                                                   !1, ~7
    6    14        ROPE_INIT                                     3  ~10     'class+'
         15        ROPE_ADD                                      1  ~10     ~10, !1
         16        ROPE_END                                      2  ~9      ~10, '+extends+Mammal+%7B%7D'
         17        INCLUDE_OR_EVAL                                          ~9, EVAL
    7    18        FETCH_CLASS                                   0  $13     !1
         19        NEW                                              $14     $13
         20        DO_FCALL                                      0          
         21      > RETURN                                                   $14
    8    22*     > RETURN                                                   null

End of function mate

End of class Dolphin.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.36 ms | 1396 KiB | 17 Q