Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- /**
- * ILLI
- *
- * @category ILLI_System
- * @package ILLI
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- */
- NAMESPACE ILLI\System;
- USE ReflectionClass;
- USE IteratorAggregate;
- /**
- * ILLI Object
- *
- * singleton-support
- * <code>
- * <?PHP
- * $t1 = \ILLI\System\Rand::instanceGet(200);
- * var_dump($t1);
- * $t1->__destruct();
- * $t2 = \ILLI\System\Rand::instanceGet(50);
- * var_dump($t2);
- * $foo = new \ILLI\System\Rand(15);
- * var_dump($foo);
- * ?>
- * </code>
- *
- * @category ILLI_System
- * @package ILLI
- * @subpackage System
- * @namespace ILLI\System
- * @link http://illi.be
- * @license http://l.illi.be
- * @copyright ILLI Conference
- * @since 2.0.1
- * @version 3.0.1
- */
- CLASS Object EXTENDS System IMPLEMENTS IteratorAggregate,
- //iQueue
- iArrayList
- //iStack
- {
- USE tSplHashRegister
- {
- tSplHashRegister___register as private __splRegister;
- tSplHashRegister___unregister as private __splUnregister;
- tSplHashRegister_getCode as public splGetHashCode;
- tSplHashRegister_getInstances as public splGetInstances;
- tSplHashRegister_getSiblings as public splGetSiblingInstances;
- }
- USE tAdapter
- {
- tAdapter_registerTrigger as private adapterRegisterTrigger;
- tAdapter_unregisterTrigger as protected adapterUnregisterTrigger;
- tAdapter_callAlias as protected adapterCallAlias;
- tAdapter_triggerExists as protected adapterTriggerExists;
- tAdapter_registerTriggerMethod as public adapterRegisterTriggerMethod;
- tAdapter_registerTriggerStaticMethod as public adapterRegisterTriggerStaticMethod;
- tAdapter_registerTriggerClosure as public adapterRegisterTriggerClosure;
- }
- USE tObserver
- {
- tObserver_registerEvent as private observerRegisterEvent;
- tObserver_unregisterEvent as protected observerUnregisterEvent;
- tObserver_notify as protected observerNotify;
- tObserver_eventExists as protected observerEventExists;
- tObserver_registerEventMethod as public observerRegisterEventMethod;
- tObserver_registerEventStaticMethod as public observerRegisterEventStaticMethod;
- tObserver_registerEventClosure as public observerRegisterEventClosure;
- }
- USE tFilter
- {
- tFilter_registerEvent as private filterRegisterEvent;
- tFilter_unregisterTrigger as protected filterUnregisterEvent;
- tFilter_triggerExists as protected filterTriggerExists;
- tFilter_applyFilter as protected filterApply;
- tFilter_registerEventMethod as public filterRegisterEventMethod;
- tFilter_registerEventStaticMethod as public filterRegisterEventStaticMethod;
- tFilter_registerEventClosure as public filterRegisterEventClosure;
- }
- USE tVirtualMethod
- {
- tVirtualMethod_remove as protected virtualMethodRemove;
- tVirtualMethod_add as public virtualMethodAdd;
- tVirtualMethod_call as public virtualMethodCall;
- }
- USE tInstance
- {
- tInstance___unregister as private __instanceUnregister;
- tInstance_get as public instanceGet;
- tInstance_register as public instanceRegister;
- tInstance_getName as public instanceGetName;
- tInstance_exists as public instanceExists;
- tInstance_getNames as public instanceGetNames;
- }
- USE tStorage
- {
- tStorage___register as private __storageRegister;
- tStorage___unregister as private __storageUnregister;
- tStorage_get as private storageGet;
- tStorage_getIterator as public getIterator;
- tStorage_push as public storagePush;
- tStorage_pop as public storagePop;
- tStorage_peek as public storagePeek;
- }
- public function __set($index, $value)
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__, $index, $value);
- $filtered = $this->filterApply('args', __METHOD__, array('index' => $index, 'value' => $value));
- $index = $filtered['index'];
- $value = $filtered['value'];
- $this->storageGet()->getCollection()->offsetSet($index, $value);
- $this->observerNotify(__METHOD__, $index, $value);
- }
- public function push($value)
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__, $value);
- $filtered = $this->filterApply('args', __METHOD__, array('value' => $value));
- $value = $filtered['value'];
- $this->storagePush($value);
- $this->observerNotify(__METHOD__, $value);
- $value = $this->filterApply('return', __METHOD__, $value);
- return $this;
- }
- public function __get($index)
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__, $index);
- $filtered = $this->filterApply('args', __METHOD__, array('index' => $index));
- $index = $filtered['index'];
- $value = $this->storageGet()->getCollection()->offsetGet($index);
- $this->observerNotify(__METHOD__, $index, $value);
- $value = $this->filterApply('return', __METHOD__, $value);
- return $value;
- }
- public function pop()
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__);
- $value = $this->storagePop();
- $this->observerNotify(__METHOD__, $value);
- $value = $this->filterApply('return', __METHOD__, $value);
- return $value;
- }
- public function peek()
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__);
- $value = $this->storagePeek();
- $this->observerNotify(__METHOD__, $value);
- $value = $this->filterApply('return', __METHOD__, $value);
- return $value;
- }
- public function clear()
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__);
- $this->storageClear();
- $this->observerNotify(__METHOD__);
- return $this;
- }
- public function __call($name, array $args = array())
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__, $args);
- $filtered = $this->filterApply('args', __METHOD__, array('method' => $name, 'args' => $args));
- $name = $filtered['method'];
- $args = $filtered['args'];
- $value = $this->virtualMethodCall($name, $args);
- $this->observerNotify(__METHOD__, $name, $value, $args);
- $value = $this->filterApply('return', __METHOD__, $value);
- return $value;
- }
- public function __destruct()
- {
- $this->__splUnregister();
- $this->__instanceUnregister($this);
- $this->__storageUnregister();
- }
- public function __construct()
- {
- $this->__splRegister();
- switch(TRUE):
- case($this instanceOf iStack):
- $this->__storageRegister(new Stack(new Collection));
- break;
- case($this instanceOf iQueue):
- $this->__storageRegister(new Queue(new Collection));
- break;
- case($this instanceOf iArrayList):
- default:
- $this->__storageRegister(new ArrayList(new Collection));
- break;
- endswitch;
- }
- }
- $foo = new \ILLI\System\Object;
- /*
- $foo->virtualMethodAdd('myFunkyGetter', function($val) use ($foo)
- {
- return $foo->getCollection()->offsetGet($val);
- });
- */
- $foo
- ->virtualMethodAdd('mypush', function($val) use ($foo)
- {
- $val['value'] = 'mypush----'.$val['value'];
- return $val;
- })
- ->virtualMethodAdd('mypop', function($val) use ($foo)
- {
- $val = 'pop-----'.$val;
- return $val;
- })
- ->virtualMethodAdd('mypeek', function($val) use ($foo)
- {
- $val = 'peek----'.$val;
- return $val;
- })
- ->filterRegisterEventMethod('args', get_class($foo).'::push', get_class($foo).'::mypush')
- ->filterRegisterEventMethod('return', get_class($foo).'::pop', get_class($foo).'::mypop')
- ->filterRegisterEventMethod('return', get_class($foo).'::peek', get_class($foo).'::mypeek')
- ->push('the')
- ->push('quick')
- ->push('brown')
- ->push('fox')
- ->push('jumps')
- ->push('over')
- ->push('the')
- ->push('lazy')
- ->push('dog');
- foreach($foo as $baz) var_dump($baz);
- var_dump('======');
- foreach(['pop', 'pop', 'peek'] as $call) var_dump($foo->$call());
- var_dump('======');
- var_dump($foo);
- ?>
- string(13) "mypush----the"
- string(15) "mypush----quick"
- string(15) "mypush----brown"
- string(13) "mypush----fox"
- string(15) "mypush----jumps"
- string(14) "mypush----over"
- string(13) "mypush----the"
- string(14) "mypush----lazy"
- string(13) "mypush----dog"
- string(6) "======"
- string(21) "pop-----mypush----dog"
- string(22) "pop-----mypush----lazy"
- string(21) "peek----mypush----the"
- string(6) "======"
- object(ILLI\System\Object)#20 (12) {
- ["__tSplHashRegister_Address":"ILLI\System\Object":private]=>
- string(32) "00000000215f9259000000005d5519e9"
- ["__tAdapter_tracesEnabled":"ILLI\System\Object":private]=>
- bool(false)
- ["__tAdapter_traces":"ILLI\System\Object":private]=>
- array(0) {
- }
- ["__tAdapter_hook":protected]=>
- array(0) {
- }
- ["__tObserver_tracesEnabled":"ILLI\System\Object":private]=>
- bool(false)
- ["__tObserver_traces":"ILLI\System\Object":private]=>
- array(0) {
- }
- ["__tObserver_hook":protected]=>
- array(0) {
- }
- ["__tFilter_tracesEnabled":"ILLI\System\Object":private]=>
- bool(false)
- ["__tFilter_traces":"ILLI\System\Object":private]=>
- array(0) {
- }
- ["__tFilter_hook":protected]=>
- array(3) {
- ["ILLI\System\Object::push"]=>
- array(1) {
- [0]=>
- object(ILLI\System\ConcreteFilter)#35 (3) {
- ["__event":"ILLI\System\ConcreteFilter":private]=>
- string(4) "args"
- ["__Trigger":"ILLI\System\ConcreteFilter":private]=>
- object(ILLI\System\Method)#37 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(4) "push"
- ["__method":protected]=>
- string(24) "ILLI\System\Object::push"
- }
- ["__Callable":protected]=>
- object(ILLI\System\InvokeMethod)#39 (2) {
- ["__Instance":"ILLI\System\InvokeMethod":private]=>
- *RECURSION*
- ["__Callable":protected]=>
- object(ILLI\System\Method)#40 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(6) "mypush"
- ["__method":protected]=>
- string(26) "ILLI\System\Object::mypush"
- }
- }
- }
- }
- ["ILLI\System\Object::pop"]=>
- array(1) {
- [0]=>
- object(ILLI\System\ConcreteFilter)#41 (3) {
- ["__event":"ILLI\System\ConcreteFilter":private]=>
- string(6) "return"
- ["__Trigger":"ILLI\System\ConcreteFilter":private]=>
- object(ILLI\System\Method)#42 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(3) "pop"
- ["__method":protected]=>
- string(23) "ILLI\System\Object::pop"
- }
- ["__Callable":protected]=>
- object(ILLI\System\InvokeMethod)#43 (2) {
- ["__Instance":"ILLI\System\InvokeMethod":private]=>
- *RECURSION*
- ["__Callable":protected]=>
- object(ILLI\System\Method)#44 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(5) "mypop"
- ["__method":protected]=>
- string(25) "ILLI\System\Object::mypop"
- }
- }
- }
- }
- ["ILLI\System\Object::peek"]=>
- array(1) {
- [0]=>
- object(ILLI\System\ConcreteFilter)#45 (3) {
- ["__event":"ILLI\System\ConcreteFilter":private]=>
- string(6) "return"
- ["__Trigger":"ILLI\System\ConcreteFilter":private]=>
- object(ILLI\System\Method)#46 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(4) "peek"
- ["__method":protected]=>
- string(24) "ILLI\System\Object::peek"
- }
- ["__Callable":protected]=>
- object(ILLI\System\InvokeMethod)#47 (2) {
- ["__Instance":"ILLI\System\InvokeMethod":private]=>
- *RECURSION*
- ["__Callable":protected]=>
- object(ILLI\System\Method)#48 (3) {
- ["__class":protected]=>
- string(18) "ILLI\System\Object"
- ["__function":protected]=>
- string(6) "mypeek"
- ["__method":protected]=>
- string(26) "ILLI\System\Object::mypeek"
- }
- }
- }
- }
- }
- ["__tVirtualMethod_hook":protected]=>
- array(1) {
- ["ILLI\System\Object"]=>
- array(3) {
- ["mypush"]=>
- object(ILLI\System\InvokeClosure)#28 (1) {
- ["__Callable":protected]=>
- object(Closure)#25 (2) {
- ["static"]=>
- array(1) {
- ["foo"]=>
- *RECURSION*
- }
- ["parameter"]=>
- array(1) {
- ["$val"]=>
- string(10) "<required>"
- }
- }
- }
- ["mypop"]=>
- object(ILLI\System\InvokeClosure)#30 (1) {
- ["__Callable":protected]=>
- object(Closure)#29 (2) {
- ["static"]=>
- array(1) {
- ["foo"]=>
- *RECURSION*
- }
- ["parameter"]=>
- array(1) {
- ["$val"]=>
- string(10) "<required>"
- }
- }
- }
- ["mypeek"]=>
- object(ILLI\System\InvokeClosure)#32 (1) {
- ["__Callable":protected]=>
- object(Closure)#31 (2) {
- ["static"]=>
- array(1) {
- ["foo"]=>
- *RECURSION*
- }
- ["parameter"]=>
- array(1) {
- ["$val"]=>
- string(10) "<required>"
- }
- }
- }
- }
- }
- ["__tStorage_Data":"ILLI\System\Object":private]=>
- object(ILLI\System\ArrayList)#22 (1) {
- ["__Collection":protected]=>
- object(ILLI\System\Collection)#24 (6) {
- ["__data":"ILLI\System\Collection":private]=>
- array(7) {
- [0]=>
- string(13) "mypush----the"
- [1]=>
- string(15) "mypush----quick"
- [2]=>
- string(15) "mypush----brown"
- [3]=>
- string(13) "mypush----fox"
- [4]=>
- string(15) "mypush----jumps"
- [5]=>
- string(14) "mypush----over"
- [6]=>
- string(13) "mypush----the"
- }
- ["__offsets":"ILLI\System\Collection":private]=>
- array(7) {
- [0]=>
- int(0)
- [1]=>
- int(1)
- [2]=>
- int(2)
- [3]=>
- int(3)
- [4]=>
- int(4)
- [5]=>
- int(5)
- [6]=>
- int(6)
- }
- ["__indexes":"ILLI\System\Collection":private]=>
- array(7) {
- [0]=>
- int(0)
- [1]=>
- int(1)
- [2]=>
- int(2)
- [3]=>
- int(3)
- [4]=>
- int(4)
- [5]=>
- int(5)
- [6]=>
- int(6)
- }
- ["__iteratorIndex":"ILLI\System\Collection":private]=>
- int(9)
- ["__lastOffsetUpdate":"ILLI\System\Collection":private]=>
- NULL
- ["__lastOffsetInsert":"ILLI\System\Collection":private]=>
- NULL
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement