Req #67312 [Com]: type hinting exception handling
| From: | anon at anon dot anon | Date: | Sat, 24 May 2014 14:52:35 +0000 |
| Subject: | Req #67312 [Com]: type hinting exception handling | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185916@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67312&edit=1
ID: 67312
Comment by: anon at anon dot anon
Reported by: bhasker dot t dot an at gmail dot com
Summary: type hinting exception handling
Status: Wont fix
Type: Feature/Change Request
Package: *General Issues
Operating System: windows
PHP Version: 5.4.28
Block user comment: N
Private report: N
New Comment:
The 'throws' keyword is flawed and annoying enough in Java. I don't want it added to
PHP too. If you want methods to be more self-documenting, you can put the exceptions they throw in a
/** comment */.
Previous Comments:
------------------------------------------------------------------------
[2014-05-23 02:48:27] aharvey@php.net
For reasons of consistency, this is unlikely to be changed unless all PHP errors are converted to
exceptions, which is a much bigger undertaking. This would require an RFC and would almost certainly
be something that would need to be in a new major version.
I'm closing the request, as I think it's unlikely we'd add syntax to throw a specific
exception in this case.
------------------------------------------------------------------------
[2014-05-20 19:02:50] bhasker dot t dot an at gmail dot com
Description:
------------
class a {
protected function method_a(someClass $obj)
{
/// some code
}
}
$a = new a();
$a->method_a('hellow');
//this throws an error
Test script:
---------------
class a {
protected function method_a(someClass $obj)
{
/// some code
}
}
$a = new a();
$a->method_a('hellow');
//this throws an error
Expected result:
----------------
could be grate if there is possiblity to write like
class a {
protected function method_a(someClass $obj) throws someException
{
/// some code
}
}
try {
$a = new a();
$a->method_a('hellow');
}catch (someException $e){
//catch exception
}
Actual result:
--------------
throwing fatal error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67312&edit=1