library closureaccess
Brings JavaScript-like functionality to your objects
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
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
- Accessing public methods as properties e.g. $obj->methodName (return Closure)
- Closures added to objects can be executed like public methods e.g. $obj->closureProp()
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();
dev-master
9999999-dev
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires
0.3.1
0.3.1.0
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires
0.3.0
0.3.0.0
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires
0.2.1
0.2.1.0
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires
0.2.0
0.2.0.0
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires
0.1.0
0.1.0.0
Brings JavaScript-like functionality to your objects
Sources
Download
The Development Requires