PHPackages                             envorradev/file-class-resolver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. envorradev/file-class-resolver

ActiveLibrary[File &amp; Storage](/categories/file-storage)

envorradev/file-class-resolver
==============================

0.1(3y ago)013MITPHPPHP ^8.1

Since Sep 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/envorradev/file-class-resolver)[ Packagist](https://packagist.org/packages/envorradev/file-class-resolver)[ RSS](/packages/envorradev-file-class-resolver/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

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
=======

[](#install)

```
$ composer require envorradev/file-class-resolver
```

Usage
=====

[](#usage)

The following examples will use the following sample class:

```
namespace SomeNamespace\SomeFolder;

class SomeClass {
    public function __construct(
        public string $aRequiredString,
        public int $anOptionalInt = 5,
    ) {}
}
```

```
$filename = __DIR__.'/SomeFolder/SomeClass.php';
```

They also assume you have imported the resolver class via:

```
use Envorra\FileClassResolver\ClassResolver;
```

Resolve a Fully Qualified Class Name
------------------------------------

[](#resolve-a-fully-qualified-class-name)

```
ClassResolver::resolve($filename);
```

Returns

```
'SomeNamespace\SomeFolder\SomeClass'

```

Make an Instance
----------------

[](#make-an-instance)

### Class with No Required Parameters

[](#class-with-no-required-parameters)

```
ClassResolver::make($someOtherClassPath);
```

### Class with Required Parameters

[](#class-with-required-parameters)

Pass the parameters as an array as the parameter for the `make` method:

```
ClassResolver::make($filename, ['string value', 10]);
```

Only the required parameters need to be passed:

```
ClassResolver::make($filename, ['string value']);
```

You can pass the parameters as named parameters:

```
ClassResolver::make($filename, ['aRequiredString' => 'string value', 'anOptionalInt' => 7]);
```

When using named parameters, the order does not matter:

```
ClassResolver::make($filename, ['anOptionalInt' => 7, 'aRequiredString' => 'string value']);
```

Get the Resolver Instance
-------------------------

[](#get-the-resolver-instance)

```
ClassResolver::resolver($filename);
```

Returns a `ClassResolver` Instance.

### Available ClassResolver Methods

[](#available-classresolver-methods)

In the below examples:

```
$resolver = ClassResolver::resolve($filename);
```

#### getClass(): ?string

[](#getclass-string)

Gets the fully qualified class name.

Same as `ClassResolver::resolve($filename)` and `$resolver->getFullyQualifiedClassName()`

```
$resolver->getClass();
```

Returns

```
'SomeNamespace\SomeFolder\SomeClass'
```

#### getClassInstance(array $parameters = \[\]): ?object

[](#getclassinstancearray-parameters---object)

Get an instance of the class.

Same as `ClassResolver::make($filename, $parameters)`

```
$resolver->getClassInstance(['string']);
```

Returns an instance of `SomeClass`

#### getClassName(): ?string

[](#getclassname-string)

Gets onlt the name of the class.

```
$resolver->getClassName();
```

Returns

```
'SomeClass'
```

#### getClassNode(): \\PhpParser\\Node\\Stmt\\Class\_

[](#getclassnode-phpparsernodestmtclass_)

Gets the `\PhpParser\Node\Stmt\Class_` node.

See: [nikic/php-parser](https://github.com/nikic/PHP-Parser) and [Class\_](https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/Node/Stmt/Class_.php)

```
$resolver->getClassNode();
```

Returns something like:

```
PhpParser\Node\Stmt\Class_ {#8563
    +name: PhpParser\Node\Identifier {#8550
        +name: "SomeClass",
    },
    +stmts: [
        PhpParser\Node\Stmt\ClassMethod {#8562
            +flags: 1,
            +byRef: false,
            +name: PhpParser\Node\Identifier {#8551
                +name: "__construct",
            },
            +params: [
                PhpParser\Node\Param {#8554
                    +type: PhpParser\Node\Identifier {#8553
                        +name: "string",
                    },
                    +byRef: false,
                    +variadic: false,
                    +var: PhpParser\Node\Expr\Variable {#8552
                        +name: "aRequiredString",
                    },
                    +default: null,
                    +flags: 1,
                    +attrGroups: [],
                },
                PhpParser\Node\Param {#8557
                    +type: PhpParser\Node\Identifier {#8556
                        +name: "int",
                    },
                    +byRef: false,
                    +variadic: false,
                    +var: PhpParser\Node\Expr\Variable {#8555
                        +name: "anOptionalInt",
                    },
                    +default: null,
                    +flags: 1,
                    +attrGroups: [],
                },
            ],
            +returnType: null,
            +stmts: [],
            +attrGroups: [],
        },
    ],
    +attrGroups: [],
    +namespacedName: null,
    +flags: 0,
    +extends: null,
    +implements: [],
}
```

#### getFullyQualifiedClassName(): ?string

[](#getfullyqualifiedclassname-string)

Gets the fully qualified class name.

Same as `ClassResolver::resolve($filename)` and `$resolver->getClass()`

```
$resolver->getFullyQualifiedClassName();
```

Returns

```
'SomeNamespace\SomeFolder\SomeClass'
```

#### getNamespace(): ?string

[](#getnamespace-string)

Gets only the namespace of the class.

```
$resolver->getNamespace();
```

Returns

```
'SomeNamespace\SomeFolder'
```

#### getNamespaceNode(): \\PhpParser\\Node\\Stmt\\Namespace\_

[](#getnamespacenode-phpparsernodestmtnamespace_)

Gets the `\PhpParser\Node\Stmt\Namespace_` node.

See: [nikic/php-parser](https://github.com/nikic/PHP-Parser) and [Namespace\_](https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/Node/Stmt/Namespace_.php)

```
$resolver->getNamespaceNode();
```

Returns something like:

```
PhpParser\Node\Stmt\Namespace_ {#8549
    +name: PhpParser\Node\Name {#8548
        +parts: [
            "SomeNamespace",
            "SomeFolder",
        ],
    },
    +stmts: [
        PhpParser\Node\Stmt\Class_ {#8563
            +name: PhpParser\Node\Identifier {#8550
                +name: "SomeClass",
            },
            +stmts: [
                PhpParser\Node\Stmt\ClassMethod {#8562
                    +flags: 1,
                    +byRef: false,
                    +name: PhpParser\Node\Identifier {#8551
                        +name: "__construct",
                    },
                    +params: [
                        PhpParser\Node\Param {#8554
                            +type: PhpParser\Node\Identifier {#8553
                                +name: "string",
                            },
                            +byRef: false,
                            +variadic: false,
                            +var: PhpParser\Node\Expr\Variable {#8552
                                +name: "aRequiredString",
                            },
                            +default: null,
                            +flags: 1,
                            +attrGroups: [],
                        },
                        PhpParser\Node\Param {#8557
                            +type: PhpParser\Node\Identifier {#8556
                                +name: "int",
                            },
                            +byRef: false,
                            +variadic: false,
                            +var: PhpParser\Node\Expr\Variable {#8555
                                +name: "anOptionalInt",
                            },
                            +default: null,
                            +flags: 1,
                            +attrGroups: [],
                        },
                    ],
                    +returnType: null,
                    +stmts: [],
                    +attrGroups: [],
                },
            ],
            +attrGroups: [],
            +namespacedName: null,
            +flags: 0,
            +extends: null,
            +implements: [],
        },
    ],
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83340094473f0bf5b2cf062bf394df221a52a30aa0e21cd0a77302977d6393ce?d=identicon)[samueljtaylor](/maintainers/samueljtaylor)

---

Top Contributors

[![samyrataylor](https://avatars.githubusercontent.com/u/15961687?v=4)](https://github.com/samyrataylor "samyrataylor (11 commits)")

---

Tags

phpphp8php81resolver

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/envorradev-file-class-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/envorradev-file-class-resolver/health.svg)](https://phpackages.com/packages/envorradev-file-class-resolver)
```

###  Alternatives

[psy/psysh

An interactive shell for modern PHP.

9.8k582.3M817](/packages/psy-psysh)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k144.5M593](/packages/zircote-swagger-php)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/packages/behat-behat)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M96](/packages/dedoc-scramble)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k28.9M2.3k](/packages/infection-infection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
