Advertisement
fruffl

T_Boot

Feb 3rd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <?PHP
  2.     NAMESPACE ILLI\Core\Proto;
  3.     USE ILLI\Core\Exception;
  4.     USE ILLI\Core\Proto\I_Boot;
  5.    
  6.     TRAIT T_Boot
  7.     {
  8.         private static $__Core_Proto_T_Boot_Static = [];
  9.        
  10.         protected function Core_Proto_T_Boot_handleLookup($propertyName, $lookupClassName, array $classCache)
  11.         {
  12.             if(FALSE === isset($classCache[$propertyName]))
  13.                 return
  14.                 [
  15.                     I_Boot::EXISTS      => isset($this->$propertyName) || property_exists($this, $propertyName),
  16.                     I_Boot::DEFINED     => $lookupClassName,
  17.                     I_Boot::REDEFINED   => FALSE,
  18.                     I_Boot::INSPECT     => $lookupClassName.'::$'.$propertyName
  19.                 ];
  20.                
  21.             $r = $classCache[$propertyName];
  22.            
  23.             if(FALSE === $r[I_Boot::REDEFINED])
  24.             {
  25.                 $r[I_Boot::REDEFINED]   = $r[I_Boot::DEFINED];
  26.                 $r[I_Boot::INSPECT] = $r[I_Boot::DEFINED].'::$'.$propertyName;
  27.             }
  28.            
  29.             $r[I_Boot::DEFINED] = $lookupClassName;
  30.            
  31.             return $r;
  32.         }
  33.        
  34.         protected function Core_Proto_T_Boot_emit(array $__lookupTable = [])
  35.         {
  36.             array_walk($__lookupTable, function($t, $p)
  37.             {
  38.                 if(is_integer($p))
  39.                 {
  40.                     $p = $t;
  41.                     $t = [];
  42.                 }
  43.                
  44.                 $l = get_called_class();
  45.                 $s = &self::$__Core_Proto_T_Boot_Static[$l][$p];
  46.                
  47.                 if(isset($s))
  48.                     goto _init;
  49.                    
  50.                 $c = [];
  51.                
  52.                 do
  53.                 {
  54.                     if(FALSE === isset($l::$$p))
  55.                         continue;
  56.                        
  57.                     $c = is_callable($h = isset($t[I_Boot::ON_LOOKUP]) ? $t[I_Boot::ON_LOOKUP] : NULL)
  58.                         ? $h($c, $l, $l::$$p)
  59.                         : $l::$$p;
  60.                 }
  61.                 while($l = get_parent_class($l));
  62.                
  63.                 $s = is_callable($h = isset($t[I_Boot::ON_COMPLETE]) ? $t[I_Boot::ON_COMPLETE] : NULL)
  64.                     ? $h($c)
  65.                     : $c;
  66.                
  67.                 _init:
  68.                
  69.                 if(is_callable($h = isset($t[I_Boot::ON_INIT]) ? $t[I_Boot::ON_INIT] : NULL))
  70.                     $h($s);
  71.             });
  72.            
  73.             return $this;
  74.         }
  75.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement