3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait TraitName{ public function check(){ $parent = get_parent_class($this); if($parent && array_key_exists(__TRAIT__, class_uses($parent))){ echo 'Rodzic mówi: '.parent::sayHello().'.'; }else{ echo 'Rodzic nie posiada cechy '.__TRAIT__; } echo ' Obecna klasa to: '.__CLASS__; echo '. To jest działanie cechy '.__TRAIT__; } abstract public function sayHello(); } class Base{ use TraitName; protected function sayHello(){ return "'Witaj świecie!'"; } } class MyClass extends Base{ use TraitName; public function sayHello(){ return " 'Dobrze Cię widzieć stary przyjacielu!'"; } } $objBase = new Base(); $objBase->check(); $objMyClass = new MyClass(); $objMyClass->check();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/acV8m
function name:  (null)
number of ops:  13
compiled vars:  !0 = $objBase, !1 = $objMyClass
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   DECLARE_CLASS                                                'base'
   26     1        DECLARE_CLASS                                                'myclass', 'base'
   35     2        NEW                                                  $2      'Base'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   36     5        INIT_METHOD_CALL                                             !0, 'check'
          6        DO_FCALL                                          0          
   37     7        NEW                                                  $6      'MyClass'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $6
   38    10        INIT_METHOD_CALL                                             !1, 'check'
         11        DO_FCALL                                          0          
         12      > RETURN                                                       1

Class TraitName:
Function check:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/acV8m
function name:  check
number of ops:  24
compiled vars:  !0 = $parent
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                                   'get_parent_class'
          1        FETCH_THIS                                           ~1      
          2        SEND_VAL                                                     ~1
          3        DO_ICALL                                             $2      
          4        ASSIGN                                                       !0, $2
    6     5      > JMPZ_EX                                              ~4      !0, ->11
          6    >   INIT_FCALL                                                   'class_uses'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $5      
          9        ARRAY_KEY_EXISTS                                     ~6      'TraitName', $5
         10        BOOL                                                 ~4      ~6
         11    > > JMPZ                                                         ~4, ->18
    7    12    >   INIT_STATIC_METHOD_CALL                                      'sayHello'
         13        DO_FCALL                                          0  $7      
         14        CONCAT                                               ~8      'Rodzic+m%C3%B3wi%3A+', $7
         15        CONCAT                                               ~9      ~8, '.'
         16        ECHO                                                         ~9
    6    17      > JMP                                                          ->19
    9    18    >   ECHO                                                         'Rodzic+nie+posiada+cechy+TraitName'
   11    19    >   FETCH_CLASS_NAME                                     ~10     
         20        CONCAT                                               ~11     '+Obecna+klasa+to%3A+', ~10
         21        ECHO                                                         ~11
   12    22        ECHO                                                         '.+To+jest+dzia%C5%82anie+cechy+TraitName'
   13    23      > RETURN                                                       null

End of function check

Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/acV8m
function name:  sayHello
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                       null

End of function sayhello

End of class TraitName.

Class Base:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/acV8m
function name:  sayHello
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E > > RETURN                                                       '%27Witaj+%C5%9Bwiecie%21%27'
   23     1*     > RETURN                                                       null

End of function sayhello

End of class Base.

Class MyClass:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/acV8m
function name:  sayHello
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E > > RETURN                                                       '+%27Dobrze+Ci%C4%99+widzie%C4%87+stary+przyjacielu%21%27'
   32     1*     > RETURN                                                       null

End of function sayhello

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.29 ms | 2694 KiB | 15 Q