Extracts the table definitions from the given content.

@param string $content Content of the file to parse
@return array Associative list of table names with table create statements ordered like in the file
348588
protected function _getTableDefinitions( $content )
	{
		$defs = array( );
		$matches = array( );

		$regex = '/CREATE TABLE \"?([a-zA-Z0-9_]+)\"? .*(\n\n|$)/sU';
		if ( preg_match_all($regex, $content, $matches, PREG_SET_ORDER) === false ) {
			throw new MW_Setup_Exception('Unable to get table definitions');
		}

		foreach ( $matches as $match ) {
			$defs[$match[1]] = $match[0];
		}

		return $defs;
	}
614527
protected function _parser($content)
    {
        $this->_initLines($content);
        $this->_stream = new TokenStream(['source' => $content, 'wrap' => $this->_states['php']]);

        $T_YIELD = defined('HHVM_VERSION') ? 381 : 267;

        $blockStartLines = [];
        $blockStartLine = null;

        while ($token = $this->_stream->current(true)) {
            switch ($token[0]) {
                case T_DIR:
                    $this->_states['body'] .= "'" . dirname($this->_states['path']) . "'";
                    break;
                case T_FILE:
                    $this->_states['body'] .= "'" . $this->_states['path'] . "'";
                    break;
                case T_OPEN_TAG:
                case T_OPEN_TAG_WITH_ECHO:
                    $this->_codeNode();
                    $this->_states['body'] .= $token[1];
                    $this->_codeNode('open');
                    $this->_states['php'] = true;
                    $blockStartLine = null;
                    break;
                case T_CLOSE_TAG:
                    $this->_codeNode();
                    $this->_states['php'] = false;
                    $this->_states['body'] .= $token[1];
                    $this->_codeNode('close');
                    break;
                case T_DOC_COMMENT:
                case T_COMMENT:
                    $this->_commentNode();
                    break;
                case T_CONSTANT_ENCAPSED_STRING:
                    if ($this->_states['lines']) {
                        $blockStartLine = $this->_states['num'];
                    }
                    $this->_stringNode('');
                    break;
                case T_START_HEREDOC:
                    $name = trim(substr($token[1], 3, -1), "'");
                    $this->_stringNode("\n" . $name, true);
                    break;
                case '"':
                    $this->_stringNode('"');
                    break;
                case '{':
                    $this->_states['body'] .= $token[0];
                    $this->_states['current'] = $this->_codeNode();
                    $blockStartLine = null;
                    break;
                case '}':
                    $this->_closeCurly();
                    $blockStartLine = null;
                    break;
                case '(':
                case '[':
                    $this->_states['body'] .= $token[0];
                    if ($this->_states['lines']) {
                        $lines = explode("\n", $this->_states['body']);
                        $blockStartLines[$token[0]][] = $this->_states['num'] + (count($lines) - 1);
                    }
                    break;
                case ')':
                case ']':
                    $this->_states['body'] .= $token[0];
                    if ($this->_states['lines']) {
                        $char = $token[0] === ']' ? '[' : '(';
                        $blockStartLine = array_pop($blockStartLines[$char]);
                    }
                    break;
                case ';':
                    $this->_states['body'] .= $token[1];
                    $node = $this->_codeNode(null, true);
                    if ($this->_states['lines'] && $blockStartLine !== null) {
                        $node->lines['begin'] = $blockStartLine;
                        $blockStartLine = null;
                    }
                    break;
                case T_DECLARE:
                    $this->_declareNode();
                    break;
                case T_NAMESPACE:
                    $this->_namespaceNode();
                    break;
                case T_USE:
                    $this->_useNode();
                    break;
                case T_TRAIT:
                    $this->_traitNode();
                    break;
                case T_INTERFACE:
                    $this->_interfaceNode();
                    break;
                case T_CLASS:
                    $this->_classNode();
                    break;
                case T_FINAL:
                case T_ABSTRACT:
                case T_PRIVATE:
                case T_PROTECTED:
                case T_PUBLIC:
                case T_STATIC:
                    $this->_states['visibility'][$token[1]] = true;
                    $this->_states['body'] .= $token[1];
                    break;
                case T_FUNCTION:
                    $this->_functionNode();
                    break;
                case $T_YIELD: // use T_YIELD directly when PHP 5.4 support will be removed.
                    $parent = $this->_states['current'];
                    while ($parent && !$parent instanceof FunctionDef) {
                        $parent = $parent->parent;
                    }
                    $parent->isGenerator = true;
                    $this->_states['body'] .= $token[1];
                    break;
                case T_VARIABLE:
                    $this->_states['visibility'] = [];
                    $this->_states['body'] .= $token[1];
                    break;
                case T_ENDIF:
                case T_ENDFOREACH:
                case T_ENDSWITCH:
                case T_ENDWHILE:
                    $this->_codeNode();
                    $this->_states['body'] .= $token[1] . $this->_stream->next([';']);
                    $this->_codeNode(null, false);
                    $blockStartLine = null;
                    break;
                case ':':
                    $this->_states['body'] .= $token[1];
                    $blockStartLine = null;
                    break;
                default:
                    $this->_states['body'] .= $token[1];
                    break;
            }
            $this->_stream->next();
        }
        $this->_codeNode();
        $this->_flushUses();
        $this->_stream->rewind();
        $this->_assignCoverable();
        return $this->_root;
    }
