private function findMatchingMethod(File $file, LineRange $range) { $foundMethod = null; $this->broker = new Broker(new Memory()); $file = $this->broker->processString($file->getCode(), $file->getRelativePath(), true); $lastLine = $range->getEnd(); foreach ($file->getNamespaces() as $namespace) { foreach ($namespace->getClasses() as $class) { foreach ($class->getMethods() as $method) { if ($method->getStartLine() < $lastLine && $lastLine < $method->getEndLine()) { $foundMethod = $method; break; } } } } return $foundMethod; }
public function replace(LineRange $range, array $newLines) { $this->builder->replaceLines($range->getStart(), $range->getEnd(), $newLines); }
public static function rangeIsNotInsideMethod(LineRange $range) { return new self(sprintf('The range %d-%d is not inside one single method.', $range->getStart(), $range->getEnd())); }