Parses a Class Signature and returns collected Information.
@access		protected
@param		ADT_PHP_File		$parent			File Object of current Class
@param		array				$matches		Matches of RegEx
@return		ADT_PHP_Interface|ADT_PHP_Class
322085
protected function parseClassOrInterface( ADT_PHP_File $parent, $matches )
	{
		switch( strtolower( trim( $matches[3] ) ) )
		{
			case 'interface':
				$artefact	= new ADT_PHP_Interface( $matches[4] );
				if( isset( $matches[5] ) )
					$artefact->setExtendedInterfaceName( $matches[6] );
				$artefact->setFinal( (bool) $matches[2] );
				break;
			default:
				$artefact	= new ADT_PHP_Class( $matches[4] );
				if( isset( $matches[5] ) )
					$artefact->setExtendedClassName( $matches[6] );
				$artefact->setFinal( (bool) $matches[2] );
				$artefact->setAbstract( (bool) $matches[1] );
				if( isset( $matches[7] ) )
					foreach( array_slice( $matches, 8 ) as $match )
						if( trim( $match ) && !preg_match( "@^,|{@", trim( $match ) ) )
							$artefact->setImplementedInterfaceName( trim( $match ) );
				break;
		}
		$artefact->setParent( $parent );
		$artefact->setLine( $this->lineNumber );
		$artefact->type		= $matches[3];
		if( $this->openBlocks )
		{
			$this->decorateCodeDataWithDocData( $artefact, array_pop( $this->openBlocks ) );
			$this->openBlocks	= array();
		}
		if( !$artefact->getCategory() && $parent->getCategory() )
			$artefact->setCategory( $parent->getCategory() );
		if( !$artefact->getPackage() && $parent->getPackage() )
			$artefact->setPackage( $parent->getPackage() );
		return $artefact;
	}
581318
private function computeUrlRegex(array $matches)
    {
        $this->names[] = $matches[1];

        if (isset($this->conditions[$matches[1]])) {
            return '(?P<' . $matches[1] . '>' . $this->conditions[$matches[1]] . ')';
        }

        if (substr($matches[0], -1) === '+') {

            $this->namesPath[$matches[1]] = 1;

            return '(?P<' . $matches[1] . '>.+)';
        }

        return '(?P<' . $matches[1] . '>[^/]+)';
    }
35388
protected function file_callback($matches)
    {
        $file = $matches[3];
        $file = preg_replace('!^/this/!', '/', $file);

        // correct absolute paths
        if ($file[0] == '/') {
            $file = $this->base_path . $file;
        }

        // add file modification timestamp
        if (preg_match('/\.(js|css)$/', $file, $m)) {
            $file = $this->file_mod($file);
        }

        return $matches[1] . '=' . $matches[2] . $file . $matches[4];
    }
416507
protected function parseTokens(array $tokens)
    {
        //Current active token
        $activeToken = [];

        //Some blocks can be named as parent. We have to make sure we closing the correct one
        $activeLevel = 0;

        //Content to represent full tag declaration (including body)
        $activeContent = [];

        foreach ($tokens as $token) {
            $tokenType = $token[HtmlTokenizer::TOKEN_TYPE];

            if (empty($activeToken)) {
                switch ($tokenType) {
                    case HtmlTokenizer::TAG_VOID:
                    case HtmlTokenizer::TAG_SHORT:
                        //Token will be clarified using Supervisor
                        $this->mountToken($token);
                        break;

                    case HtmlTokenizer::TAG_OPEN:
                        $activeToken = $token;
                        break;

                    case HtmlTokenizer::TAG_CLOSE:
                        if ($this->compiler->getSyntax()->isStrict()) {
                            throw new StrictSyntaxException(
                                "Unpaired close tag '{$token[HtmlTokenizer::TOKEN_NAME]}'.",
                                $token
                            );
                        }
                        break;
                    case HtmlTokenizer::PLAIN_TEXT:
                        //Everything outside any tag
                        $this->mountContent([$token]);
                        break;
                }

                continue;
            }

            if (
                $tokenType != HtmlTokenizer::PLAIN_TEXT
                && $token[HtmlTokenizer::TOKEN_NAME] == $activeToken[HtmlTokenizer::TOKEN_NAME]
            ) {
                if ($tokenType == HtmlTokenizer::TAG_OPEN) {
                    $activeContent[] = $token;
                    $activeLevel++;
                } elseif ($tokenType == HtmlTokenizer::TAG_CLOSE) {
                    if ($activeLevel === 0) {
                        //Closing current token
                        $this->mountToken($activeToken, $activeContent, $token);
                        $activeToken = $activeContent = [];
                    } else {
                        $activeContent[] = $token;
                        $activeLevel--;
                    }
                } else {
                    //Short tag with same name (used to call for parent content)s
                    $activeContent[] = $token;
                }

                continue;
            }

            //Collecting token content
            $activeContent[] = $token;
        }

        //Everything after last tag
        $this->mountContent($activeContent);
    }