1354888
public function parseRelease(&$content)
	{
		$release = new Release;
		$types = [];
		$lastType = '';
		$nameSet = false;

		$line = current($content);
		while ($line !== false)
		{
			$line = ltrim($line);

			if ($this->startsWith($line, '###'))
			{
				$type = $this->trimHashes($line);
				$types[$type] = [];
				$lastType = $type;
			}
			elseif ($nameSet &&
				$this->startsWith($line, '##') ||
				$this->startsWith($line, '[')
			)
			{
				prev($content);
				break;
			}
			elseif ($this->startsWith($line, '##'))
			{
				$this->handleName($release, $line);
				$nameSet = true;
			}
			else
			{
				$change = ltrim($line, "\t\n\r\0\x0B -");

				if ($change !== '')
				{
					$types[$lastType][] = $change;
				}
			}

			$line = next($content);
		}

		$release->setAllChanges($types);
		return $release;
	}
1350532
protected function _getPaddedLine($content)
    {
        if (!is_array($content)) $content = array( $content );
        if ($this->column_size===0 && $this->line_size===0 && $this->cell_size===0) {
            $this->_parseTableSizes();
        }
        if (count($content) > $this->getColumnSize()) {
            $this->_repadAllLines();
        } elseif (count($content) < $this->getColumnSize() && ($this->getPadFlag() & self::PAD_BY_EMPTY_CELLS)) {
            $content = array_pad($content, $this->getColumnSize(), '');
        }
        return $content;
    }
1106849
protected function _getSetOfLines($content)
    {
        if (!is_array($content)) $content = array( $content );
        reset($content);
        if (!is_array(current($content))) {
            $content = array( 0=>$content );
        }
        return $content;
    }
438546
protected function extractDirectives($directive, $content)
    {
        $pattern = '/{{'.$directive.'\(?([\w\.]*)\)?}}/';
        preg_match_all($pattern, $content, $result);

        return $result;
    }
