/** * Searches the file for the format: (function(){})(); */ public function getExecutedFunctions() { if ($this->executions) { return $this->executions; } $lines = $this->getCode(); $matches = preg_grep('%function%', $lines); $last_line = 0; foreach ($matches as $line_number => $line) { if ($line_number < $last_line) { continue; } if (preg_match('%(?:([a-zA-Z_.$][\\w.$]*)\\s*=\\s*)?(?:new\\s*)?\\(\\s*function\\s*\\(\\s*\\)\\s*{%', $line, $match)) { $execution = new DojoExecutedFunction($this); $execution->setAnonymous(true); if ($match[1]) { $execution->setFunctionName($match[1]); } $execution->setStart($line_number, strpos($line, $match[0])); $end = $execution->build(); if ($end) { $last_line = $end[0]; $this->executions[] = $execution; } } } return $this->executions; }
public function getExecutedFunctions() { $lines = $this->getCode(); $matches = preg_grep('%function%', $lines); $last_line = 0; foreach ($matches as $line_number => $line) { if ($line_number < $last_line) { continue; } if (preg_match('%\\(\\s*function\\s*\\(\\s*\\)\\s*{%', $line, $match)) { $execution = new DojoExecutedFunction($this); $execution->setStart($line_number, strpos($line, $match[0])); $end = $execution->build(); if ($end) { $last_line = $end[0]; $this->executions[] = $execution; } } } return $this->executions; }