/** * Register the internal type definitions used by this TypeHound. */ protected static function registerDefinitions() { static::$definitions = [new CompoundTypes(), new ScalarTypes(), new SpecialTypes()]; }
/** * Clear definitions variable. */ protected static final function clearDefinitions() { static::$definitions = []; }
/** * Load JSON definitions from file (via lazy loading from get()) * * @todo add caching */ protected static function load() { static::$definitions = array(); $cache_id = static::CACHE_KEY . static::FILE; if (Util\Configuration::read('devmode') == FALSE && extension_loaded('apc') && apc_exists($cache_id) && time() - filemtime(__DIR__ . '/' . static::FILE) > Util\Configuration::read('cache.ttl')) { static::$definitions = apc_fetch($cache_id); } else { // expensive - cache results $json = Util\JSON::decode(file_get_contents(__DIR__ . '/' . static::FILE)); foreach ($json as $property) { static::$definitions[$property->name] = new static($property); } if (extension_loaded('apc')) { apc_store($cache_id, static::$definitions, Util\Configuration::read('cache.ttl')); } } }
/** * Load JSON definitions from file (via lazy loading from get()) * * @todo add caching */ protected static function load() { static::$definitions = array(); $json = Util\JSON::decode(file_get_contents(VZ_DIR . static::FILE)); foreach ($json as $property) { static::$definitions[$property->name] = new static($property); } }
/** * Flush the registry */ public static function flush() { static::$definitions = []; }