393480
protected function normalizeMatches($matches)
    {
        return collect($matches)
            ->filter(function ($item, $key) {
                return ! is_numeric($key);
            })
            ->map(function ($item, $key) {
                $return = $item[0];

                if (starts_with($key, 'load')) {
                    $return = floatval($return);
                } elseif (is_numeric($return)) {
                    $return = (int) $return;
                } elseif (empty($return)) {
                    $return = null;
                }

                return $return;
            })
            ->toArray();
    }
1136448
protected function validateRuntimeMetadata($class, $parent)
    {
        if (!$class->reflClass) {
            // only validate if there is a reflection class instance
            return;
        }

        $class->validateIdentifier();
        $class->validateReferenceable();
        $class->validateReferences();
        $class->validateChildClasses();
        $class->validateLifecycleCallbacks($this->getReflectionService());
        $class->validateTranslatables();

        // verify inheritance
        // TODO
    }
1207629
private function tableClb($matches)
    {
        return $this->implementation->reprTable($this->connection, $this->prefix.$matches[1]);
    }
573139
protected function parseParameter( ADT_PHP_Function $parent, $matches )
	{
		$parameter	= new ADT_PHP_Parameter( $matches[5] );
		$parameter->setParent( $parent );
		$parameter->setLine( $this->lineNumber );
		$parameter->setCast( $matches[2] );
		$parameter->setReference( (bool) $matches[4] );

		if( isset( $matches[6] ) )
			$parameter->setDefault( $matches[7] );
		return $parameter;
	}
554759
public function parseIncr($files)
    {
        foreach($files as $file)
        {
            if(isset($this->fileMap[$file]))
            {
                unset($this->fileMap[$file]);
            }
            if(!is_file($file))
            {
                continue;
            }
            $content = file_get_contents($file);
            if(preg_match('/namespace ([^;]+);/', $content, $matches) <= 0)
            {
                continue;
            }
            $namespace = trim($matches[1]);
            $className = $namespace . '\\' . basename($file, '.php');
            if(class_exists($className))
            {
                $this->parse($className);
            }
        }
    }
363048
public static function findByFileTag( $parentId, $parentType, $fileTag, $type = null ) {

		$mapTable	= static::tableName();
		$fileTable	= CoreTables::getTableName( CoreTables::TABLE_FILE );

		if( empty( $type ) ) {

			$type = CoreGlobal::TYPE_DEFAULT;
		}

		return self::queryByParent( $parentId, $parentType )->andWhere( "$fileTable.tag=:tag AND $mapTable.type=:type", [ ':tag' => $fileTag, ':type' => $type ] )->one();
	}
172445
private function parse_callback($matches)
    {
    	$method = $matches[1];
    	//$params = str_replace(array('"', '\''), '', $matches[2]);
    	$params = $this->addquote($matches[2]);
    	switch ($method) {
    	    case 'template':
    		case 'include':
    			$content = '<?php include $this->template(' . $params . '); ?>';
    			break;
    		case 'layout':
    		    $content = '<!-- php__layout(' . $params . ') -->';
    		    break;
    	}
    	
    	return isset($content) ? '' . $this->addquote($content) : '';
    }
