3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface HasMethodReturnIntOrString { public function methodA(): int|string; } interface HasMethodReturnIntOrFloat { public function methodA(): int|float; } /** * 返り値が int|string 型であるメソッド methodA の実装を約束するインターフェイスと * 返り値が int|float 型であるメソッド methodA の実装を約束するインターフェイスの * 両方を実装するクラス */ class HasMethodReturnInt implements HasMethodReturnIntOrString, HasMethodReturnIntOrFloat { /** * 返り値が int|string 型 と int|float 型の両方を満たすメソッド * つまり (int|string) & (int|float) の計算結果である int 型の値を返すメソッド * @return int */ public function methodA(): int { return 0; } // 片方の型を満たせない場合↓の様にPHPがエラーを出力します // Fatal error: Declaration of HasMethodReturnInt::methodA(): string must be compatible with HasMethodReturnStringOrFloat::methodA(): int|float in ***\tmp.php on line 28 // public function methodA(): string|int // { // return 0; // } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MjGI
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_CLASS                                            'hasmethodreturnint'
   35     1      > RETURN                                                   1

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

End of function methoda

End of class HasMethodReturnIntOrString.

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

End of function methoda

End of class HasMethodReturnIntOrFloat.

Class HasMethodReturnInt:
Function methoda:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MjGI
function name:  methodA
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E > > RETURN                                                   0
   27     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function methoda

End of class HasMethodReturnInt.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140 ms | 1448 KiB | 13 Q