|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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();
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 00:00:02 2025 UTC |
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 :)