pExpr_Include() public method

public pExpr_Include ( PHPParser_Node_Expr_Include $node )
$node PHPParser_Node_Expr_Include
Beispiel #1
0
 /**
  * Function: pExpr_Include
  *
  * Handles the inclusion of script-files.
  */
 public function pExpr_Include(PHPParser_Node_Expr_Include $node)
 {
     $file_to_include = $node->expr->value;
     if ($file_to_include) {
         LogMore::debug('File to include: %s', $file_to_include);
         # If the file should be only included/required once
         if ($node->type == PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE || $node->type == PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE) {
             # If the file has already been included
             if (isset($this->includedFiles[$file_to_include])) {
                 LogMore::debug('File has already been included once');
                 # Leave function
                 return null;
             }
         }
         $code = $this->parseFile($file_to_include);
         # Add file to array of included files and raise counter:
         if (isset($this->includedFiles[$file_to_include])) {
             $this->includedFiles[$file_to_include] += 1;
         } else {
             $this->includedFiles[$file_to_include] = 1;
         }
         return $code;
     } else {
         return parent::pExpr_Include($node);
     }
 }
Beispiel #2
0
 /**
  * Function: pExpr_Include
  *
  * Handles the inclusion of script-files.
  */
 public function pExpr_Include(PHPParser_Node_Expr_Include $node)
 {
     $file = $node->expr->value;
     $path = realpath($file);
     $info = pathinfo($file);
     $extension = isset($info['extension']) ? $extension = $info['extension'] : null;
     if ($file && $this->mergeScripts && $extension == 'php' || $file && is_array($this->filesToMerge) && in_array($file, $this->filesToMerge)) {
         LogMore::debug('File to include: %s', $file);
         # If the file should be only included/required once
         if ($node->type == PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE || $node->type == PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE) {
             # If the file has already been included
             if (isset($this->includedFiles[$path])) {
                 LogMore::debug('File has already been included once');
                 # Leave function
                 return null;
             }
         }
         $code = $this->parseFile($file);
         # Add file to array of included files and raise counter:
         if (isset($this->includedFiles[$path])) {
             $this->includedFiles[$path] += 1;
         } else {
             $this->includedFiles[$path] = 1;
         }
         return $code;
     } else {
         return parent::pExpr_Include($node);
     }
 }