fruffl icon

GC ADT in PHP

fruffl | 02/25/13 03:25:45 PM UTC | 0 ⭐ | 252 👁️ | Never ⏰ | []
PHP |

26.29 KB

|

None

|

0 👍

/

0 👎

<?PHP
    NAMESPACE ILLI\Core\Std\Def;
    USE ILLI\Core\Std\Def\__const_ADTClass;
    USE ILLI\Core\Std\Def\__const_Type;
    USE ILLI\Core\Std\Def\ADTInstance;
    USE ILLI\Core\Std\Def\ADT\ComponentInitializationException;
    USE ILLI\Core\Std\Def\ADT\ComponentMethodCallException;
    USE ILLI\Core\Std\Exception\ArgumentExpectedException;
    USE ILLI\Core\Std\Exception\ArgumentLengthZeroException;
    USE ILLI\Core\Std\Exception\ArgumentInUseException;
    USE ILLI\Core\Std\Exception\NotSupportedException;
    USE ILLI\Core\Std\Invoke;
    USE ILLI\Core\Std\Spl\Fsb;
    USE ILLI\Core\Util\Spl;
    
    CLASS ADT EXTENDS \ILLI\Core\Std\Spl\Fsb
    {
        /**
         * Instantiate a new Abstract Data Type Definition.
         *
         * ADT is the definition as is and doesn't store data.
         *
         * A definition can be a base-type or a collection of base-types:
         *  <long> forbids all except integers.
         *  <string|array> forbids all except strings and arrays.
         *
         * define ADT:
         *
         * :offset<long>
         *  zero-based index
         *
         * :gcType<string>
         *  a valid __const_Type
         *
         * @param   array $__defineTypes [{:offset} => {:gcType}]
         * @catchable   ILLI\Core\Std\Def\ADT\ComponentInitializationException
         * @fires   ILLI\Core\Std\Exception\ArgumentLengthZeroException when definition is an empty array
         * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_CTOR_E_DEFINITION_LENGTH_ZERO
         * @see     ::validate()
         * @see     ::__destruct()
         * @see     ILLI\Core\Std\Def\__const_Type
         * @see     ILLI\Core\Std\Def\ADTInstance
         */
        public function __construct(array $__defineTypes = [])
        {
            $c = get_called_class();
            $e = $c.'\ComponentMethodCallException';
            
            try
            {
                if([] === $__defineTypes)
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException(new ArgumentLengthZeroException, ['method' => __METHOD__], ComponentMethodCallException::ERROR_M_CTOR_E_DEFINITION_LENGTH_ZERO)
                        : new $e(new ArgumentLengthZeroException, ['method' => __METHOD__], $e::ERROR_M_CTOR_E_DEFINITION_LENGTH_ZERO);
                
                $n = $this->createHashAddr($__defineTypes);
                $t = &self::$__gc[$n];      
                
                parent::setSize(1);
                parent::offsetSet(0, $n);
                
                if(FALSE === isset($t))
                    $t = Fsb::fromArray($this->parseDef($__defineTypes));
            }
            catch(\Exception $E)
            {
                $e = $c.'\ComponentInitializationException';
                throw ($c === __CLASS__ || FALSE === class_exists($e))
                    ? new ComponentInitializationException($E, ['class' => get_called_class()])
                    : new $e($E, ['class' => get_called_class()]);
            }
        }
        
        /**
         * value validation
         *
         * The type of given value equals with one of the registered gc-types.
         *
         * @param   mixed $__value
         * @return  boolean
         * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
         * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_VALIDATE
         * @see     ILLI\Core\Std\Def\__const_Type
         */
        public function validate($__value)
        {
            try
            {
                $v = &$__value;
                $t = getType($v);
                
                foreach($this->getGC() as $h)
                {
                    if($t === $h
                    ||($t === __const_Type::SPL_OBJECT && (class_exists($h) || interface_exists($h)) && (is_subclass_of($v, $h) || $v instanceOf $h)))
                        return TRUE;
                }
                
                return FALSE;
            }
            catch(\Exception $E)
            {
                $c = get_called_class();
                $e = $c.'\ComponentMethodCallException';
                throw ($c === __CLASS__ || FALSE === class_exists($e))
                    ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_VALIDATE, ['method' => __METHOD__])
                    : new $e($E, $e::ERROR_M_VALIDATE, ['method' => __METHOD__]);
            }
        }
        
        #:define:
            /**
             * ADT class-mapping
             *
             * :gcType<string>
             *  a valid __const_Type
             *
             * :adtClass<string>
             *  a valid __const_ADTClass
             *
             * @var     array [{:gcType} => {:adtClass}]
             * @see     ::define()
             * @see     ILLI\Core\Std\Def\__const_ADTClass
             * @see     ILLI\Core\Std\Def\__const_Type
             * @note    ILLI\Core\Std\Def\__const_ADTClass::SPL_INSTANCE will be created by undefined type-requests in ::define()
             */
            private static $__def = 
            [
                __const_Type::SPL_ARRAY         => __const_ADTClass::SPL_ARRAY,
                __const_Type::SPL_BOOLEAN       => __const_ADTClass::SPL_BOOLEAN,
                __const_Type::SPL_CALLABLE      => __const_ADTClass::SPL_CALLABLE,
                __const_Type::SPL_CLASS         => __const_ADTClass::SPL_CLASS,
                __const_Type::SPL_CLOSURE       => __const_ADTClass::SPL_CLOSURE,
                __const_Type::SPL_DIRECTORY     => __const_ADTClass::SPL_DIRECTORY,
                __const_Type::SPL_DOUBLE        => __const_ADTClass::SPL_DOUBLE,
                __const_Type::SPL_FILE          => __const_ADTClass::SPL_FILE,
                __const_Type::SPL_FLOAT         => __const_ADTClass::SPL_DOUBLE,
                __const_Type::SPL_FUNCTION      => __const_ADTClass::SPL_FUNCTION,
                __const_Type::SPL_INTERFACE     => __const_ADTClass::SPL_INTERFACE,
                __const_Type::SPL_INTEGER       => __const_ADTClass::SPL_LONG,
                __const_Type::SPL_LONG          => __const_ADTClass::SPL_LONG,
                __const_Type::SPL_METHOD        => __const_ADTClass::SPL_METHOD,
                __const_Type::SPL_NULL          => __const_ADTClass::SPL_NULL,
                __const_Type::SPL_OBJECT        => __const_ADTClass::SPL_OBJECT,
                __const_Type::SPL_RESOURCE      => __const_ADTClass::SPL_RESOURCE,
                __const_Type::SPL_STRING        => __const_ADTClass::SPL_STRING,
                __const_Type::SPL_TRAIT         => __const_ADTClass::SPL_TRAIT
            ];
            
            /**
             * create ADT from __const_Type
             *
             * :rOffset<long>
             *  offset in result-array
             *
             * :gcOffset<long>
             *  zero-based index
             *
             * :gcType<string>
             *   a valid __const_Type or class-/interface-name
             *
             * @param   string  $__type     {:gcType}
             * @param   array   $__type     [{:rOffset} => {:gcType}]
             * @param   array   $__type     [{:rOffset} => [{:gcOffset} => {:gcType}]]
             * @return  ILLI\Core\Std\Def\Type
             * @see     ::$__def
             * @see     ILLI\Core\Std\Def\ADT
             * @see     ILLI\Core\Std\Def\ADTInstance
             * @note    unlisted types: interpreting {:gcType} as class/interface and define the abstract-data-type as ADTInstance
             */
            final public static function define($__type)
            {
                if(!is_string($__type))
                {
                    if(is_array($__type))
                    {
                        $r = [];
                        
                        foreach($__type as $k => $v)
                            $r[$k] = self::define($v);
                        
                        return $r;
                    }
                    
                    throw new ArgumentExpectedException([
                        'target'    => __METHOD__,
                        'expected'  => 'string ILLI\Core\Std\Def\__const_Type::SPL*|string className|array [className:1, …, className:N]',
                        'detected'  => getType($v = $__type),
                        'value'     => is_object($v) ? get_class($v) : (is_scalar($v) ? $v : NULL)
                    ]);
                }
                
                $n = &self::$__def[$__type];
                $a = func_get_args();
                
                if(FALSE === isset($n))
                {
                    $a[0] = (array) $a[0];
                    #+ instance-based ADT: ADTInstance<instanceOf myClass>
                    #+ allow definition of ADT as subADT (ADT-classes are not listed as array-keys in ::$__def): ADTInstance<instanceOf ADT*>
                    return Invoke::emitClass('ILLI\Core\Std\Def\ADTInstance', $a);
                }
                
                array_shift($a);
                
                #+ default ADT: ADTArray, ADTBoolean, ..., ADT*
                return Invoke::emitClass($n, $a);
            }
        #::
        
        #:gc:
            /**
             * ADT definition gc
             *
             * :hashAddr<string>
             *  absolute ADT:
             *      instance of get_called_class(): ILLI\Core\Std\Def\ADT*
             *  anonymous ADT:
             *      instance of __CLASS__:      ILLI\Core\Std\Def\ADT<hash>
             *
             * :adtDef<ILLI\Core\Std\Spl\Fsb>
             *  collection of defined __const_Type(s)
             *
             * @var     array [{:hashAddr} => {:adtDef}]
             * @note    anonymous ADT: temporary gc; absolute ADT: permanent gc
             * @note    gc[{:hashAddr}] is traversable
             * @see     :gc:ILLI\Core\Std\Spl\Fsb:
             */
            private static $__gc = [];
        
            /**
             * get gc hash address
             *
             * @return  string
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_GET_NAME
             * @see     ::$__gc
             */
            final public function getName()
            {
                try
                {
                    return parent::offsetGet(0);
                }
                catch(\Exception $E)
                {
                    $c = get_called_class();
                    $e = $c.'\ComponentMethodCallException';
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_GET_NAME, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_M_GET_NAME, ['method' => __METHOD__]);
                }
            }
        
            /**
             * get ADT-gc
             *
             * @return  ILLI\Core\Std\Spl\Fsb
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_GET_GC
             * @see     ::$__gc
             */
            final public function getGC()
            {
                try
                {
                    return self::$__gc[$this->getName()];
                }
                catch(\Exception $E)
                {
                    $c = get_called_class();
                    $e = $c.'\ComponentMethodCallException';
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_GET_GC, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_M_GET_GC, ['method' => __METHOD__]);
                }
            }
            
            /**
             * join registered gc-type(s)
             *
             * @return  ILLI\Core\Std\Spl\Fsb
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_TO_STRING
             * @see     ::$__gc
             * @see     ILLI\Core\Std\Def\__const_Type
             */
            final public function toString()
            {
                try
                {
                    return implode('|', $this->getGC()->toArray());
                }
                catch(\Exception $E)
                {
                    $c = get_called_class();
                    $e = $c.'\ComponentMethodCallException';
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_TO_STRING, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_M_TO_STRING, ['method' => __METHOD__]);
                }
            }
        
            /**
             * validate typedef request
             *
             * :offset<long>
             *  zero-based index
             *
             * :gcType<string>
             *  a valid __const_Type
             *
             * @param   array $__defineTypes [{:offset} => {:gcType}]
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @fires   ILLI\Core\Std\Exception\ArgumentExpectedException when {:gcType} is not of type string
             * @fires   ILLI\Core\Std\Exception\ArgumentLengthZeroException when result-array is empty
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_PARSE_DEF_E_EXPECTED_STRING
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_PARSE_DEF_E_RESULT_LENGTH_ZERO
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_PARSE_DEF
             */
            final protected function parseDef(array $__defineTypes)
            {
                $c = get_called_class();
                $e = $c.'\ComponentMethodCallException';
                
                try
                {
                    $r = [];
                    
                    foreach($__defineTypes as $k => $v)
                    {
                        if(TRUE === is_string($v))
                        {
                            $r[$k] = $v;
                            continue;
                        }
                        
                        $E = new ArgumentExpectedException([
                            'target'    => $this->getName().'['.$k.']',
                            'expected'  => 'string', 
                            'detected'  => $t = getType($v),
                            'value'     => is_object($v) ? get_class($v) : (is_scalar($v) ? $v : NULL)
                        ]);
                        
                        $a =
                        [
                            'offset'    => $k,
                            'class'     => get_called_class()
                        ];
                        
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, $a, ComponentMethodCallException::ERROR_M_PARSE_DEF_E_EXPECTED_STRING)
                            : new $e($E, $a, $e::ERROR_M_PARSE_DEF_E_EXPECTED_STRING);
                            
                    }
                    
                    if([] !== $r)
                        return $r;
                    
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException(new ArgumentLengthZeroException, ['method' => __METHOD__], ComponentMethodCallException::ERROR_M_PARSE_DEF_E_RESULT_LENGTH_ZERO)
                        : new $e(new ArgumentLengthZeroException, ['method' => __METHOD__], $e::ERROR_M_PARSE_DEF_E_RESULT_LENGTH_ZERO);
                }
                catch(ComponentMethodCallException $E)
                {
                    throw $E;
                }
                catch(\Exception $E)
                {
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_PARSE_DEF, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_M_PARSE_DEF, ['method' => __METHOD__]);
                }
            }
        
            /**
             * Destroy anonymous ATD definitions
             *
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_DTOR
             * @void
             */
            public function __destruct()
            {
                try
                {
                    if(($c = get_called_class()) === __CLASS__)
                        unset(self::$__gc[$this->getName()]);
                }
                catch(\Exception $E)
                {
                    $c = get_called_class();
                    $e = $c.'\ComponentMethodCallException';
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_DTOR, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_DTOR, ['method' => __METHOD__]);
                }
            }
        
            /**
             * generate gc-hash-address from called-class or from spl_object_hash
             *
             * :offset<long>
             *  zero-based index
             *
             * :gcType<string>
             *  a valid __const_Type
             *
             * @param   array $__defineTypes [{:offset} => {:gcType}]
             * @return  string
             * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
             * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_CREATE_HASH_ADDR
             * @see     ::$__gc
             */
            protected function createHashAddr(array $__defineTypes = [])
            {
                try
                {
                    #~ performanced ADT: cache request by called-class; otherwise by hash
                    return ($c = get_called_class()) === __CLASS__ ? Spl::nameWithHash($c, $this) : $c;
                }
                catch(\Exception $E)
                {
                    $c = get_called_class();
                    $e = $c.'\ComponentMethodCallException';
                    throw ($c === __CLASS__ || FALSE === class_exists($e))
                        ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_CREATE_HASH_ADDR, ['method' => __METHOD__])
                        : new $e($E, $e::ERROR_M_CREATE_HASH_ADDR, ['method' => __METHOD__]);
                }
            }
            
            #:ILLI\Core\Std\Spl\Fsb:
                #+ forward Fsb::*() to ::$__gc::*()
            
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_GET_SIZE
                 */
                final public function getSize()
                {
                    try
                    {
                        return $this->getGC()->getSize();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_GET_SIZE, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_GET_SIZE, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_OFFSET_EXISTS
                 */
                final public function offsetExists($__offset)
                {
                    try
                    {
                        return $this->getGC()->offsetExists($__offset);
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_OFFSET_EXISTS, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_OFFSET_EXISTS, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_OFFSET_GET
                 */
                final public function offsetGet($__offset)
                {
                    try
                    {
                        return $this->getGC()->offsetGet($__offset);
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_OFFSET_GET, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_OFFSET_GET, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_COUNT
                 */
                final public function count()
                {
                    try
                    {
                        return $this->getGC()->count();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_COUNT, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_COUNT, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_CURRENT
                 */
                final public function current()
                {
                    try
                    {
                        return $this->getGC()->current();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_CURRENT, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_CURRENT, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_KEY
                 */
                final public function key()
                {
                    try
                    {
                        return $this->getGC()->key();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_KEY, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_KEY, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_NEXT
                 */
                final public function next()
                {
                    try
                    {
                        return $this->getGC()->next();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_NEXT, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_NEXT, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_REWIND
                 */
                final public function rewind()
                {
                    try
                    {
                        return $this->getGC()->rewind();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_REWIND, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_REWIND, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_VALID
                 */
                final public function valid()
                {
                    try
                    {
                        return $this->getGC()->valid();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_VALID, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_VALID, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_END
                 */
                final public function end()
                {
                    try
                    {
                        return $this->getGC()->end();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_END, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_END, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_KEYS
                 */
                final public function keys()
                {
                    try
                    {
                        return $this->getGC()->keys();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_KEYS, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_KEYS, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_PREV
                 */
                final public function prev()
                {
                    try
                    {
                        return $this->getGC()->prev();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_PREV, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_PREV, ['method' => __METHOD__]);
                    }
                }
                
                /**
                 * @return  integer
                 * @catchable   ILLI\Core\Std\Def\ADT\ComponentMethodCallException
                 * @throws  ILLI\Core\Std\Def\ADT\ComponentMethodCallException::ERROR_M_VALUES
                 */
                final public function values()
                {
                    try
                    {
                        return $this->getGC()->values();
                    }
                    catch(\Exception $E)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_VALUES, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_VALUES, ['method' => __METHOD__]);
                    }
                }
            
                #:NotSupported:
                    #! disable Fsb element modifiers
                    
                    /**
                     * @notSupported
                     * @throws  ILLI\Core\Std\Exception\NotSupportedException
                     */
                    final public function setSize($__size)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        $E = new NotSupportedException(['target' => __METHOD__]);
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_SET_SIZE, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_SET_SIZE, ['method' => __METHOD__]);
                    }
                    
                    /**
                     * @notSupported
                     * @throws  ILLI\Core\Std\Exception\NotSupportedException
                     */
                    final public function offsetSet($__offset, $__value)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        $E = new NotSupportedException(['target' => __METHOD__]);
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_OFFSET_SET, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_OFFSET_SET, ['method' => __METHOD__]);
                    }
                    
                    /**
                     * @notSupported
                     * @throws  ILLI\Core\Std\Exception\NotSupportedException
                     */
                    final public function offsetUnset($__offset)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        $E = new NotSupportedException(['target' => __METHOD__]);
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_OFFSET_UNSET, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_OFFSET_UNSET, ['method' => __METHOD__]);
                    }
                    
                    /**
                     * @notSupported
                     * @throws  ILLI\Core\Std\Exception\NotSupportedException
                     */
                    final public static function fromArray($__array, $__saveIndexes = TRUE)
                    {
                        $c = get_called_class();
                        $e = $c.'\ComponentMethodCallException';
                        $E = new NotSupportedException(['target' => __METHOD__]);
                        throw ($c === __CLASS__ || FALSE === class_exists($e))
                            ? new ComponentMethodCallException($E, ComponentMethodCallException::ERROR_M_FROM_ARRAY, ['method' => __METHOD__])
                            : new $e($E, $e::ERROR_M_FROM_ARRAY, ['method' => __METHOD__]);
                    }
                #::
            #::
        #::
        
        #:deprecated:
            /**
             * @deprecated
             */
            final protected function mergeTypes(array $__definedTypes, array $__defineTypes)
            {
                    throw new NotSupportedException([
                        'target' => __METHOD__
                    ]);
                $a = func_get_args();
                $r = [];
                
                foreach($a as $t)
                {
                    foreach($t as $k => $v)
                    {
                        if(FALSE === is_integer($k))
                            throw new ArgumentExpectedException([
                                'target'    => get_called_class().'['.$k.']',
                                'expected'  => 'integer',
                                'detected'  => $t = getType($v),
                                'value'     => is_object($v) ? get_class($v) : (is_scalar($v) ? $v : NULL)
                            ]);
                            
                        if(isset($r[$k]))
                            throw new ArgumentInUseException([
                                'target' => get_called_class().'['.$k.']'
                            ]);
                            
                        $r[$k] = $v;
                    }
                }
                
                return $r;
            }
        #::
    }

Comments