|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78677 Parameter Type Widening not properly documented
Submitted: 2019-10-17 07:41 UTC Modified: 2020-03-12 15:01 UTC
From: pavel at bunaev dot ru Assigned: tiffany (profile)
Status: Closed Package: Class/Object related
PHP Version: 7.2.23 OS: 18.04.1-Ubuntu
Private report: No CVE-ID: None
 [2019-10-17 07:41 UTC] pavel at bunaev dot ru
The interface allows you to change the type of variable in an incompatible direction.

In versions php 7.0+ and 7.1-, we could specify in the interface with what types of data we will work in the method.
And at the kernel level, be sure that by implementing the interface the signature will not change.

In version php 7.2+ and 7.3+, this has changed and there was no announcement ..
We can create an interface and expect in the signature that the method will work with certain arguments

but in fact we can transfer anything

OS linux
version php 7.2+

version php 7.1- is ok

Test script:
interface IBaz {};
interface IFoo {
    public function simple(IBaz $a);

class CFoo implements IFoo {
    public function simple($a){

$cFoo = new CFoo();

Expected result:
<br />
<b>Fatal error</b>:  Declaration of CFoo::simple($a) must be compatible with IFoo::simple(IBaz $a) in <b>[...][...]</b> on line <b>7</b><br />

Actual result:
string(4) "vbvc"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-17 08:02 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2019-10-17 08:02 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

See <>.
 [2019-10-17 08:04 UTC]
-Summary: Interface declaration of ... unexpected behavior +Summary: Parameter Type Widening not properly documented -Status: Not a bug +Status: Open -Type: Bug +Type: Documentation Problem -Package: *Programming Data Structures +Package: Class/Object related -Assigned To: cmb +Assigned To:
 [2019-10-17 08:04 UTC]
While this might be documented better, this is definitely not a bug, see
 [2019-10-17 08:05 UTC]
@cmb shouldn't this functionality also be documented on ?
 [2019-10-17 09:12 UTC]
Well, there is a note in the Interfaces section[1], but this is
only correct for PHP 7.2 and up (and even too general for 7.2),
and it doesn't cater to inheritance in general.  It seems to me
that this should be documented in the Inheritance section[2]; we
could link to that section from other parts of the manual where

[1] <>
[2] <>
 [2019-10-17 10:53 UTC] pavel at bunaev dot ru
-Status: Open +Status: Closed
 [2019-10-17 10:53 UTC] pavel at bunaev dot ru
Indeed, this is not a bug.
Somehow I missed this point in the documentation :(

I apologize for wasting your time in vain

Thanks for the clarification.
 [2019-10-17 14:20 UTC]
-Status: Closed +Status: Verified
 [2019-10-17 14:20 UTC]
reopening as a documentation bug
 [2020-02-20 13:04 UTC]
-Assigned To: +Assigned To: tiffany
 [2020-03-12 14:56 UTC]
This bug is fixed with the recent revision:
 [2020-03-12 15:01 UTC]
-Status: Verified +Status: Closed
 [2020-03-12 15:01 UTC]
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from and re-test.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 19:01:30 2024 UTC