Helper to format text as docblock.

@param @lines
An array of lines, or a single line of text. Lines to be normally indented
should have no leading whitespace.

@return
An array of lines for the docblock with start and end PHP comment markers.
436668
function docBlock($lines) {
    if (!is_array($lines)) {
      $lines = array($lines);
    }

    $lines = array_merge(
      array("/**"),
      array_map(function ($line) {
        if (empty($line)) {
          return ' *';
        }
        return " * $line";
      }, $lines),
      array(" */")
    );

    return $lines;
  }
1334872
public function getTail($lines = 10){
		$this->blockStart = $this->fileSize;
		$buff1 = Array();
		$lastLines = array();
		
		while($this->blockStart){
			$buff = $this->readChunk();
			if(!$buff)break;
			
			$lines -= substr_count($buff, "\n");
			
			if($lines <= 0)
			{
				$buff1[] = $this->cutHead($buff, "\n", abs($lines)+1);
				break;
			}
			$buff1[] = $buff;
		}
		
		for($i = count($buff1); $i >= 0; $i--){
			$lastLines = array_merge($lastLines, explode("\n", $buff1[$i]));
		}
		
		return $lastLines;
	}
1100909
public function addRawFromAssocArray($lines, $indentation = 0)
	{
		foreach ($lines as $key => $value)
		{
			if (is_array($value))
			{
				$this->addLine($key . ': [', array("indentation"=>$indentation));
				$this->addRawFromAssocArray($value, $indentation + 1);
				$this->addLine(']', array("indentation"=>$indentation));
			}
			else
			{
				$this->addLine($key . ': ' . $value, array("indentation"=>$indentation));
			}
		}
	}
1204778
public function filterEmptyLines(array $lines)
    {
        return array_filter($lines, function ($line) {
            $line = trim($line);

            return $line !== '*' ? $line : false;
        });
    }
83417
private function __extractDocString($DocComment, $lines = null, $parse_tags = false)
    {
        $split = preg_split("/\r\n|\n|\r/", $DocComment);

        //clean up: removes useless chars like new-lines, tabs and *
        $_tmp = array();
        $_l=1;
        foreach ($split as $id => $row) {
            $_row = trim($row, "* /\n\t\r");
            if (!empty($_row) AND $_row[0]!='@') {
                $_tmp[$_l] = $_row;
                $_l++;
            }
        }           

        if (!empty($lines)) {
            if (is_numeric($lines)) {
                if (!isset($_tmp[ $lines ])) return '';
                $_tmp = array( $_tmp[ $lines ] );
            } elseif (is_array($lines)) {
                if (!empty($lines[1]))
                    $_tmp = array_slice($_tmp, array_search( $_tmp[ $lines[0] ], $_tmp)-1, $lines[1]);
                else
                    $_tmp = array_slice($_tmp, array_search( $_tmp[ $lines[0] ], $_tmp)-1 );
            }
        }

        return trim(implode("\n",$_tmp));
    }
950152
public function append($lines, $newline = true, $indentOffset = 0)
    {
        $this->_buffer[] = trim($lines) ? ($this->_getIndentationString($indentOffset) . $lines) : $lines;
        if ($newline) {
            $this->_buffer[] = $this->newLineStr;
        }

        return $this;
    }
638348
public function getArrayFromLines(array $lines) {
		$array = [];
		$map = [];

		$i = 1;
		foreach ($lines as $line) {
			if ($this->processor->isEmptyLine($line)) {
				$map[$i] = ['type' => 'empty'];
			} elseif ($this->processor->isCommentLine($line)) {
				$map[$i] = ['type' => 'comment', 'value' => $line];
			} else {
				$keyValue = explode('=', $line, 2);
				if (count($keyValue) < 2) {
					throw new InvalidLineException('Invalid line in configuration file');
				}
				list($key, $value) = $keyValue;

				$key = trim($key);

				$array[$key] = $this->processValue($value);
				$map[$i] = ['type' => 'value', 'key' => $key];
				$map[$i]['info'] = $this->mapInfoForValue($value);
			}

			$i++;
		}

		return [$array,$map];
	}
