|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
6 + 47 = ?
Subscribe to this entry?

 [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: Sun Dec 10 22:01:27 2023 UTC