Tell you about PHP hints.

Parses the file to be analyzed and traverses the obtained AST node with DFS.

@return void
493428
public function instruct()
    {
        foreach ($this->files as $file) {
            Logger::getInstance()->info('Parse: '.$file);
            try {
                $root = \ast\parse_file($file, Config::AST_VERSION);
                $this->annotations = Annotation::create($file, file_get_contents($file));
                // If file is empty, $root is not instance of Node.
                if ($root instanceof Node) {
                    $this->traverse($file, $root);
                }
            } catch (\ParseError $exception) {
                // When a parsing error occurs, the file is determined to be a syntax error.
                Logger::getInstance()->info('Parse error occurred: '.$file);
                // SyntaxError is a special tool. Pahout directly generates Hint without checking AST.
                if (!in_array('SyntaxError', Config::getInstance()->ignore_tools, true)) {
                    $this->hints[] = new Hint(
                        'SyntaxError',
                        'Syntax error occurred.',
                        $file,
                        $exception->getLine(),
                        Hint::DOCUMENT_LINK."/SyntaxError.md"
                    );
                }
            }
        }

        Logger::getInstance()->info('Hints: '.count($this->hints));
    }
683135
protected function parse()
    {
        try {
            // get parse context
            $ctx = $this->project->getReference(self::PARSING_CONTEXT_REFERENCE);
            if (null == $ctx) {
                // make a new context and register it with project
                $ctx = new PhingXMLContext($this->project);
                $this->project->addReference(self::PARSING_CONTEXT_REFERENCE, $ctx);
            }

            //record this parse with context
            $ctx->addImport($this->buildFile);

            if (count($ctx->getImportStack()) > 1) {
                $currentImplicit = $ctx->getImplicitTarget();
                $currentTargets = $ctx->getCurrentTargets();

                $newCurrent = new Target();
                $newCurrent->setProject($this->project);
                $newCurrent->setName('');
                $ctx->setCurrentTargets([]);
                $ctx->setImplicitTarget($newCurrent);

                // this is an imported file
                // modify project tag parse behavior
                $this->setIgnoreProjectTag(true);
                $this->_parse($ctx);
                $newCurrent->main();

                $ctx->setImplicitTarget($currentImplicit);
                $ctx->setCurrentTargets($currentTargets);
            } else {
                $ctx->setCurrentTargets([]);
                $this->_parse($ctx);
                $ctx->getImplicitTarget()->main();
            }
        } catch (Exception $exc) {
            //throw new BuildException("Error reading project file", $exc);
            throw $exc;
        }
    }
283098
public function tell()
	{
		if (!$this->fh)
		{
			throw new FilesystemException('File not open');
		}

		// Capture PHP errors
		$php_errormsg = '';
		$trackErrors  = ini_get('track_errors');
		ini_set('track_errors', true);

		switch ($this->processingmethod)
		{
			case 'gz':
				$res = gztell($this->fh);

				break;

			case 'bz':
			case 'f':
			default:
				$res = ftell($this->fh);

				break;
		}

		// Restore error tracking to what it was before
		ini_set('track_errors', $trackErrors);

		// May return 0 so check if it's really false
		if ($res === false)
		{
			throw new FilesystemException($php_errormsg);
		}

		// Return the result
		return $res;
	}
183122
protected function parseCode()
    {
        $brace_level      = 0;
        $parsed_code      = '';
        $parsing_complete = false;

        // Parse the code looking for the end of the function
        /** @var $token \FunctionParser\Token */
        foreach ($this->tokenizer as $token)
        {
            /***********************************************************************************************************
             * AFTER PARSING
             *
             * After the parsing is complete, we need to make sure there are no other T_FUNCTION tokens found, which
             * would indicate a possible ambiguity in the function code we retrieved. This should only happen in
             * situations where the code is minified or poorly formatted.
             */
            if ($parsing_complete)
            {
                if ($token->is(T_FUNCTION))
                {
                    throw new \RuntimeException('Cannot parse the function; multiple, non-nested functions were defined'
                        . ' in the code block containing the desired function.');
                }
                else
                {
                    continue;
                }
            }

            /***********************************************************************************************************
             * WHILE PARSING
             *
             * Scan through the tokens (while keeping track of braces) and reconstruct the code from the parsed tokens.
             */

            // Keep track of opening and closing braces
            if ($token->isOpeningBrace())
            {
                $brace_level++;
            }
            elseif ($token->isClosingBrace())
            {
                $brace_level--;

                // Once we reach the function's closing brace, mark as complete
                if ($brace_level === 0)
                {
                    $parsing_complete = true;
                }
            }

            // Reconstruct the code token by token
            $parsed_code .= $token->code;
        }

        /*
         * If all tokens have been looked at and the closing brace was not found, then there is a
         * problem with the code defining the Closure. This should probably never happen, but just
         * in case...
         */
        if (!$parsing_complete)
        {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException('Cannot parse the function because the code appeared to be invalid.');
            // @codeCoverageIgnoreEnd
        }

        return $parsed_code;
    }
