Bug #77507 [Opn->Csd]: No fatal error when implementing interface method with parameter type declared

From: Date: Wed, 23 Jan 2019 11:22:07 +0000
Subject: Bug #77507 [Opn->Csd]: No fatal error when implementing interface method with parameter type declared
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219150@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77507&edit=1 ID: 77507 Updated by: cmb@php.net Reported by: a dot owrew at gmail dot com Summary: No fatal error when implementing interface method with parameter type declared -Status: Open +Status: Closed Type: Bug -Package: PHP Language Specification +Package: Scripting Engine problem Operating System: Linux PHP Version: 7.2.14 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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] <https://wiki.php.net/rfc/parameter-no-type-variance> [2] <http://de2.php.net/manual/en/migration72.new-features.php#migration72.new-features.param-type-widening> Previous Comments: ------------------------------------------------------------------------ [2019-01-23 10:37:42] a dot owrew at gmail dot com Description: ------------ 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: --------------- <?php 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) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77507&edit=1

« previous php.bugs (#219150) next »