How to Implement PHP Class Callbacks with Minimal Code - Armory PHP Closure Trait package blog

Recommend this page to a friend!
  All package blogs All package blogs   Armory PHP Closure Trait Armory PHP Closure Trait   Blog Armory PHP Closure Trait package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Implement PHP ...  
  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Updated on: 2020-10-08

Posted on: 2020-10-08

Package: Armory PHP Closure Trait

Some classes need to implement a callback system that allows applications to customize actions to be executed when certain events happen inside the class.

This package provides a trait that can be used to quickly add callback function registration and invocation for any number of types of events that a class may trigger.




About the Armory PHP Closure Trait Package

The package Armory PHP Closure Trait is one of the few PHP packages that was considered notable recently because it does something that is worth paying attention.

The basic purpose is: Cache, rename and hide anonymous functions

Here follows in more detail what it does:

This package provides a trait to cache, rename and hide your anonymous and callback functions in a class object instance.

It provides a protected array to store the functions under a different name.

By declaring the functions as properties of the class object, getter and setter methods take care of the hiding. The executing scope is preserved.

The trait can be used to gather all callback functions and store them in a protected variable to avoid name collisions.

It can also make class functions available without the necessity of retrieving the object instances first.

Conclusion

The Armory PHP Closure Trait can be downloaded from download page or be installed using the PHP Composer tool following instructions in the Composer install instructions page.

This package was considered notable for implementing its benefits in a way that is worth noticing.

Notable PHP packages can be often considered innovative. If this package is also innovative, it can be nominated to the PHP Innovation Award and the author may win prizes and recognition for sharing innovative packages.

If you also developed your own notable or innovative packages consider sharing them, so you can also earn more visibility for your package as well nice prizes.

One nice prize that many PHP developers want and you may like is the PHP elePHPant mascot plush.




You need to be a registered user or login to post a comment

1,564,876 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

No comments were submitted yet.




  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
  All package blogs All package blogs   Armory PHP Closure Trait Armory PHP Closure Trait   Blog Armory PHP Closure Trait package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Implement PHP ...  

For more information send a message to info at phpclasses dot org.