3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {protected $a = 'A';} class B1 extends A {} class B2 extends A {protected $a = 'B';} class C extends A { public function foo(A $a) { echo $a->a; // 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); // not ok?
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TM6jk
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
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $4      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   13     3        NEW                                              $7      'B1'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
   14     6        NEW                                              $10     'B2'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $10
   15     9        NEW                                              $13     'C'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $13
   16    12        INIT_METHOD_CALL                                         !3, 'foo'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   17    15        INIT_METHOD_CALL                                         !3, 'foo'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class A: [no user functions]
Class B1: [no user functions]
Class B2: [no user functions]
Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TM6jk
function name:  foo
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        FETCH_OBJ_R                                      ~1      !0, 'a'
          2        ECHO                                                     ~1
   10     3      > RETURN                                                   null

End of function foo

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.44 ms | 1385 KiB | 13 Q