734272
private function parseMethod( $matches, &$openBlocks )
	{
		$method	= $this->methodData;
		$method['name']		= $matches[5];
		$method['access']	= trim( $matches[3] );
		$method['abstract']	= (bool) $matches[1];
		$method['final']	= (bool) $matches[2];
		$method['static']	= (bool) $matches[4];
		if( trim( $matches[6] ) )
		{
			$paramList	= array();
			foreach( explode( ",", $matches[6] ) as $param )
			{
				$param	 = trim( $param );
				if( !preg_match( $this->regexParam, $param, $matches ) )
					continue;
				$param	= array(
					'cast'		=> $matches[2],
					'reference'	=> $matches[4] ? TRUE : FALSE,
					'name'		=> $matches[5],
				);
				if( isset( $matches[6] ) )
					$param['default']	= $matches[7];
				$method['param'][$matches[5]] = $param; 
			}
		}
		if( $openBlocks )
		{
			$methodBlock	= array_pop( $openBlocks );
			$this->overwriteCodeDataWithDocData( $method, $methodBlock );
			$openBlocks	= array();
		}
		if( !$method['access'] )
			$method['access']	= "public";
		return $method;
	}
538417
private function _getParentArray($parent, $array)
    {
        foreach ($array as $section => $arraySection) {

            $sectionName = explode(':', $section);

            if (trim($sectionName[0]) == $parent) return $arraySection;
        }

        throw new NoSectionMatchesException('No section matches with ' . $parent);
    }
873060
protected function parseTemplateTag(array $match)
    {
        $keys = explode('->', $match[1]);

        $context = 'title';
        if ($keys[0][0] === '$') {
            $context = substr(array_shift($keys), 1);
        }

        $previous = null;
        $model = $this->{$context};

        foreach ($keys as $key) {
            $previous = $model;
            $model = (is_object($model))
                ? $model->{$key}
                : $model[$key];
        }

        if ($context === 'dictionary') {
            $model = utf8_encode($model);
        }

        if ($model instanceof Medools\Model) {
            return implode('-', $model->getPrimaryKey());
        }

        switch ($key) {
            case 'billet_tax':
            case 'discount1_value':
            case 'discount2_value':
            case 'discount3_value':
            case 'fine_value':
            case 'interest_value':
            case 'ioc_iof':
            case 'rebate':
            case 'tax_value':
            case 'value_paid':
            case 'value':
                $model = $this->formatMoney($model);
                break;

            case 'discount1_date':
            case 'discount2_date':
            case 'discount3_type_date':
            case 'due':
            case 'emission':
            case 'fine_date':
            case 'interest_date':
                $model = $this->formatDate($model);
                break;

            case 'document':
                $model = $previous->getFormattedDocument();
                break;

            case 'stamp':
            case 'update':
                $model = date('H:i:s d/m/Y', strtotime($model));
                break;

            case 'zipcode':
                $model = Utils\Validation::cep($model);
                break;
        }

        return $model;
    }
1354079
protected static function in_array_matches_regex($test, $patterns)
    {
        foreach($patterns as $val) {
            if(@preg_match($val, null) === false) {
                if( strcasecmp($val, $test) === 0 ) {
                    return true;
                }
            } else {
                if( preg_match($val, $test) === 1 ) {
                    return true;
                }
            }
        }
        return false;
    }
298891
private function createLinkOrSeeTagFromRegexMatch(array $match): Tag
    {
        list($completeMatch, $tagName, $tagContent) = $match;

        $fqsenResolver = new FqsenResolver();
        $tagFactory = new StandardTagFactory($fqsenResolver);
        $descriptionFactory = new DescriptionFactory($tagFactory);
        $tagFactory->addService($descriptionFactory);
        $tagFactory->addService(new TypeResolver($fqsenResolver));

        switch ($tagName) {
            case 'see':
                return See::create($tagContent, $fqsenResolver, $descriptionFactory, $this->createDocBlockContext());
            case 'link':
                return Link::create($tagContent, $descriptionFactory, $this->createDocBlockContext());
        }
    }
1008203
protected function attributes($matches)
    {
        return array_filter($matches, function ($value, $key)
        {
            return !is_int($key) && (is_numeric($value) || !empty($value));
        }, ARRAY_FILTER_USE_BOTH);
    }