Get Contant Values By Prefix

@param string $className
@param string $prefix

@return array
196454
public static function getConstantValuesByPrefix($className, $prefix)
    {
        $prefixLength = strlen($prefix);
        $result = [];

        $reflection = new \ReflectionClass($className);
        foreach ($reflection->getConstants() as $constKey => $constValue) {
            if ($prefix === substr($constKey, 0, $prefixLength)) {
                $result[] = $constValue;
            }
        }

        return $result;
    }
1180480
public function getFieldsByClass($className)
    {
        $result = [];

        foreach ($this->fields as $field) {
            if ($field instanceof $className ||
                get_class($field) == $className ||
                (new \ReflectionClass($field))->getShortName() == $className
            ) {
                $result[] = $field;
            }
        }

        return $result;
    }
541687
public function getClassTagValues($className, $tag)
    {
        if (!isset($this->reflectedClassNames[$className])) {
            $this->reflectClass($className);
        }
        if (!isset($this->classTagsValues[$className])) {
            return [];
        }
        return isset($this->classTagsValues[$className][$tag]) ? $this->classTagsValues[$className][$tag] : [];
    }
24441
public function get(string $className): array
    {
        if ($this->has($className) === false) {
            if (array_key_exists($className, $this->ambiguousMap) === true) {
                throw new AmbiguousSettingsException($className);
            }
            throw new NotRegisteredSettingsException($className);
        }

        $index = $this->settingsMap[$className];
        $data  = $this->settingsData[$index];

        return $data;
    }
31254
protected function getPropertyBuilder($prefix)
    {
        $build = function ($value, $key, $sub = null) use (&$prefix, &$build) {
            $sub = ($sub ? $sub : $prefix);

            if (!is_numeric($key)) {
                $sub .= static::SEP_MAJOR . $this->fixString($key);
            }

            if (is_array($value)) {
                return array_map(
                    $build,
                    $value,
                    array_keys($value),
                    array_fill(0, count($value), $sub)
                );
            }

            $sep = (
                $prefix === $sub
                ? static::SEP_MINOR
                : str_repeat(static::SEP_MAJOR, static::SEP_MULTI)
            );

            return $sub . $sep . $this->fixString($value);
        };

        return $build;
    }
160798
public function getHttpConstantsFromConfigs($configs = array(), $prefix)
    {
        $arr = array();
        if ($prefix != null && is_array($configs)) {
            foreach ($configs as $k => $v) {
                // Check if it startsWith
                if (substr($k, 0, strlen($prefix)) === $prefix) {
                    $newKey = ltrim($k, $prefix);
                    if (defined($newKey)) {
                        $arr[constant($newKey)] = $v;
                    }
                }
            }
        }
        return $arr;
    }
1319227
public function get($name = '', $prefix = null) {
        $prefix = !is_null($prefix) ? $prefix : $this->prefix;
        if ('' == $name) {
            // 获取全部的session
            $value = $prefix ? (!empty($_SESSION[$prefix]) ? $_SESSION[$prefix] : []) : $_SESSION;
        }
        elseif ($prefix) {
            // 获取session
            if (strpos($name, '.')) {
                list($name1, $name2) = explode('.', $name);
                $value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null;
            }
            else {
                $value = isset($_SESSION[$prefix][$name]) ? $_SESSION[$prefix][$name] : null;
            }
        }
        else {
            if (strpos($name, '.')) {
                list($name1, $name2) = explode('.', $name);
                $value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null;
            }
            else {
                $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
            }
        }
        return $value;
    }
698213
private function getClassName($table, $prefix)
    {
        $prefixLen = strlen($prefix);
        if(substr($table, 0, $prefixLen) === $prefix)
        {
            $table = substr($table, $prefixLen);
        }
        return Text::toPascalName($table);
    }
547851
private static function identifyMethods($prefix)
    {
        //====================================================================//
        // Prepare List of Available Methods
        $result = array();
        foreach (get_class_methods(__CLASS__) as $method) {
            if (0 !== strpos($method, $prefix)) {
                continue;
            }
            if (false === strpos($method, "Fields")) {
                continue;
            }
            $result[] = $method;
        }

        return $result;
    }
