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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattsch at gmail dot com
New email:
PHP Version: OS:

 

 [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: Fri Mar 29 08:01:27 2024 UTC