Req #38544 [Opn->Wfx]: tryeach
| From: | cmb@php.net | Date: | Thu, 30 Sep 2021 11:39:42 +0000 |
| Subject: | Req #38544 [Opn->Wfx]: tryeach | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236933@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=38544&edit=1
ID: 38544
Updated by: cmb@php.net
Reported by: dtyschenko at soft-ukraine dot com
Summary: tryeach
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.1.5
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
15 years and no further feedback on a doubtful feature request (in
my opinion, input validation should not throw exceptions), makes
me close this as WONTFIX.
If anybody is still interested in this feature, please pursue the
RFC process[1].
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2006-08-22 13:20:35] dtyschenko at soft-ukraine dot com
The keyword is each.
When user submit the form, you show them waht he misses. With try you will show only one error.
And with tryeach all errors.
------------------------------------------------------------------------
[2006-08-22 12:25:56] tony2001@php.net
What's the problem with this ?
try {
$Item->Title($_POST['title']);
$Item->Content($_POST['content']);
} ...
------------------------------------------------------------------------
[2006-08-22 12:16:35] dtyschenko at soft-ukraine dot com
Description:
------------
Sometimes I need to run few functions that can throw new exception
Reproduce code:
---------------
<?php
$errors = array();
try {
$Item->Title($_POST['title']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
try {
$Item->Content($_POST['content']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
// In this case tryeach operator can be very usefull
tryeach {
$Item->Title($_POST['title']);
$Item->Content($_POST['content']);
} catch (InvalidArgument $e) {
$errors[] = $e->getMessage();
}
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=38544&edit=1