Edit report at https://bugs.php.net/bug.php?id=47416&edit=1

 ID:                 47416
 Comment by:         undsoft at gmail dot com
 Reported by:        mail at dropdev dot org
 Summary:            Please add "endclass", "endfunction" keywords.
 Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   Any
 PHP Version:        6CVS-2009-02-17 (CVS)
 Block user comment: N
 Private report:     N

 New Comment:

Hi,

I'd like to speak in favour of the request.

Alternative syntax is very useful for embedding php code to the html.
This way statements like <?php endif ?> look pretty much like template engine 
tags.

Very useful in php framework's view files.


Previous Comments:
------------------------------------------------------------------------
[2009-02-17 15:41:52] johan...@php.net

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


------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=47416&edit=1

Reply via email to