575195
protected function parse()
    {
        $this->checkFormat();
        $this->parsePalmDb();
        $this->parsePalmDoc();
        $this->parseMobiHeader();
        $this->parseExth();
    }
228974
public function loadXMLStructure() {
        if ($this->fileExists()) {
            // Let's validate the XML file
            if (!$this->validateXMLStructure()) {
                return false;
            }
            $contents = file_get_contents($this->path);
            if (strpos($contents, '<STATEMENTS>')) {
                //delete the removed STATEMENTS section, it would not validate
                $contents = preg_replace('|<STATEMENTS>.*</STATEMENTS>|s', '', $contents);
                debugging('STATEMENTS section is not supported any more, please use db/install.php or db/log.php');
            }
            // File exists, so let's process it
            // Load everything to a big array
            $xmlarr = xmlize($contents);
            // Convert array to xmldb structure
            $this->xmldb_structure = $this->arr2xmldb_structure($xmlarr);
            // Analyze results
            if ($this->xmldb_structure->isLoaded()) {
                $this->loaded = true;
                return true;
            } else {
                return false;
            }
        }
        return true;
    }
744146
protected function _extract()
    {
        $this->out();
        $this->out();
        $this->out('Extracting...');
        $this->hr();
        $this->out('Paths:');
        foreach ($this->_paths as $path) {
            $this->out('   ' . $path);
        }
        $this->hr();
        $this->_extractTokens();

        $this->_languages();
        $this->_write();

        $this->_paths = $this->_files = $this->_storage = [];
        $this->_translations = $this->_tokens = [];
        $this->out();
        $this->out('Done.');
    }
173757
public function parse() {
		if($this->bParsed) {
			return;
		}

		if ($this->replacements) {
            // We cannot rely of html_entity_decode,
            // because it would replace &amp; and &lt; as well,
            // whereas we need to keep them unmodified.
            // We must do it manually, with a modified hardcopy
            // of PHP 5.4+ 's get_html_translation_table(ENT_XHTML)
            $this->source = XMLEntityTransformer::replace($this->source);
		}
		
		$this->xmlParser = xml_parser_create('UTF-8');
		xml_parser_set_option($this->xmlParser, XML_OPTION_CASE_FOLDING, false);
		xml_set_object($this->xmlParser, $this);
		xml_set_element_handler($this->xmlParser, 'openTagHandler', 'closeTagHandler');
		xml_set_character_data_handler($this->xmlParser,'cdataHandler');

		//Prepare the detection of the very first tag, in order to compute
		//the offset in XML string as regarded by the parser.
		$this->firstOpening = true;

		try {
            $bSuccess = xml_parse($this->xmlParser, $this->source);
        } catch (RequiredAttributeException $ex) {
		    throw $ex->setFile($this->filename);
        }

        if ($bSuccess) {
            $errMsg = '';
            $lineNumber = 0;
        } else {
			$errMsg = xml_error_string(xml_get_error_code($this->xmlParser));
			$lineNumber = xml_get_current_line_number($this->xmlParser);
			if(count($this->stack)) {
				$lastElement = $this->stack[count($this->stack) - 1];
				if($lastElement instanceof ViewElementTag) {
					$errMsg .= '. Last element: ' . $lastElement->getTagName() . '(' . $lineNumber . ')';
				}
			}
		}

		xml_parser_free($this->xmlParser);
		$this->bParsed = $bSuccess;

		if(! $bSuccess ) {
			throw new XMLParsingException(
					$errMsg,
					$lineNumber);
		}

		// Store a serialized version of the parsed tree, if successfully parsed,
        // and if we've got a cache path.
        if ( ($this->cachePath) && ($this->filename !== null) && (! $this->unserialized) ) {
            $cacheFile = $this->makeCacheFilename($this->cachePath, $this->templatesRoot, $this->filename, true);
            file_put_contents($cacheFile, serialize($this));
        }


    }
730821
public function parseOutsideTag() : void
    {
        if (!count($this->stream->getTokens())) {
            return;
        }

        if ($this->accept(Token::T_TEXT)) {
            $this->insert(new TextNode($this->getCurrentToken()->getValue()));
            $this->advance();
        }

        if ($this->skip(Token::T_OPENING_TAG)) {
            $this->parseStatement();
        }
    }
