php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62572 Relax syntax by skipping ";" at end of line
Submitted: 2012-07-16 03:36 UTC Modified: 2012-07-17 14:09 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: thbley at gmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-07-16 03:36 UTC] thbley at gmail dot com
Description:
------------
old:

$txt1="Hello World!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
$i = 1; $j = 2; $k = 3;
function hello() { echo "hello world"; }

new:
$txt1="Hello World!"
$txt2="What a nice day!"
echo $txt1 . " " . $txt2
$i = 1; $j = 2; $k = 3
function hello() { echo "hello world" }

Test script:
---------------
$txt1="Hello World!"
$txt2="What a nice day!"
echo $txt1 . " " . $txt2
$i = 1; $j = 2; $k = 3
function hello() { echo "hello world" }


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-16 22:07 UTC] zyss at mail dot zp dot ua
Semicolons were invented not by stupid people...

It's interesting how would you write without semicolons the following:

from($categories)
    ->orderBy('$v["name"]')
    ->groupJoin(
        from($products)
            ->where('$v["quantity"] > 0')
            ->orderByDescending('$v["quantity"]')
            ->thenBy('$v["name"]'),
        '$v["id"]', '$v["catId"]', 'array("name" => $v["name"], "products" => $e)'
    );

???
 [2012-07-17 05:30 UTC] thbley at gmail dot com
I would try these rules:
do ";" if line ends with "\n" and
- next token is not "->" and not an operator (-+%...)
- "(", "'", "\"" are currently not open on stack and
- previous token is not an operator and
- start child stack if "function" token comes and
- not inside "function|if|while|switch|for|foreach () {"

e.g.
$test = [
  [],
  function ()
  { // do ";"
    return "test" // do ";"
  },
] // do ";"

for must remain:
  for ($i=0;
  $i<10;
  $i++) {}
 [2012-07-17 05:32 UTC] thbley at gmail dot com
small correction:
- "(", "'", "\"", "[" are currently not open on stack and
 [2012-07-17 14:09 UTC] rasmus@php.net
-Status: Open +Status: Wont fix
 [2012-07-17 14:09 UTC] rasmus@php.net
Wow, complicated. I think we will stick with the simple ';' to end an expression.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 09:01:30 2024 UTC