Menu

Diff of /src/parser/PHPParser.php [r2] .. [r3]  Maximize  Restore

Switch to side-by-side view

--- a/src/parser/PHPParser.php
+++ b/src/parser/PHPParser.php
@@ -141,6 +141,7 @@
             $seenEnough = false;
             $seeMore = false;
             $tokenCnt = 0; //tokens in this line
+            $phpEnded = false;
             if($this->isContinuation($this->lastLineEndTokenType)) {
                 $this->lineType = LINE_TYPE_CONT;
                 $this->logger->debug("Continuation !", __FILE__, __LINE__);
@@ -197,7 +198,6 @@
                         }
 
                     case T_WHITESPACE:              // white space
-                    case T_CLOSE_TAG:               // ? >
                     case T_OPEN_TAG:                // < ?
                     case T_OPEN_TAG_WITH_ECHO:      // < ? =
                     case T_CURLY_OPEN:              // 
@@ -209,6 +209,7 @@
                     case T_CHARACTER:               // character
                     case T_ELSE:                    // else
                     case T_CONSTANT_ENCAPSED_STRING:   // "some str"
+                    case T_START_HEREDOC:
                         // Only if decision is not already made
                         // mark this non-executable.
                         if($this->lineType != LINE_TYPE_EXEC) {
@@ -237,6 +238,17 @@
                         $this->lineType = LINE_TYPE_EXEC;
                         break;
 
+                    case T_CLOSE_TAG:
+                        if($tokenCnt != count($tokens)) {
+                            // Token is not last (because we inserted that)
+                            $this->logger->debug("T_CLOSE_TAG for tokenCnt " . $tokenCnt . " End of PHP code.");
+                            $phpEnded = true; // php end tag found within the line.
+                        }
+                        if($this->lineType != LINE_TYPE_EXEC) {
+                            $this->lineType = LINE_TYPE_NOEXEC;
+                        }
+                        break;
+
                     default:
                         $seeMore = false;
                         $this->lineType = LINE_TYPE_EXEC;
@@ -266,12 +278,12 @@
 
             if($this->inPHP) {
                 // Check if PHP block ends on this line
-                if(($pos = strpos($line, $this->phpFinisher)) !== false) {
+                if($phpEnded) {
                     $this->inPHP = false;
                     // If line is not executable so far, check for the 
                     // remaining part
                     if($this->lineType != LINE_TYPE_EXEC) {
-                        return $this->processLine(trim(substr($line, $pos+2)));
+                        //return $this->processLine(trim(substr($line, $pos+2)));
                     }
                 }
             }