src/PhpDocument.php
public function updateContent(string $content)
    {
        // Unregister old definitions
        if (isset($this->definitions)) {
            foreach ($this->definitions as $fqn => $definition) {
                $this->index->removeDefinition($fqn);
            }
        }

        // Unregister old references
        if (isset($this->referenceNodes)) {
            foreach ($this->referenceNodes as $fqn => $node) {
                $this->index->removeReferenceUri($fqn, $this->uri);
            }
        }

        $this->referenceNodes = null;
        $this->definitions = null;
        $this->definitionNodes = null;

        $treeAnalyzer = new TreeAnalyzer($this->parser, $content, $this->docBlockFactory, $this->definitionResolver, $this->uri);

        $this->diagnostics = $treeAnalyzer->getDiagnostics();

        $this->definitions = $treeAnalyzer->getDefinitions();

        $this->definitionNodes = $treeAnalyzer->getDefinitionNodes();

        $this->referenceNodes = $treeAnalyzer->getReferenceNodes();

        foreach ($this->definitions as $fqn => $definition) {
            $this->index->setDefinition($fqn, $definition);
        }

        // Register this document on the project for references
        foreach ($this->referenceNodes as $fqn => $nodes) {
            // Cast the key to string. If (string)'2' is set as an array index, it will read out as (int)2. We must
            // deal with incorrect code, so this is a valid scenario.
            $this->index->addReferenceUri((string)$fqn, $this->uri);
        }

        $this->sourceFileNode = $treeAnalyzer->getSourceFileNode();
    }
public function updateContent(string $content)
    {
        // Unregister old definitions
        if (isset($this->definitions)) {
            foreach ($this->definitions as $fqn => $definition) {
                $this->index->removeDefinition($fqn);
            }
        }

        // Unregister old references
        if (isset($this->referenceNodes)) {
            foreach ($this->referenceNodes as $fqn => $node) {
                $this->index->removeReferenceUri($fqn, $this->uri);
            }
        }

        $this->referenceNodes = null;
        $this->definitions = null;
        $this->definitionNodes = null;

        $treeAnalyzer = new TreeAnalyzer($this->parser, $content, $this->docBlockFactory, $this->definitionResolver, $this->uri);

        $this->diagnostics = $treeAnalyzer->getDiagnostics();

        $this->definitions = $treeAnalyzer->getDefinitions();

        $this->definitionNodes = $treeAnalyzer->getDefinitionNodes();

        $this->referenceNodes = $treeAnalyzer->getReferenceNodes();

        foreach ($this->definitions as $fqn => $definition) {
            $this->index->setDefinition($fqn, $definition);
        }

        // Register this document on the project for references
        foreach ($this->referenceNodes as $fqn => $nodes) {
            // Cast the key to string. If (string)'2' is set as an array index, it will read out as (int)2. We must
            // deal with incorrect code, so this is a valid scenario.
            $this->index->addReferenceUri((string)$fqn, $this->uri);
        }

        $this->sourceFileNode = $treeAnalyzer->getSourceFileNode();
    }
public function updateContent ( string $ content ) { // Unregister old definitions if ( isset ( $ this -> definitions ) ) { foreach ( $ this -> definitions as $ fqn => $ definition ) { $ this -> index -> removeDefinition ( $ fqn ) ; } } // Unregister old references if ( isset ( $ this -> referenceNodes ) ) { foreach ( $ this -> referenceNodes as $ fqn => $ node ) { $ this -> index -> removeReferenceUri ( $ fqn , $ this -> uri ) ; } } $ this -> referenceNodes = null ; $ this -> definitions = null ; $ this -> definitionNodes = null ; $ treeAnalyzer = new TreeAnalyzer ( $ this -> parser , $ content , $ this -> docBlockFactory , $ this -> definitionResolver , $ this -> uri ) ; $ this -> diagnostics = $ treeAnalyzer -> getDiagnostics ( ) ; $ this -> definitions = $ treeAnalyzer -> getDefinitions ( ) ; $ this -> definitionNodes = $ treeAnalyzer -> getDefinitionNodes ( ) ; $ this -> referenceNodes = $ treeAnalyzer -> getReferenceNodes ( ) ; foreach ( $ this -> definitions as $ fqn => $ definition ) { $ this -> index -> setDefinition ( $ fqn , $ definition ) ; } // Register this document on the project for references foreach ( $ this -> referenceNodes as $ fqn => $ nodes ) { // Cast the key to string. If (string)'2' is set as an array index, it will read out as (int)2. We must // deal with incorrect code, so this is a valid scenario. $ this -> index -> addReferenceUri ( ( string ) $ fqn , $ this -> uri ) ; } $ this -> sourceFileNode = $ treeAnalyzer -> getSourceFileNode ( ) ; }
Updates the content on this document.
Re-parses a source file, updates symbols and reports parsing errors
that may have occurred as diagnostics.

@param string $content
@return void
Updates the content on this document . Re - parses a source file updates symbols and reports parsing errors that may have occurred as diagnostics .