Download the PHP package envorradev/file-class-resolver without Composer
On this page you can find all versions of the php package envorradev/file-class-resolver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package file-class-resolver
File Class Resolver
A simple tool to resolve the fully qualified class name and an instance of the class given the path to the file.
Install
Usage
The following examples will use the following sample class:
They also assume you have imported the resolver class via:
Resolve a Fully Qualified Class Name
Returns
Make an Instance
Class with No Required Parameters
Class with Required Parameters
Pass the parameters as an array as the parameter for the make
method:
Only the required parameters need to be passed:
You can pass the parameters as named parameters:
When using named parameters, the order does not matter:
Get the Resolver Instance
Returns a ClassResolver
Instance.
Available ClassResolver Methods
In the below examples:
getClass(): ?string
Gets the fully qualified class name.
Same as ClassResolver::resolve($filename)
and $resolver->getFullyQualifiedClassName()
Returns
getClassInstance(array $parameters = []): ?object
Get an instance of the class.
Same as ClassResolver::make($filename, $parameters)
Returns an instance of SomeClass
getClassName(): ?string
Gets onlt the name of the class.
Returns
getClassNode(): \PhpParser\Node\Stmt\Class_
Gets the \PhpParser\Node\Stmt\Class_
node.
See: nikic/php-parser and Class_
Returns something like:
getFullyQualifiedClassName(): ?string
Gets the fully qualified class name.
Same as ClassResolver::resolve($filename)
and $resolver->getClass()
Returns
getNamespace(): ?string
Gets only the namespace of the class.
Returns
getNamespaceNode(): \PhpParser\Node\Stmt\Namespace_
Gets the \PhpParser\Node\Stmt\Namespace_
node.
See: nikic/php-parser and Namespace_
Returns something like: