PHP Class Neos\Flow\Utility\PhpAnalyzer

Usage: extract the FQN e.g. "Some\Namespace\SomeClassName" $fullyQualifiedClassName = (new PhpAnalyzer($fileContents))->extractFullyQualifiedClassName(); extract the namespace "Some\Namespace" $namespace = (new PhpAnalyzer($fileContents))->extractNamespace(); extract just the class name "SomeClassName" $className = (new PhpAnalyzer($fileContents))->extractClassName();
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$phpCode string

Public Methods

Method Description
__construct ( string $phpCode )
extractClassName ( ) : string Extracts the className of the given PHP code Note: This only returns the class name without namespace, @see extractFullyQualifiedClassName()
extractFullyQualifiedClassName ( ) : string Extracts the Fully Qualified Class name from the given PHP code
extractNamespace ( ) : string Extracts the PHP namespace from the given PHP code

Method Details

__construct() public method

public __construct ( string $phpCode )
$phpCode string

extractClassName() public method

Extracts the className of the given PHP code Note: This only returns the class name without namespace, @see extractFullyQualifiedClassName()
public extractClassName ( ) : string
return string

extractFullyQualifiedClassName() public method

Extracts the Fully Qualified Class name from the given PHP code
public extractFullyQualifiedClassName ( ) : string
return string FQN in the format "Some\Fully\Qualified\ClassName" or NULL if no class was detected

extractNamespace() public method

Extracts the PHP namespace from the given PHP code
public extractNamespace ( ) : string
return string the PHP namespace in the form "Some\Namespace" (w/o leading backslash) - or NULL if no namespace modifier was found

Property Details

$phpCode protected property

protected string $phpCode
return string