Bug #76020 [Nab]: Not fully implemented class only generates fatal without exception

From: Date: Tue, 27 Feb 2018 18:07:09 +0000
Subject: Bug #76020 [Nab]: Not fully implemented class only generates fatal without exception
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214131@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76020&edit=1 ID: 76020 User updated by: elibyy at gmail dot com Reported by: elibyy at gmail dot com Summary: Not fully implemented class only generates fatal without exception Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Win/Nix PHP Version: 7.0.27 Block user comment: N Private report: N New Comment: Hey, This is understandable. my main need is so that my exception handler will catch it and I will be able to know the cause of my 500 Previous Comments: ------------------------------------------------------------------------ [2018-02-27 18:00:18] nikic@php.net The fatal error to exception conversion occurs on a best-effort basis. Not every place can easily throw an exception instead of a fatal. This is one of them. If the technical issues are resolved at some point in the future, this will be changed to throw as well. PS: The exception would occur at the point of the class declaration, not at the point of instantiation. As such, your particular example code would not work in any case. ------------------------------------------------------------------------ [2018-02-27 17:50:51] elibyy at gmail dot com Description: ------------ In PHP 7 the error flow was changed that any code (even fully breaking) will pass in a try... catch block but if you create a class that implements an interface partially, you will get a fatal but no exception is thrown, and therefore breaks the script The error message is: Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A::thing1) Test script: --------------- <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); interface A { function thing(); function thing1(); } class B implements A { public function thing() { } } try{ new B(); }catch(\Throwable $t){ //expected to be catched } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76020&edit=1

« previous php.bugs (#214131) next »