PHPackages                             itrocks/extend - 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. itrocks/extend

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

itrocks/extend
==============

Some annotations to simulate more multi-inheritance in PHP

02PHP

Since Apr 24Pushed 3y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

it.rocks Extend
---------------

[](#itrocks-extend)

Hopelessly, PHP does not allow simple multiple inheritance.

Furthermore, there is no mechanism for declaring that a trait is designed to enhance a given class (or some given classes).

This little library adds a repetitive [attribute](https://www.php.net/manual/en/language.attributes.overview) named `ITRocks\Extend`, which allows to declare additional extends:

- to a class: you will be able to simulate some multi-inheritance mechanisms based on them,
- to an interface or trait: to reserve the implement/use of this to a given class,
- to a trait: tells that the trait is designed to be used in a class that inherits a class or a class using a given trait.

Another attribute, `ITRocks\Extend\Implement`, allows to declare that a trait is designed to implement the methods prototyped into given interfaces.

Examples
--------

[](#examples)

it.rocks widely use the `ITRocks\Extend` attribute to declare traits that are designed to extend base classes at will, depending on your use case deployment configuration.

```
use ITRocks\Extend;

class My_Expandable
{
	public string $a_property;
}

interface My_Interface
{
	public function getSomething() : string;
}

#[Extend(My_Expandable::class), Implement(My_Interface::class)]
trait My_Extension
{
	public string $additional_optional_property;
	public function getSomething() : string { return $this->additional_optional_property; }
}
```

Application example
-------------------

[](#application-example)

You may use the additional [itrocks/build](https://github.com/itrocks/build) library to apply these inheritance mechanisms.

With the previous example code and the following configuration :

```
$configuration = [My_Expandable::class => [My_Extension::class]];
```

[itrocks/build](https://github.com/itrocks/build) will replace all instantiations of My\_Expandable into your source code by instantiations of the following built class:

```
class My_Expandable\B extends My_Expandable implements My_Interface
{
  use My_Extension;
}
```

Refer to the documentation of [itrocks/build](https://github.com/itrocks/build) to see how.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity22

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c59494f987e0e7b01198896224a0ed287c0406c2d216b9c6d7a239d912fb7c5?d=identicon)[itrocks](/maintainers/itrocks)

---

Top Contributors

[![baptistepillot](https://avatars.githubusercontent.com/u/3451236?v=4)](https://github.com/baptistepillot "baptistepillot (1 commits)")

### Embed Badge

![Health badge](/badges/itrocks-extend/health.svg)

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

###  Alternatives

[leafo/lessphp

lessphp is a compiler for LESS written in PHP.

2.2k8.2M141](/packages/leafo-lessphp)[chelout/laravel-relationship-events

Missing relationship events for Laravel

5252.3M17](/packages/chelout-laravel-relationship-events)[marcocesarato/php-conventional-changelog

Generate changelogs and release notes from a project's commit messages and metadata and automate versioning with semver.org and conventionalcommits.org

2511.3M109](/packages/marcocesarato-php-conventional-changelog)[larapack/dd

`dd` is a helper method in Laravel. This package will add the `dd` to your application.

1162.5M432](/packages/larapack-dd)[idiosyncratic/editorconfig

PHP implementation of EditorConfig

191.9M1](/packages/idiosyncratic-editorconfig)

PHPackages © 2026

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