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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC