title: PHP Syntax error on empty line: syntax error, unexpected '}'
body: <pre><code>Parse error: syntax error, unexpected '}', expecting end of file
  </code></pre>
  
  <p>it occurs is on an empty line between my removeWalls function and the setup comment but I am positive that there are no missing semicolons or unclosed brackets. Does anyone know why this is happening and how to fix it?</p>
  
  <pre><code>$cols;
  $rows;
  $w = 20;
  $grid = new jsarray();
  $current;
  $stack = new jsarray();
  $height = 600;
  $width = 600;
  $cols = floor($width/$w);
  $rows = floor($height/$w);
  
  function index($i, $j) {
    if ($i &lt; 0 || $j &lt; 0 || $i &gt; $cols - 1 || $j &gt; $rows - 1) {
      return -1;
    }
    return $i + $j * $cols;
  }
  
  // Classes
  class Cell{
    function __construct($i,$j){
      $this-&gt;i = $i;
      $this-&gt;j = $j;
      $this-&gt;walls = new jsarray(true,true,true,true);
      $this-&gt;visited = false;
    }
  }
  
  function removeWalls($a, $b) {
    $x = $a-&gt;i - $b-&gt;i;
    if ($x === 1) {
      $a-&gt;walls(3,false);
      $b-&gt;walls(1,false);
    } else if (x === -1) {
      $a-&gt;walls(1,false);
      $b-&gt;walls(3,false);
    }
    $y = $a-&gt;j - $b-&gt;j;
    if ($y === 1) {
      $a-&gt;walls(0,false);
      $b-&gt;walls(2,false);
    } else if (y === -1) {
      $a-&gt;walls(2,false);
      $b-&gt;walls(0&lt;false);
    }
  }
  
  // Setup
  for($j = 0;$j &lt; $rows;$j++){
    for($i = 0;$i &lt; $cols;$i++){
      $cell = new Cell($i,$j);
      $grid-&gt;push($cell);
    }
  }
  $current = $grid(0);
  
  ?&gt;
  </code></pre>
  
  <p>JSarray Class:</p>
  
  <pre><code>&lt;?php
  Class jsarray{
    function __construct(...$vals_){
      $this-&gt;vals = array();
      $this-&gt;cnt = -1;
      if($vals_ != NULL){
        if($vals_ &gt; 0 &amp;&amp; $vals_ &gt; 1){
          foreach($vals_ as $val){
            $this-&gt;vals[(string) $this-&gt;cnt] = $val;
            $this-&gt;cnt++;
          }
        }
      }
      $this-&gt;length = $this-&gt;cnt+1;
    }
    function push(...$elements){
      if($elements != NULL &amp;&amp; $elements &gt; 0){
        foreach($elements as $element){
          $this-&gt;vals[(string) $this-&gt;cnt] = $element;
          $this-&gt;cnt++;
        }
      }
      $this-&gt;length = $this-&gt;cnt+1;
    }
    function pop(){
      if($this-&gt;length &gt; 0){
        array_pop($this-&gt;vals);
        $this-&gt;cnt--;
      }
      $this-&gt;length = $this-&gt;cnt+1;
    }
    function __invoke(int $indx,$exchange,...$vals0){
      if($indx != NULL &amp;&amp; $indx &gt; -1){
        return $this-&gt;vals[(string) ($indx-1)];
      } else if($exchange != NULL &amp;&amp; $indx &gt; -1) {
        $this-&gt;vals[(string) ($indx-1)] = $exchange;
      } else if($vals0 != NULL){
        $this-&gt;vals = array();
        $this-&gt;cnt = -1;
        $this-&gt;cnt = -1;
        if($vals_ &gt; 0 &amp;&amp; $vals_ &gt; 1){
          foreach($vals_ as $val){
            $this-&gt;vals[(string) $this-&gt;cnt] = $val;
            $this-&gt;cnt++;
          }
        }
      }
    }
  }
    function concat(self ...$arrays){
      if($arrays &gt; 0 &amp;&amp; $arrays != NULL){
        $finalarr = $this;
        foreach($arrays as $array){
          $finalarr-&gt;vals = array_merge_recursive($finalarr-&gt;vals,$array-&gt;vals);
        }
        $finalarr-&gt;length = count($finalarr-&gt;vals);
        $finalarr-&gt;cnt = $finalarr-&gt;length-1;
        return $finalarr;
      }
    }
    function reverse(){
      $this-&gt;vals = array_reverse($this-&gt;vals);
    }
  }
  // one $ for every line of this file
  ?&gt;
  </code></pre>
  
  <p>If anyone is interested I was trying to translate some JS to PHP and the JS and PHP are both on this page: <a href="https://github.com/AlexDvorak/PHP-Coding-Train" rel="nofollow noreferrer">https://github.com/AlexDvorak/PHP-Coding-Train</a></p>