parses a constant

@param string $key the constant to parse
@param string $curBlock the current parser-block being processed
@return string parsed constant
5303
protected function parseConstKey($key, $curBlock)
	{
		if ($this->securityPolicy !== null && $this->securityPolicy->getConstantHandling() === Dwoo_Security_Policy::CONST_DISALLOW) {
			return 'null';
		}

		if ($curBlock !== 'root') {
			$output = '(defined("'.$key.'") ? '.$key.' : null)';
		} else {
			$output = $key;
		}

		return $output;
	}
561484
private function parseConstraint($constraint)
    {
        if (preg_match('{^([^,\s]+?)@(' . implode('|', self::$stabilities) . ')$}i', $constraint, $match)) {
            $constraint = $match[1];
            if ($match[2] !== 'stable') {
                $stabilityModifier = $match[2];
            }
        }

        if (preg_match('{^v?[xX*](\.[xX*])*$}i', $constraint)) {
            return array(new EmptyConstraint());
        }

        $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?' . self::$modifierRegex . '(?:\+[^\s]+)?';

        // Tilde Range
        //
        // Like wildcard constraints, unsuffixed tilde constraints say that they must be greater than the previous
        // version, to ensure that unstable instances of the current version are allowed. However, if a stability
        // suffix is added to the constraint, then a >= match on the current version is used instead.
        if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
            if (substr($constraint, 0, 2) === '~>') {
                throw new \UnexpectedValueException(
                    'Could not parse version constraint ' . $constraint . ': ' .
                    'Invalid operator "~>", you probably meant to use the "~" operator'
                );
            }

            // Work out which position in the version we are operating at
            if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
                $position = 4;
            } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
                $position = 3;
            } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
                $position = 2;
            } else {
                $position = 1;
            }

            // Calculate the stability suffix
            $stabilitySuffix = '';
            if (empty($matches[5]) && empty($matches[7])) {
                $stabilitySuffix .= '-dev';
            }

            $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
            $lowerBound = new Constraint('>=', $lowVersion);

            // For upper bound, we increment the position of one more significance,
            // but highPosition = 0 would be illegal
            $highPosition = max(1, $position - 1);
            $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
            $upperBound = new Constraint('<', $highVersion);

            return array(
                $lowerBound,
                $upperBound,
            );
        }

        // Caret Range
        //
        // Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple.
        // In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for
        // versions 0.X >=0.1.0, and no updates for versions 0.0.X
        if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
            // Work out which position in the version we are operating at
            if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
                $position = 1;
            } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
                $position = 2;
            } else {
                $position = 3;
            }

            // Calculate the stability suffix
            $stabilitySuffix = '';
            if (empty($matches[5]) && empty($matches[7])) {
                $stabilitySuffix .= '-dev';
            }

            $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
            $lowerBound = new Constraint('>=', $lowVersion);

            // For upper bound, we increment the position of one more significance,
            // but highPosition = 0 would be illegal
            $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
            $upperBound = new Constraint('<', $highVersion);

            return array(
                $lowerBound,
                $upperBound,
            );
        }

        // X Range
        //
        // Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple.
        // A partial version range is treated as an X-Range, so the special character is in fact optional.
        if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
            if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
                $position = 3;
            } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
                $position = 2;
            } else {
                $position = 1;
            }

            $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
            $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';

            if ($lowVersion === '0.0.0.0-dev') {
                return array(new Constraint('<', $highVersion));
            }

            return array(
                new Constraint('>=', $lowVersion),
                new Constraint('<', $highVersion),
            );
        }

        // Hyphen Range
        //
        // Specifies an inclusive set. If a partial version is provided as the first version in the inclusive range,
        // then the missing pieces are replaced with zeroes. If a partial version is provided as the second version in
        // the inclusive range, then all versions that start with the supplied parts of the tuple are accepted, but
        // nothing that would be greater than the provided tuple parts.
        if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
            // Calculate the stability suffix
            $lowStabilitySuffix = '';
            if (empty($matches[6]) && empty($matches[8])) {
                $lowStabilitySuffix = '-dev';
            }

            $lowVersion = $this->normalize($matches['from']);
            $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);

            $empty = function ($x) {
                return ($x === 0 || $x === '0') ? false : empty($x);
            };

            if ((!$empty($matches[11]) && !$empty($matches[12])) || !empty($matches[14]) || !empty($matches[16])) {
                $highVersion = $this->normalize($matches['to']);
                $upperBound = new Constraint('<=', $highVersion);
            } else {
                $highMatch = array('', $matches[10], $matches[11], $matches[12], $matches[13]);
                $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[11]) ? 1 : 2, 1) . '-dev';
                $upperBound = new Constraint('<', $highVersion);
            }

            return array(
                $lowerBound,
                $upperBound,
            );
        }

        // Basic Comparators
        if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
            try {
                $version = $this->normalize($matches[2]);

                if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') {
                    $version .= '-' . $stabilityModifier;
                } elseif ('<' === $matches[1] || '>=' === $matches[1]) {
                    if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
                        if (substr($matches[2], 0, 4) !== 'dev-') {
                            $version .= '-dev';
                        }
                    }
                }

                return array(new Constraint($matches[1] ?: '=', $version));
            } catch (\Exception $e) {
            }
        }

        $message = 'Could not parse version constraint ' . $constraint;
        if (isset($e)) {
            $message .= ': ' . $e->getMessage();
        }

        throw new \UnexpectedValueException($message);
    }
