|  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.
Block user comment
Status: Assign to:
Bug Type:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:


 [2015-07-02 02:57 UTC] grzegorz129 at gmail dot com
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:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-02 04:03 UTC]
-Status: Open +Status: Not a bug
 [2015-07-02 04:03 UTC]
Take a look at 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-2023 The PHP Group
All rights reserved.
Last updated: Wed Sep 27 13:01:24 2023 UTC