1022300
protected static function getClassMethodsByPrefix($prefix = null)
    {
        //
        $attribute = 'MethodsByPrefix:'.$prefix;

        if (!static::hasClassAttribute($attribute)) {
            $class = static::getClass();
            $allMethods = get_class_methods($class);
            $methods = [];

            if (count($allMethods) > 0) {
                foreach ($allMethods as $method) {
                    if (preg_match('/^'.$prefix.'/i', $method)) {
                        $methods[] = $method;
                    }
                }
            }
            asort($methods);

            static::setClassAttribute($attribute, $methods);
        }

        //
        return static::getClassAttribute($attribute);
    }
418503
private static function arrayFlatten($array, $prefix = '')
    {
        $result = array();
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result = $result + self::arrayFlatten($value, $prefix . $key . '.');
            } else {
                $result[$prefix . $key] = trim(preg_replace('/\s+/', ' ', $value));
            }
        }
        return $result;
    }
1061112
public static function getConstantsAnnotations($className, $annotationClassName = null)
    {
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Constants'] ?? [];
        }
        $result = [];
        foreach(static::$annotations[$className]['Constants'] ?? [] as $constantName => $annotations)
        {
            foreach($annotations as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[$constantName][] = $annotation;
                }
            }
        }
        return $result;
    }
882582
protected function getConstructorArgumentsForClass($className)
    {
        if (!isset($this->constructorReflectionFirstLevelCache[$className])) {
            $constructorSignature = [];

            // TODO: Check if we can get rid of this reflection service usage, directly reflecting doesn't work as the proxy class __construct has no arguments.
            if ($this->reflectionService->hasMethod($className, '__construct')) {
                $constructorSignature = $this->reflectionService->getMethodParameters($className, '__construct');
            }

            $this->constructorReflectionFirstLevelCache[$className] = $constructorSignature;
        }

        return $this->constructorReflectionFirstLevelCache[$className];
    }
1335896
function constants($class,$prefix='') {
		$ref=new ReflectionClass($class);
		$out=array();
		foreach (preg_grep('/^'.$prefix.'/',array_keys($ref->getconstants()))
			as $val) {
			$out[$key=substr($val,strlen($prefix))]=
				constant((is_object($class)?get_class($class):$class).'::'.$prefix.$key);
		}
		unset($ref);
		return $out;
	}
664218
public static function getConstantAnnotations($className, $constantName, $annotationClassName = null)
    {
        if(!isset(static::$annotations[$className]['Constants'][$constantName]))
        {
            return [];
        }
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Constants'][$constantName];
        }
        else
        {
            $result = [];
            foreach(static::$annotations[$className]['Constants'][$constantName] as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[] = $annotation;
                }
            }
            return $result;
        }
    }
949126
public static function getConstants($name) 
    {
        if (isset(self::$_const[$name])) {
            return self::$_const[$name];
        }
        $self = new \ReflectionClass(new static());
        $contants = $self->getConstants();
        $prefix = strtoupper($name) . '_';
        $prefixLength = strlen($prefix);
        $prefixOffset = $prefixLength - 1;
        self::$_const[$name] = [];
        foreach ($contants as $key => $value) {
            if (substr($key, 0, $prefixLength) === $prefix) {
                self::$_const[$name][$value] = ucwords(strtolower(Inflector::humanize(substr($key, $prefixLength))));
            }
        }
        return self::$_const[$name];
    }
71015
public static function getClassPath($className, $extension = '.php')
    {
        $prefix = $className = self::camelCaseToLowerNamespace(str_replace('_', '\\', $className));

        while (false !== $position = strrpos($prefix, '\\')) {
            $prefix = substr($prefix, 0, $position);
            $alias = self::getAlias($prefix);

            if (!$alias) {
                continue;
            }

            $path = $alias.'\\'.substr($className, mb_strlen($prefix) + 1);
            $absolutePath = str_replace('\\', DIRECTORY_SEPARATOR, $path).$extension;

            if (is_readable($absolutePath)) {
                return $absolutePath;
            }
        }

        return false;
    }