From: mail at dropdev dot org
Operating system: Any
PHP version: 6CVS-2009-02-17 (CVS)
PHP Bug Type: Feature/Change Request
Bug description: Please add "endclass", "endfunction" keywords.
Description:
Note: I'm aware of the "won't fix" on #24100
I'm re-requesting this feature, because this syntax actually helps people
working with php to debug their program.
Consider this:
When using curly braces, PHP gives an syntax error at the end of the file,
on a non-existing line (which confuses developpers), using an item ($end)
which looks like a php variable (which confuses developpers even more).
Also, the error message confuses lot's of developpers as can be seen in
the loads of issues popping on when searching for the error.
Now consider this:
When using endxxx statements, it gives a more meaningful, error message,
which is also a lot closer to the actual error position (a bless if you
have 1000+ lines of code in your difficult class)
Also, it is much easier to search for in the documentation (see:
http://php.net/manual/tokens.php which is on the first page of the search,
if you search sitewide for T_ENDFOREACH)
As a free bonus, using this alternative syntax also resolves the ongoing
discussion on where to place the curly braces (new line/no new line).
please also read: http://www.geocities.com/tablizer/endx.htm
The reproduce code contains two similar independent examamples showing the
primary and alternative syntax, each with 1 syntax error to show the
difference between the both.
Reproduce code:
---
$value):
if (TRUE):
// some code
// also code
endforeach; // << syntax error here!!! (unexpected T_ENDFOREACH)
endif;
else:
// more code
endif;
// example 2
$foobar = array('foo', 'bar');
if (TRUE) {
if (TRUE) {
foreach($foobar as $key => $value) {
if (TRUE) {
// some code...
// also code...
}
}
} else {
// more code ...
}
// << syntax error here!!! (unexpected $end)
--
Edit bug report at http://bugs.php.net/?id=47416&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47416&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47416&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47416&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47416&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47416&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47416&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47416&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47416&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47416&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47416&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47416&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47416&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=47416&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47416&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47416&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47416&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47416&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47416&r=mysqlcfg