190406
public function extractExamples($content)
    {
        $content = preg_replace('/^<\?(php)?/', '', $content);

        // So that you can separate examples
        // by an empty line.
        $examples = explode("\n\n", $content);

        $examples = array_filter($examples, function($example)
        {
            // Remove all \n's and see if
            // $example is still not empty.
            return str_replace("\n", "", $example);
        });

        // Recreate $examples to fix index order.
        // Array_filter won't do it for you.
        return array_values($examples);
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
207524
private function getTokens($content)
    {
        // fetch non-empty lines
        $lines = preg_split('/\r\n|\r|\n/', $content, -1, PREG_SPLIT_NO_EMPTY);
        $tokens = array();
        foreach ($lines as $line) {
            // throwing tokens after '#' sign
            $commentCharPosition = strpos($line, "#");
            $lineWithoutComments = ($commentCharPosition === false) ? $line : substr($line, 0, strpos($line, "#"));
            // storing current line tokens
            if ($lineWithoutComments) {
                $tokens = array_merge($tokens, preg_split('/\s+/', $lineWithoutComments, -1, PREG_SPLIT_NO_EMPTY));
            }
        }
        return $tokens;
    }
300555
public function parse($content)
    {
        if (!$content || strpos($content, '@view') === false) {
            return [];
        }
        $ret = [];

        if (preg_match(self::VIEW_RENDER, $content, $match)) {
            $ret[0] = array_pop($match);
        } else {
            $ret[0] = null;
        }

        if (preg_match(self::VIEW_TEMPLATE_FILE, $content, $match)) {
            $ret[1] = array_pop($match);
        } else {
            $ret[1] = null;
        }

        if (preg_match_all(self::VIEW_PARAMETERS, $content, $match, PREG_SET_ORDER)) {
            $set = [];
            // "all" is excluded
            foreach ($match as $position => $group) {
                $set[$group[1]] = $group[2];
            }

            if ($set){
                $ret[] = $set;
            }

        }

        return $ret;
    }
686730
protected function _parseFormEntities($content) {
		preg_match_all('/\$this-\>Form->create\(\$(\w+)\W/i', $content, $matches);
		if (empty($matches[1])) {
			return [];
		}

		$result = [];

		$entities = array_unique($matches[1]);
		foreach ($entities as $entity) {
			$entityName = Inflector::camelize(Inflector::underscore($entity));

			$className = App::className(($this->getConfig(static::CONFIG_PLUGIN) ? $this->getConfig(static::CONFIG_PLUGIN) . '.' : '') . $entityName, 'Model/Entity');
			if (!$className) {
				continue;
			}

			$annotation = AnnotationFactory::createOrFail(VariableAnnotation::TAG, '\\' . $className, '$' . $entity);

			$result[$entity] = $annotation;
		}

		return $result;
	}
314315
private function parseContent($content = '')
    {

        list($time, $content) = explode("#", $content);
        return [
            $time, gzuncompress($content)
        ];

    }
579302
public function transform($content)
    {
        $content = $this->entityToArray(Content::class, $content);
        return [
            'id'               => $this->setNullableValue($content['id']),
            'parentId'         => $this->setNullableValue($content['parent_id']),
            'type'             => $content['type'],
            'theme'            => $content['theme'],
            'weight'           => (int) $content['weight'],
            'rating'           => (int) $content['rating'],
            'visits'           => (int) $content['visits'],
            'isActive'         => (bool) $content['is_active'],
            'isOnHome'         => (bool) $content['is_on_home'],
            'isCommentAllowed' => (bool) $content['is_comment_allowed'],
            'isPromoted'       => (bool) $content['is_promoted'],
            'isSticky'         => (bool) $content['is_sticky'],
            'path'             => $this->buildPath($content['path']),
            'publishedAt'      => $content['published_at'],
            'createdAt'        => $content['created_at'],
            'updatedAt'        => $content['updated_at']
        ];
    }
1175372
public function parseTraceEntry($content)
    {
        $content = trim($content);

        $caught_at = $content;
        $in = $line = null;

        if (!empty($content) && preg_match("/.*".self::TRACE_IN_DIVIDER_PATTERN.".*/", $content)) {
            $split = array_map('trim', preg_split("/".self::TRACE_IN_DIVIDER_PATTERN."/", $content));

            $in   = trim($split[0]);
            $caught_at = (isset($split[1])) ? $split[1] : null;

            if (preg_match("/^".self::TRACE_FILE_PATTERN."$/", $in, $matchs)) {
                $in   = trim($matchs[1]);
                $line = $matchs[2];
            }
        }

        return compact('caught_at', 'in', 'line');
    }
1070833
protected function _getContent($content)
    {
        if(!isset($content))
            return;

        if(is_array($content))
            return array_map(
                function ($value) {
                    return $this->_getContent($value);
                }, $content
            );

        switch(gettype($content)) {
            case 'string': case 'integer': case 'double': case 'float':
                return $content;
            break;
            case 'object':
                if('Closure' == get_class($content)) {
                    ob_start();
                    ob_clean();
                    $returned = $content($this->data);
                    $output = ob_get_clean();
                    if(isset($returned))
                        return $returned;
                    else
                        return $output;
                } elseif(isset($content->content))
                    return $content->content;
            break;
            default:
                throw new \InvalidArgumentException('wrong view content type : '.gettype($content));
        }
    }
1260616
public function parse($content)
    {
        $set = null;
        if (strpos($content, '@ORM') === false) {
            return $set;
        }

        if (preg_match(self::PATTERN, $content, $matches)) {
            $set[] = [$matches[1], $matches[2]];
        }



        return $set;
    }
1239325
public function getSectionsText($content)
    {
        $sections    = array();
        $content     = ' ' . $content . ' ';
        $textCleaned = $this->cleanContent($content, '_');

        // Extract text blocks.
        if (preg_match_all('/\s+BT[\s|\(|\[]+(.*?)\s*ET/s', $textCleaned, $matches, PREG_OFFSET_CAPTURE)) {
            foreach ($matches[1] as $part) {
                $text    = $part[0];
                if ($text === '') {
                    continue;
                }
                $offset  = $part[1];
                $section = substr($content, $offset, strlen($text));

                // Removes BDC and EMC markup.
                $section = preg_replace('/(\/[A-Za-z0-9]+\s*<<.*?)(>>\s*BDC)(.*?)(EMC\s+)/s', '${3}', $section . ' ');

                $sections[] = $section;
            }
        }

        // Extract 'do' commands.
        if (preg_match_all('/(\/[A-Za-z0-9\.\-_]+\s+Do)\s/s', $textCleaned, $matches, PREG_OFFSET_CAPTURE)) {
            foreach ($matches[1] as $part) {
                $text    = $part[0];
                $offset  = $part[1];
                $section = substr($content, $offset, strlen($text));

                $sections[] = $section;
            }
        }

        return $sections;
    }