php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #42251 Add functionName throws Exception syntax
Submitted: 2007-08-08 22:40 UTC Modified: 2007-08-10 21:19 UTC
From: mattsch at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.4RC1 OS: Gentoo Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
4 + 3 = ?
Subscribe to this entry?

 
 [2007-08-08 22:40 UTC] mattsch at gmail dot com
Description:
------------
It just came to my attention today that there is a function-based Exception syntax in Java that would be very beneficial to have in php:

Example in Java:

public boolean foo(String bar) throws Exception {
//Run commands that may throw exceptions
}


Proposal in PHP:

public function foo($bar) throws Exception {
//Run commands that may throw exceptions
}


This will ensure that the function is only called within a try/catch block and if it's not, it can throw an uncaught exception or throw an error of some sort.  This would be very helpful because when someone who didn't develop the function (a different developer) trys to use the function outside of a try/catch block, he or she will be warned immediately.  


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-09 07:42 UTC] johannes@php.net
While the current Exception system was designed it was decided not having that syntax. Please search the archives of the internals list for more.
 [2007-08-10 21:19 UTC] mattsch at gmail dot com
Apparently php internals is not searchable.  Could you humble me with a link?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 00:01:32 2024 UTC