522307
protected function fileInfo()
    {
        $stackFrame = $this->trace();
        if (\preg_match('/eval\(/', $stackFrame['file'])) {
            \preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);
            $file = $matches[1][0];
            $line = (int) $matches[2][0];
        } else {
            $file = $stackFrame['file'];
            $line = $stackFrame['line'];
        }

        return \compact('file', 'line');
    }
249298
public function parseTranslationFile() {
        $base_path = $this->getMinkParameter('files_path');
        $base_path = $base_path."/";
        $file_path = $base_path.$this->multilingual_parameters['translations'];
        $yaml = file_get_contents($file_path);
        $yaml_parse_array_check = Yaml::parse($yaml);
        if(is_array($yaml_parse_array_check)) {
            $this->translations = $yaml_parse_array_check;
        }
    }
253373
protected function processToken(): void
    {
        $file = $this->getFile();
        $stackPos = $this->getStackPos();
        $nextTokenContentPos = $file->findNext(
            [T_DOC_COMMENT_WHITESPACE],
            $stackPos + 1,
            null,
            true
        );

        $nextToken = $this->tokens[$nextTokenContentPos];

        if (($nextToken['code'] === T_DOC_COMMENT_TAG) && ($this->token['column'] + 2 !== $nextToken['column'])) {
            // This thing is not fixable, because the codesniffer - as you can see - does not parse the whitespace as
            // a token but handles it as "columns"
            $file->addError(
                self::MESSAGE_ERROR_REDUNDANT_WHITESPACE,
                $stackPos,
                static::CODE_ERROR_REDUNDANT_WHITESPACE
            );
        }
    }
452668
public function parse()
    {
        if ($this->isParsed()) {
            return;
        }

        $this->parsed = true;

        // skip parsing for empty useragents or those not containing any letter
        if (empty($this->userAgent) || !preg_match('/([a-z])/i', $this->userAgent)) {
            return;
        }

        $this->parseBot();
        if ($this->isBot()) {
            return;
        }

        $this->parseOs();

        /**
         * Parse Clients
         * Clients might be browsers, Feed Readers, Mobile Apps, Media Players or
         * any other application accessing with an parseable UA
         */
        $this->parseClient();

        $this->parseDevice();
    }
874630
protected function parse()
	{
		if (($s = $this->copy_until_char('<'))==='')
		{
			return $this->read_tag();
		}

		// text
		$node = new Node($this);
		++$this->cursor;
		$node->_[self::HDOM_INFO_TEXT] = $s;
		$this->link_nodes($node, false);
		return true;
	}
80382
private function parse_block() {
        // split at each line
        foreach(preg_split("/(\r?\n)/", $this->docblock) as $line){

            // if starts with an asterisk
            if( preg_match('/^(?=\s+?\*[^\/])(.+)/', $line, $matches) ) {

                $info = $matches[1];

                // remove wrapping whitespace
                $info = trim($info);

                // remove leading asterisk
                $info = preg_replace('/^(\*\s+?)/', '', $info);

                // if it doesn't start with an "@" symbol
                // then add to the description
                if( $info[0] !== "@" ) {
                    $this->description .= rtrim("\n$info", '*');
                    continue;
                }else {
                    // get the name of the param
                    preg_match('/@(\w+)/', $info, $matches);
                    $param_name = $matches[1];

                    // remove the param from the string
                    $value = str_replace("@$param_name ", '', $info);

                    // if the param hasn't been added yet, create a key for it
                    if( !isset($this->all_params[$param_name]) ) {
                        $this->all_params[$param_name] = array();
                    }

                    // push the param value into place
                    $this->all_params[$param_name][] = $value;

                    continue;
                }
            }
        }
    }
