ID:               47416
 Updated by:       johan...@php.net
 Reported By:      mail at dropdev dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: Any
 PHP Version:      6CVS-2009-02-17 (CVS)
 New Comment:

Derick'S response to #24100 is still valid. We still prefer the {}
syntax.



Previous Comments:
------------------------------------------------------------------------

[2009-02-17 00:18:41] mail at dropdev dot org

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:
---------------
<?php
// example 1
$foobar = array('foo', 'bar');
if (TRUE):
  if (TRUE):
    foreach($foobar as $key => $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 this bug report at http://bugs.php.net/?id=47416&edit=1

Reply via email to