2017 © Pedro Peláez
 

library closureaccess

Brings JavaScript-like functionality to your objects

image

camspiers/closureaccess

Brings JavaScript-like functionality to your objects

  • Tuesday, June 3, 2014
  • by camspiers
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Closure Access

The closure access trait brings JavaScript-like functionality to your objects in the following ways:, (*1)

  • Public methods on objects can be accessed as properties e.g. $obj->methodName
  • Closures added to objects can be executed like public methods e.g. $obj->closureProp()

No claims are made as to whether you should use this library, it is provided more as a proof of concept., (*2)

Installation (with composer)

composer require camspiers/closureaccess:dev-master

Performance

  • Accessing public methods as properties e.g. $obj->methodName (return Closure)
    • ~2.1x slower
  • Closures added to objects can be executed like public methods e.g. $obj->closureProp()
    • ~3.1x slower

Usage


class A { use Camspiers\ClosureAccess; public function hello() { return "Hello"; } } function run($fn) { return $fn(); } $a = new A; // an example of accessing a public method via properties and passing it around echo run($a->hello), ', World'; // an example of executing a closure property as a method $a->world = function () { return "World"; }; echo 'Hello, ', $a->world();

The Versions

03/06 2014

dev-master

9999999-dev

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires

03/06 2014

0.3.1

0.3.1.0

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires

03/06 2014

0.3.0

0.3.0.0

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires

03/06 2014

0.2.1

0.2.1.0

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires

28/05 2014

0.2.0

0.2.0.0

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires

24/02 2014

0.1.0

0.1.0.0

Brings JavaScript-like functionality to your objects

  Sources   Download

The Development Requires