3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected function get() { return 'A'; } } class B1 extends A {} class B2 extends A { protected function get() { return 'A'; } } class C extends A { public function foo(A $a) { echo $a->get(); // will fail depends on $a implementation // liskov substitution principle failed } } $a = new A(); $b1 = new B1(); $b2 = new B2(); $c = new C(); $c->foo($b1); // ok $c->foo($b2); // ok
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSCKW
function name:  (null)
number of ops:  19
compiled vars:  !0 = $a, !1 = $b1, !2 = $b2, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $4      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   21     3        NEW                                              $7      'B1'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
   22     6        NEW                                              $10     'B2'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $10
   23     9        NEW                                              $13     'C'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $13
   24    12        INIT_METHOD_CALL                                         !3, 'foo'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   25    15        INIT_METHOD_CALL                                         !3, 'foo'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

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

End of function get

End of class A.

Class B1:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSCKW
function name:  get
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   'A'
    6     1*     > RETURN                                                   null

End of function get

End of class B1.

Class B2:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSCKW
function name:  get
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   'A'
   12     1*     > RETURN                                                   null

End of function get

End of class B2.

Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NSCKW
function name:  foo
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_METHOD_CALL                                         !0, 'get'
          2        DO_FCALL                                      0  $1      
          3        ECHO                                                     $1
   18     4      > RETURN                                                   null

End of function foo

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

End of function get

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.8 ms | 1002 KiB | 13 Q