379959
def _docstring_getblocks(self):
        
        #If there are no lines to look at, we have nothing to do here.
        if self.ibuffer[0] == self.ibuffer[1]:
            return []

        lines = self.context.bufferstr[self.ibuffer[0]:self.ibuffer[1]]
        docblock = []
        result = []
        self._doclines = []

        #We need to keep track of the line number for the start of the
        #documentation strings.
        docline = 0
        doclength = 0

        first = self.docparser.RE_DOCS.match(lines[0])
        if first is not None:
            docblock.append(first.group("docstring"))
            docline = self.ibuffer[0]
            self._doclines.append(docline)
            doclength += len(lines[0]) + 1 # + 1 for \n removed by split.

            #We need to search backwards in the main buffer string for
            #additional tags to add to the block
            i = self.ibuffer[0] - 1
            while i > 0:
                current = self.context.bufferstr[i]
                docmatch = self.docparser.RE_DOCS.match(current)
                if docmatch is not None:
                    docblock.append(docmatch.group("docstring"))
                    docline = i
                    doclength += len(current) + 1
                else:
                    break
                i -= 1

        #Reverse the docblock list since we were going backwards and appending.
        if len(docblock) > 0:
            docblock.reverse()

        #Now handle the lines following the first line. Also handle the
        #possibility of multiple, separate blocks that are still valid XML.
        #We have to keep going until we have exceed the operational changes
        #or found the decorating element.
        i = self.ibuffer[0] + 1
        while (i < len(self.context.bufferstr) and 
               (i < self.ibuffer[1] or len(docblock) > 0)):
            line = self.context.bufferstr[i]
            docmatch = self.docparser.RE_DOCS.match(line)
            if docmatch is not None:
                docblock.append(docmatch.group("docstring"))
                doclength += len(line)
                if docline == 0:
                    docline = i
                #Only track actual documentation lines that are within the 
                #operations list of lines.
                if i < self.ibuffer[1]:
                    self._doclines.append(i)

            elif len(docblock) > 0:
                key = self._docstring_key(line)
                result.append((docblock, docline, doclength, key))
                docblock = []
                docline = 0
                doclength = 0

            #We need to exit the loop if we have exceeded the length of
            #the operational changes
            if len(docblock) == 0 and i > self.ibuffer[1]:
                break
            i += 1

        return result
558057
public AppleScriptBuilder withLines(List<String> lines) {
        for (String line : lines) {
            withLine(line);
        }
        return this;
    }
1058391
def lines
      @lines ||= begin
        all_lines = @buffer.source_lines
        last_token_line = tokens.any? ? tokens.last.line : all_lines.size
        result = []
        all_lines.each_with_index do |line, ix|
          break if ix >= last_token_line && line == '__END__'

          result << line
        end
        result
      end
    end
656184
protected function wrapLines($lines, $indentationLevel = 0)
    {
        if ($wrapper = $this->getOption('wrapper')) {
            $lines = explode("\n", $lines);
            for ($i = 0; $i < count($lines); $i++) {
                // first line ignored
                if ($i === 0) {
                    continue;
                }
                $line = $lines[$i];
                if ($indentationLevel && $i < count($lines) - 1) {
                    $line = str_repeat($this->getOption('indentation'), $indentationLevel) . $line;
                }
                $lines[$i] = sprintf($wrapper, $line);
            }
            $lines = implode("\n", $lines);
        }

        return $lines;
    }
84526
private function getIndent(array $lines)
    {
        $detector = new IndentationDetector(
            LineCollection::createFromArray($lines)
        );

        return str_repeat(' ', $detector->getFirstLineIndentation());
    }
1122529
protected function processDocBlock($text, array $uses = []): array
    {
        $parser = new DocBlockParser($text);

        $rtn = [
            'params' => [],
            'return' => null,
            'inheritdoc' => false,
        ];

        if (isset($parser->tags['param'])) {
            $rtn = $this->processDocBlockParams($parser->tags['param'], $uses, $rtn);
        }

        if (isset($parser->tags['return'])) {
            $rtn['return'] = $this->getDocBlockReturnType($parser->tags['return'], $uses);
        }

        if (stripos($parser->comment, '@inheritdoc') !== false) {
            $rtn['inheritdoc'] = true;
        }

        return $rtn;
    }
1141869
protected static function parseAnnotations($docblock)
    {
        $annotations = array();
        // Strip away the docblock header and footer
        // to ease parsing of one line annotations
        $docblock = substr($docblock, 3, -2);

        $re = '/@(?P<name>[A-Za-z_-]+)(?:[ \t]+(?P<value>.*?))?[ \t]*\r?$/m';
        if (preg_match_all($re, $docblock, $matches)) {
            $numMatches = count($matches[0]);

            for ($i = 0; $i < $numMatches; ++$i) {
                $annotations[$matches['name'][$i]][] = $matches['value'][$i];
            }
        }

        return $annotations;
    }
477594
public Block split(final Line line)
    {
        final Block block = new Block();

        block.lines = this.lines;
        block.lineTail = line;
        this.lines = line.next;
        line.next = null;
        if (this.lines == null)
        {
            this.lineTail = null;
        }
        else
        {
            this.lines.previous = null;
        }

        if (this.blocks == null)
        {
            this.blocks = this.blockTail = block;
        }
        else
        {
            this.blockTail.next = block;
            this.blockTail = block;
        }

        return block;
    }
190245
def _compile(cls, lines):
        ''''''
        m = cls.RE_FOR.match(lines.current)
        if m is None:
            raise DefineBlockError(
                'Incorrect block definition at line {}, {}\nShould be '
                'something like: #for @item in @items:'
                .format(lines.pos, lines.current))
        return m.group(1), m.group(2).replace('.', '-')
100507
def highlight_block(self, text):
        """"""
        text = to_text_string(text)
        if text.startswith(("c", "C")):
            self.setFormat(0, len(text), self.formats["comment"])
            self.highlight_spaces(text)
        else:
            FortranSH.highlight_block(self, text)
            self.setFormat(0, 5, self.formats["comment"])
            self.setFormat(73, max([73, len(text)]),
                           self.formats["comment"])