|  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
 [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-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 09:01:29 2024 UTC