PHPackages                             jasny/fqcn-reader - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jasny/fqcn-reader

Abandoned → [phpdocumentor/type-resolver](/?search=phpdocumentor%2Ftype-resolver)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

jasny/fqcn-reader
=================

Library to extract PHP class name from source file

v1.0.0(7y ago)05.2k1[1 issues](https://github.com/jasny/fqcn-reader/issues)[1 PRs](https://github.com/jasny/fqcn-reader/pulls)MITPHPPHP &gt;=7.1.0

Since Aug 16Pushed 5y agoCompare

[ Source](https://github.com/jasny/fqcn-reader)[ Packagist](https://packagist.org/packages/jasny/fqcn-reader)[ RSS](/packages/jasny-fqcn-reader/feed)WikiDiscussions master Synced today

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

Jasny FQCN Reader
=================

[](#jasny-fqcn-reader)

[![Build Status](https://camo.githubusercontent.com/02d8a28f7402bc0acd60b19af6ebb31083ad250daeb9eba339500ce7bfb7e344/68747470733a2f2f7472617669732d63692e6f72672f6a61736e792f6671636e2d7265616465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jasny/%7B%7Blibrary%7D%7D)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/36f18190b2f0f800224e73ac0baf7b728e97efa28d561ae27fc761b5f30b5fca/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f6671636e2d7265616465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/%7B%7Blibrary%7D%7D/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/5befca456855792b65d8269057fb3d8a1ad1d9482a03c3e0af4e7641d9c54261/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f6671636e2d7265616465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/%7B%7Blibrary%7D%7D/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/922b9c1008baf39696f60bca14011e2a9e594f200ddec2a601ed838371bb06f7/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31393736643264652d316339632d346334322d386263642d3432306666373865346531632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/1976d2de-1c9c-4c42-8bcd-420ff78e4e1c)[![BCH compliance](https://camo.githubusercontent.com/a5957d3e6cab7fe5b5df0b0bc14751b88468204267ce2087a2ba66b99025b7d2/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f6a61736e792f6671636e2d7265616465723f6272616e63683d6d6173746572)](https://bettercodehub.com/)[![Packagist Stable Version](https://camo.githubusercontent.com/6967b1f7cc043a09cd1b283b8d3170a27c12665258fd114721168c3fa5bda02b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f6671636e2d7265616465722e737667)](https://packagist.org/packages/jasny/%7B%7Blibrary%7D%7D)[![Packagist License](https://camo.githubusercontent.com/8544a95ff562aae82716ca789a4341479df8cdd8b852ccef7788b0ed04bf7020/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f6671636e2d7265616465722e737667)](https://packagist.org/packages/jasny/%7B%7Blibrary%7D%7D)

Library to extract fully qualified class name (FQCN) from a PHP source file.

*Caveat; only considers one class per source file.*

Installation
------------

[](#installation)

```
composer require jasny/fqcn-reader

```

Usage
-----

[](#usage)

### Single source file

[](#single-source-file)

The `FQCNReader` allows extracting a class name from a PHP source file.

```
use Jasny\FQCN\FQCNReader;

$reader = new FQCNReader();

$class = $reader->getClass("path/to/source.php");
```

### Interator

[](#interator)

The `FQCNIterator` is an [`OuterIterator`](http://php.net/manual/en/class.outeriterator.php), meaning it will iterate over an iterator applying logic. The iterator expects to traverse over source files.

With the file names in an array, use [`ArrayIterator`](http://php.net/ArrayIterator).

```
use Jasny\FQCN\FQCNIterator;

$sourceFiles = glob('path/to/directory/*.php');
$sourceIterator = new ArrayIteractor($sourceFiles);

$fqcnIterator = new FQCNIterator($sourceIterator);

foreach ($fqcnIteractor as $file => $class) {
   // do something with $class
}
```

Alternatively use SPL Iterators like [`DirectoryIterator`](http://php.net/DirectoryIterator), [`RecursiveDirectoryIterator`](http://php.net/RecursiveDirectoryIterator) or [`GlobIterator`](http://php.net/GlobIterator).

```
use Jasny\FQCN\FQCNIterator;

$directoryIterator = new RecursiveDirectoryIterator('path/to/project/');
$recursiveIterator = new RecursiveIteratorIterator($directoryIterator);
$sourceIterator = new RegexIterator($recursiveIterator, '/^.+\.php$/i', RegexIterator::GET_MATCH);

$fqcnIterator = new FQCNIterator($sourceIterator);

foreach ($fqcnIteractor as $file => $class) {
   // do something with $class
}
```

Files that do not define a class are skipped.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.2% 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

2826d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3379a93d51305df325df9045e1a8b205d195e4e8c01312dff53a000ee79002eb?d=identicon)[jasny](/maintainers/jasny)

---

Top Contributors

[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (9 commits)")[![MichielCuijpers](https://avatars.githubusercontent.com/u/18576001?v=4)](https://github.com/MichielCuijpers "MichielCuijpers (4 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jasny-fqcn-reader/health.svg)

```
[![Health](https://phpackages.com/badges/jasny-fqcn-reader/health.svg)](https://phpackages.com/packages/jasny-fqcn-reader)
```

PHPackages © 2026

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