$parser
$parser : \PhpParser\Parser
The instance of Parser used to run this analysis.
Class StringAnalyser
$result : \Pvra\AnalysisResult
The result-instance used to store results from this analysis.
__construct(string $string, boolean $registerNameResolver = true)
StringAnalyser constructor
This constructor registers the NodeVisitor\NameResolver
node walker as first node traverser if the first
argument is set to true. Refer to the parameters documentation.
string | $string | The code to analyse |
boolean | $registerNameResolver | Inherited from the base class |
getNodeTraverser() : \PhpParser\NodeTraverserInterface
Gets the associated NodeTraverser
This method returns the associated NodeTraverser. If no NodeTraverser has been attached a default one will be created.
The NodeTraverser associated to this instance.
attachRequirementVisitor(\PhpParser\NodeVisitor|\Pvra\AnalyserAwareInterface $visitor) : $this
Attaches a RequirementVisitor.
This method should be used to attach an instance of Pvra\PhpParser\RequirementAnalyserAwareInterface
to the
current analyser. This method makes sure that RequirementAnalyserAwareInterface::setOwningAnalyser is
called using the correct parameters.
\PhpParser\NodeVisitor|\Pvra\AnalyserAwareInterface | $visitor |
Returns the current instance to allow chained calls.
attachRequirementVisitors(array<mixed,\Pvra\AnalyserAwareInterface> $visitors) : $this
Attach an array of RequirementVisitors
This method can be used to attach multiple RequirementAnalyserAwareInterface
instances at once.
Analyser::attachRequirementVisitor
is called upon each instance.
array<mixed,\Pvra\AnalyserAwareInterface> | $visitors | An array of requirement visitors |
Returns the current instance to allow chained calls.
run() : \Pvra\AnalysisResult
Execute the current Analysis
Parses the given code and runs the currently attached visitors. If run has already been called the previously generated result will be returned. The result instance returned by this method is sealed. Visitors that are attached after run is called are ignored on subsequent calls.
The sealed result.
getResult() : \Pvra\AnalysisResult
Get the result instance associated with this Analyser
If a AnalysisResult
instance is attached it will be returned.
If none was attached a default one is attached. Please be aware that you cannot set
a custom MessageFormatter
in an instance created using this.
The AnalysisResult
instance attached with this
analyser
setResultInstance(\Pvra\AnalysisResult $result) : $this
Attach a (new) ResultInstance to this analyser
Set a new result instance to this analyser. If a result was already attached or the to be attached result is already sealed an exception is thrown.
\Pvra\AnalysisResult | $result | The |
Thrown in case that the given result is sealed or an Result instance was already attached.
Returns the current instance to allow method chaining
setTraverser(\PhpParser\NodeTraverser|\PhpParser\NodeTraverserInterface $nodeTraverser)
Set the NodeTraverser used by this instance
This method allows you to set a NodeTraverser
before the default one is initialized.
This should usually happen in the constructor of a child class.
\PhpParser\NodeTraverser|\PhpParser\NodeTraverserInterface | $nodeTraverser |
parse() : array<mixed,\PhpParser\Node>
Parse the given code.
Implementations of this method should parse the given code and return a list of Node
instances.
The simplest implementation may directly return return $this->getParser()->getParse($this->getCode());
.
List of nodes representing the analysing target.
createAnalysisTargetId() : string
Create an identifier for the parsed content.
Implementations of this method should return a string that can be used to identify a given source. This may be achieved by hashing a given string or returning an absolute path.
Identifier to identify the target of this analyser.