php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62404 Add checked exceptions, please
Submitted: 2012-06-24 19:23 UTC Modified: 2015-08-24 13:56 UTC
Votes:7
Avg. Score:3.0 ± 1.1
Reproduced:2 of 5 (40.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: normandiggs at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.4 OS:
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: normandiggs at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-24 19:23 UTC] normandiggs at gmail dot com
Description:
------------
Please, add Checked Exceptions to PHP (from Java).

Test script:
---------------
<?php

Class Example
{
    public function SomeFunction() throws \PDOException, \Some\Interface
    {
        //...
    }
}

Class Check
{
    protected function CheckItWrong()
    {
        $Example = new Example;
        // please, generate "warning" here, because "try-catch" 
        // with necessary types wasn't declared around call.
        $Example->SomeFunction();
    }
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-25 09:50 UTC] laruence@php.net
I have discussed with ekneuss about this FR for a bit.

thanks to ekneuss, we found there are some limits, 

1. since PHP is a dynamic language, then for $obj->function, we can not 
determine what $obj is, so if we want to implement this FR, we have to do the 
check at run-time.

2. there is another question while for following codes:
   function bar($i) {
       if ($i == 42) {
          $obj->someFuncThrowException();
       }
   }
   so,  should we trigger WARNING all the times?

3. unlesss ZEND_CATCH is executed, we have no idea what type of exception will 
be caught by catch, so, if we implement a whole exception type check, we will 
need: exception autoload, and catch statements analyse , which will bring a 
obvious performance slow down..

anyway, I can do more research later , thanks :)
 [2012-06-25 17:12 UTC] normandiggs at gmail dot com
I think one my wish should not be the reason of performance slowdown in all 
scripts, which use try-catch.
Thanks for your time and explanation. Close this ticket please.
 [2015-08-24 13:56 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-08-24 13:56 UTC] cmb@php.net
Closed on OP's request.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 13:01:27 2024 UTC