Bug #76020 [Opn->Nab]: Not fully implemented class only generates fatal without exception
| From: | nikic@php.net | Date: | Tue, 27 Feb 2018 18:00:20 +0000 |
| Subject: | Bug #76020 [Opn->Nab]: Not fully implemented class only generates fatal without exception | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214130@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
Updated by: nikic@php.net
Reported by: elibyy at gmail dot com
Summary: Not fully implemented class only generates fatal
without exception
-Status: Open
+Status: Not a bug
Type: Bug
-Package: PHP Language Specification
+Package: Scripting Engine problem
Operating System: Win/Nix
PHP Version: 7.0.27
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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