PHP
JQuery Style PHP Closure in version 5.3
Submitted by jimthunderbird on Wed, 03/03/2010 - 05:36.
#!/usr/bin/php
<?php
class Document {
private $body_closure = NULL;
protected $reflection = NULL;
public function __construct($function)
{
if ( ! $function instanceOf Closure)
throw new InvalidArgumentException();
$this->body_closure = $function;
$this->reflection = new ReflectionFunction($function);
}
public function __invoke()
{
$args = func_get_args();
return $this->reflection->invokeArgs($args);
}
public function getClosure()
{
The object oriented javascript style php class definition for PHP 5.3
Submitted by jimthunderbird on Tue, 03/02/2010 - 10:21.#!/usr/bin/php
<?php
/**
* Mootools-style php scripting at version 5.3
* Hash-based class definition, avoiding namespaces
*/
#################################################################################
# Start Core
#################################################################################
class P{
private static $map;
private static $current_class;
public function mclass($class_name, $class_hash){
$class_name = self::clean_class_name($class_name);
self::$map["$class_name"] = $class_hash;
#a hook after the class has been made