PHPackages                             aedart/overload - 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. aedart/overload

Abandoned → [aedart/athenaeum](/?search=aedart%2Fathenaeum)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

aedart/overload
===============

Provides means to dynamically deal with inaccessible properties, by implementing PHP's magic methods; \_\_get(), \_\_set(), \_\_isset(), and \_\_unset(). This package, however, enforces the usage of getters- and setters-methods, ensuring that if a property is indeed available, then its corresponding getter or setter method will be invoked. The term 'overload', in this context, refers to PHP’s own definition hereof. (http://php.net/manual/en/language.oop5.overloading.php)

5.1.0(7y ago)112.4k↓25%3BSD-3-ClausePHPPHP &gt;=7.1.0

Since Nov 24Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (29)Used By (3)

[![Build Status](https://camo.githubusercontent.com/a5152a49362808bfdd178e67b242179be76930f35e76090cb025cde76322f17c/68747470733a2f2f7472617669732d63692e6f72672f6165646172742f6f7665726c6f61642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aedart/overload)[![Latest Stable Version](https://camo.githubusercontent.com/d4b0269a3bf2faf7235760cb619611470283e7d0d222941296cdcadaac67ceb6/68747470733a2f2f706f7365722e707567782e6f72672f6165646172742f6f7665726c6f61642f762f737461626c65)](https://packagist.org/packages/aedart/overload)[![Total Downloads](https://camo.githubusercontent.com/6e3ba10aeaac9fd9dea824d34091a9f07abc6431a4e902e35589707fdcbb30b6/68747470733a2f2f706f7365722e707567782e6f72672f6165646172742f6f7665726c6f61642f646f776e6c6f616473)](https://packagist.org/packages/aedart/overload)[![Latest Unstable Version](https://camo.githubusercontent.com/24633b7affa87b1fea48c6538744ffb3777acfb1466a5294edcb21239ca279b0/68747470733a2f2f706f7365722e707567782e6f72672f6165646172742f6f7665726c6f61642f762f756e737461626c65)](https://packagist.org/packages/aedart/overload)[![License](https://camo.githubusercontent.com/f450aa4ad4fbf09107aeff62c454ea6eb7d9359bd59c9da9847d8419781abb48/68747470733a2f2f706f7365722e707567782e6f72672f6165646172742f6f7665726c6f61642f6c6963656e7365)](https://packagist.org/packages/aedart/overload)

Deprecated - Overload
=====================

[](#deprecated---overload)

Package has been replaced by [aedart/athenaeum](https://github.com/aedart/athenaeum)

Provides means to dynamically deal with inaccessible properties, by implementing PHP's magic methods; `__get()`, `__set()`, `__isset()`, and `__unset()`. This package, however, enforces the usage of getters- and setters-methods, ensuring that if a property is indeed available, then its corresponding getter or setter method will be invoked. The term 'overload', in this context, refers to PHP’s own definition hereof. ()

Contents
--------

[](#contents)

- [When to use this](#when-to-use-this)
- [How to install](#how-to-install)
- [Quick start](#quick-start)
    - [A Typical Class](#a-typical-class)
    - [Tip: PHPDoc](#tip--phpdoc)
- [Naming convention applied](#naming-convention-applied)
    - [Property names](#property-names)
    - [Getter / Setter names](#getter---setter-names)
- [Protected vs. Private properties](#protected-vs-private-properties)
    - [Behaviour override](#behaviour-override)
- [Custom usage](#custom-usage)
- [Contribution](#contribution)
    - [Bug Report](#bug-report)
    - [Fork, code and send pull-request](#fork--code-and-send-pull-request)
- [Versioning](#versioning)
- [License](#license)

When to use this
----------------

[](#when-to-use-this)

Generally speaking, magic methods can be very troublesome to use. For the most part, they prohibit the usage of auto-completion in IDEs and if not documented, developers are forced to read large sections of the source code, in order to gain understanding of what’s going on. Depending upon implementation, there might not be any validation, when dynamically assigning new properties to objects, which can break other components, which depend on the given object. In addition to this, it can also be very difficult to write tests for components that are using such magic methods.

This package will not be able to solve any of the mentioned problems, because at the end of the day, as a developer, you still have to ensure that the code readable / understandable, testable and documented. Therefore, I recommend that this package only to be used, if and only if, the following are all true;

- Properties shouldn't be allowed to be dynamically created and assigned to an object, without prior knowledge about them. Thus, properties must always be predefined.
- Getters and setters must always be used for reading / writing properties
- You wish to allow access to an object’s properties like such: `$person->age;` and still enforce some kind of validation.

How to install
--------------

[](#how-to-install)

```
composer require aedart/overload
```

This package uses [composer](https://getcomposer.org/). If you do not know what that is or how it works, I recommend that you read a little about, before attempting to use this package.

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

[](#quick-start)

### A Typical Class

[](#a-typical-class)

```
