PHPackages                             ryunosuke/polyfill-attribute - 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. ryunosuke/polyfill-attribute

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

ryunosuke/polyfill-attribute
============================

Emulate php8's attributes

v2.0.0(2y ago)1161↑96.7%MITPHPPHP &gt;=7.4

Since Mar 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/arima-ryunosuke/php-polyfill-attribute)[ Packagist](https://packagist.org/packages/ryunosuke/polyfill-attribute)[ RSS](/packages/ryunosuke-polyfill-attribute/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

PHP Attribute Polyfill
======================

[](#php-attribute-polyfill)

Description
-----------

[](#description)

This package provides attribute feature of php8 and later.

Install
-------

[](#install)

```
{
    "require": {
        "ryunosuke/polyfill-attribute": "*"
    }
}
```

Demo
----

[](#demo)

```
# Below are the same results
php74 demo/main.php
php80 demo/main.php
```

Usage
-----

[](#usage)

The `Provider` class provides a method that returns a ReflectionAttribute. This works the same way in php7/8.

Notice
------

[](#notice)

- Performance is low
- Attributes are cached per identifier if a PSR16 is specified
- Abstract syntax tree is cached per filename
- There are minute differences in `__CLASS__` of anonymous classes
- Not support continuous line attribute (e.g. `#[Attribute] private $property`)
- Attribute::$target constraint is a runtime error (in php8 it is compile time)

Release
-------

[](#release)

`@api` method Versioning follows semantic versioning.

-
    - major: change specifications (BC break)
    - minor: add feature (no BC break)
    - patch: fix bug (no BC break)

### 2.0.0

[](#200)

- \[feature\] delete utility getter
    - use ryunosuke/utility-attribute ()
- \[feature\] deprecated No cache setting

### 1.2.0

[](#120)

- \[feature\] support BetterReflection attribute
- \[feature\] support both BetterReflection 4/5

### 1.1.0

[](#110)

- \[feature\]\[Provider\] add cache per instance

### 1.0.0

[](#100)

- publish

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~230 days

Total

4

Last Release

763d ago

Major Versions

v1.2.0 → v2.0.02024-02-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/e51e177034dd7673cfaa86a43d5236ed7a6bc94f32d05c9100b039d908cd1174?d=identicon)[arima-ryunosuke](/maintainers/arima-ryunosuke)

---

Top Contributors

[![arima-ryunosuke](https://avatars.githubusercontent.com/u/7457522?v=4)](https://github.com/arima-ryunosuke "arima-ryunosuke (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ryunosuke-polyfill-attribute/health.svg)

```
[![Health](https://phpackages.com/badges/ryunosuke-polyfill-attribute/health.svg)](https://phpackages.com/packages/ryunosuke-polyfill-attribute)
```

###  Alternatives

[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M41](/packages/roave-backward-compatibility-check)[typhoon/reflection

Static PHP reflection with phpDoc support

3845.2k2](/packages/typhoon-reflection)[albertoarena/laravel-event-sourcing-generator

Laravel event sourcing domain generator

147.6k](/packages/albertoarena-laravel-event-sourcing-generator)

PHPackages © 2026

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