Advertisement
fruffl

ILLI\System\Object

Aug 20th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.02 KB | None | 0 0
  1. <?PHP
  2.     /**
  3.      * ILLI
  4.      *
  5.      * @category   ILLI_System
  6.      * @package    ILLI
  7.      * @link       http://illi.be
  8.      * @license    http://l.illi.be
  9.      * @copyright  ILLI Conference
  10.      */
  11.     NAMESPACE ILLI\System;
  12.     USE Serializable;
  13.  
  14.     /**
  15.      * ILLI Object
  16.      *
  17.      * @category   ILLI_System
  18.      * @package    ILLI
  19.      * @subpackage System
  20.      * @namespace  ILLI\System
  21.      * @link       http://illi.be
  22.      * @license    http://l.illi.be
  23.      * @copyright  ILLI Conference
  24.      * @since      2.0.1
  25.      * @version    3.0.1
  26.      */
  27.     CLASS Object IMPLEMENTS Serializable
  28.     {
  29.         USE tSplHashRegister
  30.         {
  31.             tSplHashRegister_getCode        as getHashCode;
  32.             tSplHashRegister_getInstances       as getSplInstances;
  33.             tSplHashRegister_getSiblings        as getSplSiblingInstances;
  34.             tSplHashRegister___register     as __registerSpl;
  35.             tSplHashRegister___unregister       as __unregisterSpl;
  36.         }
  37.        
  38.         USE tAdapter
  39.         {
  40.             tAdapter_registerTrigger        as adapterRegisterTrigger;
  41.             tAdapter_registerTriggerMethod      as adapterRegisterTriggerMethod;
  42.             tAdapter_registerTriggerStaticMethod    as adapterRegisterTriggerStaticMethod;
  43.             tAdapter_registerTriggerClosure     as adapterRegisterTriggerClosure;
  44.             tAdapter_unregisterTrigger      as adapterUnregisterTrigger;
  45.             tAdapter_callAlias          as adapterCallAlias;
  46.             tAdapter_triggerExists          as adapterTriggerExists;
  47.         }
  48.        
  49.         USE tObserver
  50.         {
  51.             tObserver_registerEvent         as observerRegisterEvent;
  52.             tObserver_registerEventMethod       as observerRegisterEventMethod;
  53.             tObserver_registerEventStaticMethod as observerRegisterEventStaticMethod;
  54.             tObserver_registerEventClosure      as observerRegisterEventClosure;
  55.             tObserver_unregisterEvent       as observerUnregisterEvent;
  56.             tObserver_notify            as observerNotify;
  57.             tObserver_eventExists           as observerEventExists;
  58.         }
  59.        
  60.         USE tFilter
  61.         {
  62.             tFilter_registerEvent           as filterRegisterEvent;
  63.             tFilter_registerEventMethod     as filterRegisterEventMethod;
  64.             tFilter_registerEventStaticMethod   as filterRegisterEventStaticMethod;
  65.             tFilter_registerEventClosure        as filterRegisterEventClosure;
  66.             tFilter_unregisterTrigger       as filterUnregisterEvent;
  67.             tFilter_triggerExists           as filterTriggerExists;
  68.             tFilter_applyFilter         as filterApply;
  69.         }
  70.        
  71.         USE tSerializable
  72.         {
  73.             tSerializable_serialize             as serialize;
  74.             tSerializable_unserialize           as unserialize;
  75.             tSerializable___sleep               as __sleep;
  76.             tSerializable___set_state           as __set_state;
  77.             tSerializable___registerSerializableProperty    as __serializableRegister;
  78.         }
  79.        
  80.         protected $__Collection = NULL;
  81.        
  82.         public function randomize($arg)
  83.         {
  84.             (TRUE === $this->adapterTriggerExists(__METHOD__))
  85.                 ? $this->adapterCallAlias(__METHOD__, $arg)
  86.                 : var_dump(__METHOD__.'->'.$arg);
  87.         }
  88.        
  89.         public function __set($index, $value)
  90.         {
  91.             $foo = $this->filterApply('args', __METHOD__, array('index' => $index, 'value' => $value));
  92.             $index = $foo['index'];
  93.             $value = $foo['value'];
  94.             $this->__Collection->offsetSet($index, $value);
  95.             $this->observerNotify(__METHOD__, $index, $value);
  96.         }
  97.        
  98.         public function __construct()
  99.         {
  100.             $this->__serializableRegister('__Collection');
  101.             $this->__registerSpl();
  102.             $this->__Collection = new Collection;
  103.             //$this->adapterRegisterTriggerStaticMethod('\ILLI\System\Object::randomize', 'ILLI\System\Foo::bar');
  104.             //$this->observerRegisterEventStaticMethod('foo', 'ILLI\System\Object::randomize');
  105.             //$this->observerNotify('foo', 'notify');
  106.             //$this->randomize('foobar');
  107.            
  108.             $this->filterRegisterEventMethod('args', __CLASS__.'::__set', 'ILLI\System\Foo::findex');
  109.             $this->filterRegisterEventMethod('args', __CLASS__.'::__set', 'ILLI\System\Foo::toUpper');
  110.            
  111.            
  112.            
  113.            
  114.            
  115.             //throw new \Exception('Test!');
  116.             /*
  117.             \ILLI\Boot\ErrorHandler::config
  118.             (
  119.                 array
  120.                 (
  121.                     array
  122.                     (
  123.                         //'code' => E_ALL | E_PARSE | E_STRICT | E_DEPRECATED | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
  124.                         //'type' => 'Exception',
  125.                         'handler' => function($info) use ($self) { $self->errors[] = $info; }
  126.                     )
  127.                 )
  128.             );
  129.             \ILLI\Boot\ErrorHandler::handle(new \Exception('Test!'));
  130.             */
  131.             /*
  132.             \ILLI\Boot\ErrorHandler::config
  133.             (
  134.                 array
  135.                 (
  136.                     array
  137.                     (
  138.                         //'code' => E_ALL | E_PARSE | E_STRICT | E_DEPRECATED | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
  139.                         //'type' => 'Exception',
  140.                         'handler' => function($info) use ($self) { $self->errors[] = $info; }
  141.                     )
  142.                 )
  143.             );
  144.            
  145.             \ILLI\Boot\ErrorHandler::handle(new \Exception('Test!'));
  146.             */
  147.            
  148.         }
  149.     }
  150.  
  151. // ...
  152.  
  153.     $foo = new \ILLI\System\UUID;
  154.     $foo->baz = 'bar';
  155.     var_dump(unserialize(serialize($foo)));
  156.  
  157. object(ILLI\System\UUID)#34 (12) {
  158.  ["__value":"ILLI\System\UUID":private]=>
  159.   string(0) ""
  160.   ["__Collection":protected]=>
  161.   object(ILLI\System\Collection)#47 (6) {
  162.    ["__data":"ILLI\System\Collection":private]=>
  163.     array(1) {
  164.       ["***ILLI\System\Foo::findex->baz***"]=>
  165.       string(3) "BAR"
  166.     }
  167.     ["__offsets":"ILLI\System\Collection":private]=>
  168.     array(1) {
  169.       [0]=>
  170.       string(34) "***ILLI\System\Foo::findex->baz***"
  171.     }
  172.     ["__indexes":"ILLI\System\Collection":private]=>
  173.     array(1) {
  174.       ["***ILLI\System\Foo::findex->baz***"]=>
  175.       int(0)
  176.     }
  177.     ["__iteratorIndex":"ILLI\System\Collection":private]=>
  178.     int(0)
  179.     ["__lastOffsetUpdate":"ILLI\System\Collection":private]=>
  180.     string(34) "***ILLI\System\Foo::findex->baz***"
  181.     ["__lastOffsetInsert":"ILLI\System\Collection":private]=>
  182.     NULL
  183.   }
  184.   ["__splHashRegisterAddress":"ILLI\System\Object":private]=>
  185.   string(32) "000000004247f66c00000000026382bc"
  186.   ["__adapterTracesEnabled":"ILLI\System\Object":private]=>
  187.   bool(false)
  188.   ["__adapterTraces":"ILLI\System\Object":private]=>
  189.   array(0) {
  190.   }
  191.   ["__adapters":protected]=>
  192.   array(0) {
  193.   }
  194.   ["__observerTracesEnabled":"ILLI\System\Object":private]=>
  195.   bool(false)
  196.   ["__observerTraces":"ILLI\System\Object":private]=>
  197.   array(0) {
  198.   }
  199.   ["__observers":protected]=>
  200.   array(0) {
  201.   }
  202.   ["__filterTracesEnabled":"ILLI\System\Object":private]=>
  203.   bool(false)
  204.   ["__filterTraces":"ILLI\System\Object":private]=>
  205.   array(0) {
  206.   }
  207.   ["__filters":protected]=>
  208.   array(1) {
  209.     ["ILLI\System\Object::__set"]=>
  210.     array(2) {
  211.       [0]=>
  212.       object(ILLI\System\FilterAlias)#48 (3) {
  213.        ["__event":"ILLI\System\FilterAlias":private]=>
  214.         string(4) "args"
  215.         ["__TRIGGER":"ILLI\System\FilterAlias":private]=>
  216.         object(ILLI\System\Method)#49 (3) {
  217.          ["__class":protected]=>
  218.           string(18) "ILLI\System\Object"
  219.           ["__function":protected]=>
  220.           string(5) "__set"
  221.           ["__method":protected]=>
  222.           string(25) "ILLI\System\Object::__set"
  223.         }
  224.         ["__FILTER":"ILLI\System\FilterAlias":private]=>
  225.         object(ILLI\System\InvokeMethod)#50 (1) {
  226.          ["__callable":protected]=>
  227.           object(ILLI\System\Method)#51 (3) {
  228.            ["__class":protected]=>
  229.             string(15) "ILLI\System\Foo"
  230.             ["__function":protected]=>
  231.             string(6) "findex"
  232.             ["__method":protected]=>
  233.             string(23) "ILLI\System\Foo::findex"
  234.           }
  235.         }
  236.       }
  237.       [1]=>
  238.       object(ILLI\System\FilterAlias)#52 (3) {
  239.        ["__event":"ILLI\System\FilterAlias":private]=>
  240.         string(4) "args"
  241.         ["__TRIGGER":"ILLI\System\FilterAlias":private]=>
  242.         object(ILLI\System\Method)#53 (3) {
  243.          ["__class":protected]=>
  244.           string(18) "ILLI\System\Object"
  245.           ["__function":protected]=>
  246.           string(5) "__set"
  247.           ["__method":protected]=>
  248.           string(25) "ILLI\System\Object::__set"
  249.         }
  250.         ["__FILTER":"ILLI\System\FilterAlias":private]=>
  251.         object(ILLI\System\InvokeMethod)#54 (1) {
  252.          ["__callable":protected]=>
  253.           object(ILLI\System\Method)#55 (3) {
  254.            ["__class":protected]=>
  255.             string(15) "ILLI\System\Foo"
  256.             ["__function":protected]=>
  257.             string(7) "toUpper"
  258.             ["__method":protected]=>
  259.             string(24) "ILLI\System\Foo::toUpper"
  260.           }
  261.         }
  262.       }
  263.     }
  264.   }
  265. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement