Edit report at https://bugs.php.net/bug.php?id=62404&edit=1

 ID:                 62404
 Updated by:         larue...@php.net
 Reported by:        normandiggs at gmail dot com
 Summary:            Add checked exceptions, please
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

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 :)


Previous Comments:
------------------------------------------------------------------------
[2012-06-24 19:23:39] 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();
    }
}




------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62404&edit=1

Reply via email to