PHPackages                             hudsxn/introspection - 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. hudsxn/introspection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hudsxn/introspection
====================

Rapid Reflection utility with extra ergonomic functions

v1.0.1(4mo ago)05MITPHP

Since Jan 4Pushed 4mo agoCompare

[ Source](https://github.com/hudsxncom/introspection)[ Packagist](https://packagist.org/packages/hudsxn/introspection)[ RSS](/packages/hudsxn-introspection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Hudsxn Introspection
====================

[](#hudsxn-introspection)

Hudsxn Introspection is a **high-performance PHP library** for full-depth class, interface, and trait introspection. It captures **properties, constants, methods, method arguments, and attributes** while supporting **memory caching**, **filesystem-backed caching**, and selective or full refresh modes. Ideal for frameworks, static analysis tools, IDE integrations, and any system that requires reliable reflection metadata.

---

Features
--------

[](#features)

- Deep introspection of **classes, interfaces, and traits**
- **Memory caching** for repeated accesses
- **Filesystem caching** to persist introspection results across requests
- **Refresh mode** to regenerate metadata when source changes
- **Selective refresh** to optimize performance in large systems
- Singleton-based introspector for centralized caching and consistent results
- Fully **tested** and production-ready

---

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

[](#installation)

Install via Composer:

```
composer require hudsxn/introspection
```

---

Basic Usage
-----------

[](#basic-usage)

```
use Hudsxn\Introspection\Introspector;

// Get singleton instance
$introspector = Introspector::getSelf();

// Initialize with cache directory
$introspector->init(__DIR__ . '/cache');

// Set mode (fastest in-memory caching)
$introspector->setMode(Introspector::MODE_FASTEST);

// Introspect a class
$classObj = $introspector->getClass(MyApp\ExampleClass::class);

// Access properties
foreach ($classObj->getProperties() as $property) {
    echo $property->getName() . ': ' . $property->getType() . PHP_EOL;
}

// Access methods and arguments
foreach ($classObj->getMethods() as $method) {
    echo $method->getName() . '(): ' . $method->getReturnType() . PHP_EOL;
    foreach ($method->getArguments() as $arg) {
        echo '  - ' . $arg->getName() . ': ' . $arg->getType() . PHP_EOL;
    }
}
```

---

Refresh Modes
-------------

[](#refresh-modes)

- **Default:** Uses memory and filesystem caches
- **Refresh:** Regenerates class metadata from source
- **Selective Refresh:** Only refresh specific classes

```
// Refresh a single class
$introspector->setMode([\MyApp\ExampleClass::class]);
$refreshedClass = $introspector->getClass(MyApp\ExampleClass::class);
```

---

Filesystem Cache
----------------

[](#filesystem-cache)

- The library can **persist introspected metadata to disk** for faster repeated access.
- Clearing memory cache does **not remove filesystem cache**, so subsequent requests will load cached PHP files.

```
// Clear only memory cache
$introspector->clearInstanceCache();

// Clear memory + filesystem cache
$introspector->clearCache();
```

---

Performance Benefits
--------------------

[](#performance-benefits)

OperationWithout CacheWith Memory CacheWith Filesystem CacheFirst introspection100% parsing overheadN/AN/ASecond introspection100% parsingNear-instantNear-instantSubsequent request after memory clear100% parsingN/ANear-instant (loaded from disk)- **Memory cache** ensures repeated accesses are **nearly instantaneous**.
- **Filesystem cache** avoids repeated reflection parsing across processes.
- Works seamlessly for **hundreds of classes** with negligible overhead.

---

---

Testing
-------

[](#testing)

Run full test suite:

```
composer install
vendor/bin/phpunit
```

- The library is fully tested for **memory caching, filesystem caching, refresh modes**, and **deep introspection** of classes, interfaces, and traits.
- Tests validate that cached files maintain **100% fidelity** with native PHP reflection.

---

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit pull requests or open issues on GitHub.

- Follow PSR-12 coding standards
- Include tests for new features or fixes
- Ensure **cache and introspection integrity**

---

License
-------

[](#license)

MIT License – see [LICENSE](LICENSE)

---

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance82

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

Every ~0 days

Total

2

Last Release

125d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1c414ede123b1a90a206934071021be75f144fa79c077ded9919e9c0852a53d?d=identicon)[Hudsxn](/maintainers/Hudsxn)

---

Top Contributors

[![hudson1998x](https://avatars.githubusercontent.com/u/22916228?v=4)](https://github.com/hudson1998x "hudson1998x (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hudsxn-introspection/health.svg)

```
[![Health](https://phpackages.com/badges/hudsxn-introspection/health.svg)](https://phpackages.com/packages/hudsxn-introspection)
```

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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