php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69979 TypeError does not extend Exception
Submitted: 2015-07-02 02:57 UTC Modified: 2015-07-02 04:03 UTC
From: grzegorz129 at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 7.0.0alpha2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-07-02 02:57 UTC] grzegorz129 at gmail dot com
Description:
------------
Since development versions of PHP 7.0 TypeException was thrown, from alpha2 TypeError replaced it. Unfortunately none of them extends Exception - is there any reason for that?
It could introduce a lot of incompatibility - a lot of code catches some specific exceptions and at the end catches Exception. Good example of that is phpUnit - under PHP 7.0 is impossible to use setExpectedException() with TypeError because it doesn't extend Exception.

Test script:
---------------
http://3v4l.org/eMijr


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-02 04:03 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2015-07-02 04:03 UTC] requinix@php.net
Take a look at https://wiki.php.net/rfc/throwable-interface. Additionally,
- Existing catch(Exception $e) code will continue to not catch errors
- Exception vs Error presents a clear separation between exceptions and errors

To catch everything, simply catch BaseException (alpha1) or Throwable (alpha2).
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 03:05:53 2022 UTC