321536
public function get($key)
    {
        $curlHandler = $this->curlHandler($key.'?fields=_source,_ttl');

        $response = \curl_exec($curlHandler);
        \curl_close($curlHandler);

        if (false !== $response) {
            $response = \json_decode($response, true);

            if (true === $response['exists'] && $response['fields']['_ttl'] > 0) {
                return $response["_source"]['value'];
            }
        }

        return null;
    }
1164503
protected function parseLock(Query $query, $lock = false)
    {
        if (is_bool($lock)) {
            return $lock ? ' FOR UPDATE ' : '';
        } elseif (is_string($lock) && !empty($lock)) {
            return ' ' . trim($lock) . ' ';
        }
    }
186953
public static function pull($key)
    {
        self::setPrefix();
        $value = $_SESSION[self::$_sessionPrefix . $key];
        unset($_SESSION[self::$_sessionPrefix . $key]);

        return $value;
    }
429498
public function read($key)
    {
        if ($value = $this->memcache->get($key)) {
            $arr = unserialize($value);
            $this->changed = $arr['changed'];
            $this->ip      = $arr['ip'];
            $this->vars    = $arr['vars'];
            $this->key     = $key;
        }

        if ($this->debug) {
            $this->debug('get', $key, $value);
        }

        return $this->vars ?: '';
    }
445187
public function _get($key)
    {
        $value = parent::_get($key);

        try {
            return $this->_dereferenceTokens($value);
        } catch (RuntimeException $e) {
            throw $this->_createContainerException($this->__('Could not de-reference tokens'), null, $e, $this);
        }
    }
1282002
protected String getLockProperty(String key) {
        return lockProps != null ? lockProps.getProperty(key) : null;
    }
1271629
public static function parseBlock($block)
    {
        $data = array();
        $lines = preg_split("/(\r\n|\n|\r)/", trim($block));
        $continueKey = null;
        foreach($lines as $n => $line) {
            if ($continueKey !== null) {
                $data[$continueKey] .= "\n" . $line;
                if (!self::lineContinues($lines, $n, $continueKey)) {
                    $continueKey = null;
                }
            } elseif (preg_match('/([^:]*): ?(.*)/', $line, $match)) {
                $key = $match[1];
                $value = $match[2];
                // Convert multiple keys like 'FieldStateOption' or 'FieldValue'
                // from Choice fields to array
                if (isset($data[$key])) {
                    $data[$key]   = (array) $data[$key];
                    $data[$key][] = $value;
                } else {
                    $data[$key] = $value;
                }
                if (self::lineContinues($lines, $n, $key)) {
                    $continueKey = $key;
                }
            }
        }
        return $data;
    }
1002567
public function get($key)
    {
        $value = $this->apc->get($this->prefix.$key);

        if ($value !== false) {
            return $value;
        }
    }
179621
public function offsetGet($key) {
		$hashCode = HashUtils::hashCode($key);
		if (isset($this->values[$hashCode])) {
			return $this->values[$hashCode];
		}
		return null;
	}
783098
private static function getCoroutineContext(string $key)
    {
        $coroutineId = self::getCoroutineId();
        if (!isset(self::$context[$coroutineId])) {
            return null;
        }

        $coroutineContext = self::$context[$coroutineId];
        if (isset($coroutineContext[$key])) {
            return $coroutineContext[$key];
        }
        return null;
    }
420770
public function decr($key)
    {
        $this->log(__FUNCTION__, $key);
        return $this->persistence->decr($key);
    }
670646
public function resolveVariable($key)
    {
        $key = trim($key);

        if (($result = $this->executeFunction($key)) !== Constants::NOT_RESOLVED) {
            return $result;
        }

        return Constants::NOT_RESOLVED;
    }
550128
protected function parseKey(string $key): array
	{
		return (strpos($key, '.') === false) ? [$key, null] : explode('.', $key, 2);
	}
498096
protected function parseKey($key)
    {
        if (substr_count($key, $this->getDelimiter()) != 4)
        {
            throw new InvalidKeyException('Invalid file key: '.$key);
        }
        
        $this->key = $key;
        
        list($storageName, $className, $fieldName, $depth, $hashExt) = explode($this->getDelimiter(), $key);
        
        if (false !== strpos($hashExt, '.'))
        {
            list($hash, $extension) = explode('.', $hashExt, 2);
        }
        else
        {
            $hash = $hashExt;
            $extension = '';
        }
        
        $this->storageName = $storageName;
        $this->className = $className;
        $this->fieldName = $fieldName;
        $this->depth = $depth;
        $this->hash = $hash;
        $this->extension = $extension;
        
        return $this;
    }
94254
protected function parseSubkeys($key) {
        $k          = $key;
        $subkeys    = [];
        $quoteChars = ["'", '"'];                       // single and double quotes

        while (true) {
            $k = trim($k);

            foreach ($quoteChars as $char) {
                if (strpos($k, $char) === 0) {          // subkey starts with a quote char
                    $pos = strpos($k, $char, 1);        // find the ending quote char
                    if ($pos === false) throw new InvalidArgumentException('Invalid argument $key: '.$key);
                    $subkeys[] = substr($k, 1, $pos-1);
                    $k         = trim(substr($k, $pos+1));
                    if (!strlen($k))                    // last subkey or next char is a key separator
                        break 2;
                    if (strpos($k, '.') !== 0) throw new InvalidArgumentException('Invalid argument $key: '.$key);
                    $k = substr($k, 1);
                    continue 2;
                }
            }

            // key is not quoted
            $pos = strpos($k, '.');                     // find next key separator
            if ($pos === false) {
                $subkeys[] = $k;                        // last subkey
                break;
            }
            $subkeys[] = trim(substr($k, 0, $pos));
            $k         = substr($k, $pos+1);            // next subkey
        }
        return $subkeys;
    }