34 public function detect($filePath, $functions)
37 $regexp = $this->composeRegexp($functions);
44 $file = file($filePath);
63 $matches = preg_grep($regexp, explode(
"\n", $fileContent));
64 if (!empty($matches)) {
65 foreach ($matches as $line) {
66 $actualFunctions = [];
67 foreach ($functions as $function) {
68 if (
false !== strpos($line, $function)) {
69 $actualFunctions[] = $function;
72 $result[array_search($line .
"\n", $file) + 1] = $actualFunctions;
89 array_unshift($file,
'');
90 $lines = preg_grep($regexp, $file);
91 foreach ($lines as $lineNumber => $line) {
92 if (preg_match_all($regexp, $line, $matches)) {
93 $result[$lineNumber] = $matches[1];
106 private function composeRegexp(array $functions)
108 if (empty($functions)) {
111 return '/(?<!function |->|::)\b(' . join(
'|', $functions) .
')\s*\(/i';
static getChangedContent($fileName)
grepChangedContent(array $file, $regexp, $functions, $fileContent)
grepFile(array $file, $regexp)
detect($filePath, $functions)