718660
public function read()
    {
        
        $translationUnits = array();
        
        try{
            $translationFile = $this->getTranslationFile();
        }
        catch (tao_helpers_translation_TranslationException $e){
            $translationFile = new tao_helpers_translation_RDFTranslationFile();
        }
        
        $this->setTranslationFile($translationFile);
        $inputFile = $this->getFilePath();
        
        if (file_exists($inputFile)){
            if (is_file($inputFile)){
                if (is_readable($inputFile)){
                    
                    try{
                        $doc = new DOMDocument('1.0', 'UTF-8');
                        $doc->load($inputFile);
                        $xpath = new DOMXPath($doc);
                        $rdfNS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
                        $xmlNS = 'http://www.w3.org/XML/1998/namespace';
                        $xpath->registerNamespace('rdf', $rdfNS);
                        
                        $rootNodes = $xpath->query('//rdf:RDF');
                        if ($rootNodes->length == 1){
                            // Try to get annotations from the root node.
                            $sibling = $rootNodes->item(0)->previousSibling;
                            while ($sibling !== null){
                                if ($sibling instanceof DOMNode && $sibling->nodeType == XML_COMMENT_NODE){
                                    $annotations = tao_helpers_translation_RDFUtils::unserializeAnnotations($sibling->data);
                                    $translationFile->setAnnotations($annotations);
                                    
                                    if (isset($annotations['sourceLanguage'])){
                                        $translationFile->setSourceLanguage($annotations['sourceLanguage']);
                                    }
                                    
                                    if (isset($annotations['targetLanguage'])){
                                        $translationFile->setTargetLanguage($annotations['targetLanguage']);
                                    }
                                    
                                    break;
                                }
                                
                                $sibling = $sibling->previousSibling;
                            }
                            
                            $descriptions = $xpath->query('//rdf:Description');
                            foreach ($descriptions as $description){
                                if ($description->hasAttributeNS($rdfNS, 'about')){
                                    $subject = $description->getAttributeNS($rdfNS, 'about');
                                    
                                    // Let's retrieve properties.
                                    foreach ($description->childNodes as $property){
                                        if ($property->nodeType == XML_ELEMENT_NODE){
                                            // Retrieve namespace uri of this node.
                                            if ($property->namespaceURI != null){
                                                $predicate = $property->namespaceURI . $property->localName;
                                                
                                                // Retrieve an hypothetic target language.
                                                $lang = tao_helpers_translation_Utils::getDefaultLanguage();
                                                if ($property->hasAttributeNS($xmlNS, 'lang')){
                                                    $lang = $property->getAttributeNS($xmlNS, 'lang');
                                                }
                                                
                                                $object = $property->nodeValue;
                                                
                                                $tu = new tao_helpers_translation_RDFTranslationUnit('');
                                                $tu->setTargetLanguage($lang);
                                                $tu->setTarget($object);
                                                $tu->setSubject($subject);
                                                $tu->setPredicate($predicate);
                                                
                                                // Try to get annotations.
                                                $sibling = $property->previousSibling;
                                                while ($sibling !== null){
                                                    if ($sibling instanceof DOMNode && $sibling->nodeType == XML_COMMENT_NODE){
                                                        // We should have the annotations we are looking for.
                                                        $annotations = tao_helpers_translation_RDFUtils::unserializeAnnotations($sibling->data);
                                                        $tu->setAnnotations($annotations);
                                                        
                                                        // Set the found sources and sourcelanguages if found.
                                                        if (isset($annotations['source'])){
                                                            $tu->setSource($annotations['source']);
                                                        }
                                                    }
                                                    
                                                    $sibling = $sibling->previousSibling;
                                                }
                                                
                                                $translationUnits[] = $tu;
                                            }
                                        }
                                    }
                                }
                            }
    
                            $this->getTranslationFile()->addTranslationUnits($translationUnits);
                        }else{
                            throw new tao_helpers_translation_TranslationException("'${inputFile}' has no rdf:RDF root node or more than one rdf:RDF root node.");
                        }
                    }
                    catch (DOMException $e){
                        throw new tao_helpers_translation_TranslationException("'${inputFile}' cannot be parsed.");
                    }
                    
                }else{
                    throw new tao_helpers_translation_TranslationException("'${inputFile}' cannot be read. Check your system permissions.");
                }
            }else{
                throw new tao_helpers_translation_TranslationException("'${inputFile}' is not a file.");
            }
        }else{
            throw new tao_helpers_translation_TranslationException("The file '${inputFile}' does not exist.");
        }
        
    }
1061100
protected function load()
    {
        $data = file_get_contents($this->filename);
        // Ok, here comes the dirty work.
        // We take everything at the beginning of the file until the closing of the first doc comment.
        preg_match('#^(.+\*/)#sU', $data, $matches);

        if ($matches && count($matches[0])) {
            $this->head = $matches[0];
            if (preg_match(
                '#https://www.transifex.com/projects/p/(.*)/language/(.*)/#',
                $this->head,
                $match,
                PREG_OFFSET_CAPTURE
            )) {
                $this->transifexProject = $match[1][0][0];
                $this->language         = $match[2][0][0];
            }
        } else {
            $this->head = $this->getDefaultHead();
        }
        $this->langstrings = array();

        $parser = new Parser($this);
        $parser->setContent($data);
        $parser->parse();
    }