PHPackages                             selikhovleonid/accessors-trait - 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. selikhovleonid/accessors-trait

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

selikhovleonid/accessors-trait
==============================

Trait for Property Accessors Generation

0321PHP

Since Nov 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/selikhovleonid/accessors-trait)[ Packagist](https://packagist.org/packages/selikhovleonid/accessors-trait)[ RSS](/packages/selikhovleonid-accessors-trait/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (1)

Accessors Trait
===============

[](#accessors-trait)

Trait for Property Accessors Generation

[![Latest Unstable Version](https://camo.githubusercontent.com/508f573956f0a0e1d065cbca3e8fd662cbee36d07ee7c05a7baac17b4b1ade0e/68747470733a2f2f706f7365722e707567782e6f72672f73656c696b686f766c656f6e69642f6163636573736f72732d74726169742f762f756e737461626c65)](https://packagist.org/packages/selikhovleonid/accessors-trait)[![License](https://camo.githubusercontent.com/d32d6de7a40564c12f80a6e9a6461d16ad377ecd54c931a4a1bf6200e5f4561e/68747470733a2f2f706f7365722e707567782e6f72672f73656c696b686f766c656f6e69642f6163636573736f72732d74726169742f6c6963656e7365)](https://packagist.org/packages/selikhovleonid/accessors-trait)[![PHP from Packagist](https://camo.githubusercontent.com/40750ceaa4227c4510cc4572385212d8d6477c27015477737a7a8abf923f106c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f73656c696b686f766c656f6e69642f6163636573736f72732d74726169742e737667)](https://packagist.org/packages/selikhovleonid/accessors-trait)

Installing
----------

[](#installing)

The minimum required PHP version is PHP 5.4. You will need Composer dependency manager to install this tiny tool.

```
php composer.phar require selikhovleonid/accessors-trait

```

Quick start
-----------

[](#quick-start)

When the trait is used in a child class, it catches the calls of undeclared methods of this class. If the name of the invoked method matches the setProperty, getProperty or isPropertySet pattern and the target class has corresponding property, then this trait calls needed accessor as if it was declared directly in the child class.

You need just add one of the following tags to the PHPDoc block to mark property as accessible to the corresponding methods: `@get`, `@set`, `@isset`. The `@accessors`annotation marks property as full-accessible.

```
/**
 * Foo class description
 */
class Foo
{
    use \nadir2\tools\AccessorsTrait;

    /**
     * @var string Property description
     * @accessors
     */
    protected $property;

    /**
     * @var array Another property description
     * @get
     * @isset
     */
    private $anotherProperty = [];

    /**
     * This method sets value of 'another property'.
     * @param array $data Passed data.
     * @return self
     */
    public function setAnotherProperty(array $data)
    {
        $this->anotherProperty = $data;
        return $this;
    }
}

$foo = new Foo();

// The following code is valid
if (!$foo->isPropertySet()) {
    $foo->setProperty('bar');
    $bar = $foo->getProperty();
}
if (empty($foo->getAnotherProperty())) {
    $baz = $foo->setAnotherProperty(['baz'])->getAnotherProperty();
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ae6af76e731edc15ac6b9de066fa737972315d1998704669a79f15eb77abe52?d=identicon)[selikhovleonid](/maintainers/selikhovleonid)

---

Top Contributors

[![selikhovleonid](https://avatars.githubusercontent.com/u/8490649?v=4)](https://github.com/selikhovleonid "selikhovleonid (17 commits)")

### Embed Badge

![Health badge](/badges/selikhovleonid-accessors-trait/health.svg)

```
[![Health](https://phpackages.com/badges/selikhovleonid-accessors-trait/health.svg)](https://phpackages.com/packages/selikhovleonid-accessors-trait)
```

PHPackages © 2026

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