PHPackages                             cresset/module-fused-interceptors - 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. cresset/module-fused-interceptors

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

cresset/module-fused-interceptors
=================================

Replaces Magento's dynamic interceptors with fused (inlined-chain) interceptors generated at setup:di:compile time.

0.1.0(today)00OSL-3.0PHPPHP ~8.4.0||~8.5.0

Since Jul 1Pushed todayCompare

[ Source](https://github.com/cresset-tools/module-fused-interceptors)[ Packagist](https://packagist.org/packages/cresset/module-fused-interceptors)[ RSS](/packages/cresset-module-fused-interceptors/feed)WikiDiscussions main Synced today

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

Cresset\_FusedInterceptors
==========================

[](#cresset_fusedinterceptors)

Replaces Magento's **dynamic** interceptor with a **fused** one at `setup:di:compile`time. Instead of per-call `PluginList::getNext()` + the `___callPlugins` closure, each plugged method inlines its resolved plugin chain as straight-line PHP, with scope branching baked in. On a representative catalog store this removed ~30% of a request's PHP function calls and ~4–5 ms (~8–11%) off PLP/PDP render in production, with behaviour identical to the stock interceptor.

How it hooks in
---------------

[](#how-it-hooks-in)

Magento's compile-time interceptor generator, `Magento\Setup\Module\Di\Code\Generator\Interceptor`, is instantiated via `ObjectManager::create()`, so it is replaceable by a plain DI **preference** (`etc/di.xml`):

```
Magento\Setup\Module\Di\Code\Generator\Interceptor
    → Cresset\FusedInterceptors\Code\Generator\FusedInterceptor

```

`setup:di:compile` clears `generated/code` and reads `di.xml` live, so the preference applies on the very first run — no priming compile, no post-processing, no file rewriting. `FusedInterceptor::_generateCode()` emits the fused class; anything it can't fuse safely falls back to the stock dynamic interceptor, so compilation can never break.

(A plugin on `DiCompileCommand` does **not** work — its `execute()` is protected and the Setup module runs outside app interception. Replacing the generator is the correct hook.)

Components
----------

[](#components)

ClassRole`Code\Generator\FusedInterceptor`Overrides `_generateCode()`: extract chains → emit fused, else fall back to stock.`Model\ChainExtractor`Per-scope plugin chains for a type. One warmed PluginList per scope (global + every area); clean, non-accumulating, no subprocess.`Model\CodeEmitter`Turns the per-scope chains into fused PHP (pruning, scope dispatch, before/after threading, around → nested-closure onion, lazy resolve-once plugin caches).What the generated interceptor does
-----------------------------------

[](#what-the-generated-interceptor-does)

- Overrides only plugged methods (everything else inherited).
- No constructor — inherits the subject's, so the OM injects real deps unchanged. Plugins/scope are resolved lazily via the global OM at call time, so building the interceptor never forces a plugin to construct (no circular-dependency risk).
- `switch` on `getCurrentScope()` only when the chain differs across scopes.
- Faithful to `Interceptor::___callPlugins`: before rewrites args (`if ($r !== null)`), after reassigns `$result`, around plugins get a real `$next` closure per chain segment.
- Around chains minimise closure allocations: the outermost segment is inlined into the method body (never passed as a `$next`), and a terminal with no before/after is passed as the first-class callable `parent::method(...)` rather than a wrapper closure — ~50% fewer closures for a single around, ~28% for before+around+after+around.
- Falls back to the stock dynamic interceptor for a method with a by-reference or variadic parameter.

Install
-------

[](#install)

```
composer require cresset/module-fused-interceptors
bin/magento module:enable Cresset_FusedInterceptors
bin/magento setup:upgrade
bin/magento setup:di:compile     # interceptors come out fused
```

Disable by removing the module (`composer remove cresset/module-fused-interceptors`or the preference) and recompiling.

Requirements
------------

[](#requirements)

- Mage-OS / Magento Open Source 2.4+ (Mage-OS `framework` ^3.0)
- PHP 8.4 / 8.5

License
-------

[](#license)

OSL-3.0 / AFL-3.0.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

0d ago

### Community

Maintainers

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

---

Top Contributors

[![pingiun](https://avatars.githubusercontent.com/u/1576660?v=4)](https://github.com/pingiun "pingiun (2 commits)")

### Embed Badge

![Health badge](/badges/cresset-module-fused-interceptors/health.svg)

```
[![Health](https://phpackages.com/badges/cresset-module-fused-interceptors/health.svg)](https://phpackages.com/packages/cresset-module-fused-interceptors)
```

###  Alternatives

[kevinlebrun/slug.php

Slug helpers

4952.9k1](/packages/kevinlebrun-slugphp)[dintel/php-github-webhook

Simple class for handling GitHub webhook calls

5216.5k](/packages/dintel-php-github-webhook)

PHPackages © 2026

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