|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77507 No fatal error when implementing interface method with parameter type declared
Submitted: 2019-01-23 10:37 UTC Modified: 2019-01-23 11:22 UTC
From: a dot owrew at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.2.14 OS: Linux
Private report: No CVE-ID: None
 [2019-01-23 10:37 UTC] a dot owrew at gmail dot com
As it states in the summary, up until PHP 7.1.26, implementing an interface method without providing the full signature would cause a fatal error. Starting PHP 7.2.0 it appears to be more lax. In the example, the missing string parameter type is causing a fatal error prior to PHP 7.2.0.

Test script:

interface SomeInterface {
    public function setSome(string $some);

class SomeClass implements SomeInterface {
    public function setSome($some){}

Expected result:
Fatal error: Declaration of SomeClass::setSome($some) must be compatible with SomeInterface::setSome(string $some)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-23 11:22 UTC]
-Status: Open +Status: Closed -Package: PHP Language Specification +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2019-01-23 11:22 UTC]
This is a deliberate change[1], mostly to accommodate libraries
which want to add paramter type hints without breaking existing
clients.  It is also documented in the migration guide[2].

[1] <>
[2] <>
 [2019-01-23 11:26 UTC] spam2 at rhsoft dot net
if 7.0/7.1 would have worked as sane as 7.2 in that context it would have saved a lot of hours and headache when we added type-hints to our complete codebase where you start to extend shared libraries and every custom consumer was broken in one or the other direction and there are still too much cases ending in fatal errors
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 01:01:28 2019 UTC