Convert hstore to php array

@param $string

@return array
766999
private static function fromHStore($string)
    {
        $result = [];
        if (empty($string)) {
            return $result;
        }

        preg_match_all(
            '#"((?:\\\"|[^"])*)"=>"((?:\\\"|[^"])*)"#U',
            $string,
            $matches
        );
        foreach ($matches[1] as $id => $val) {
            $result[stripcslashes($val)] = stripcslashes($matches[2][$id]);
        }

        return $result;
    }
282075
public static function parseStringForSearch($string)
    {
        $words = explode(' ', $string);
        $conditions = [];

        foreach ($words as $word) {
            $word = trim($word);

            if (empty($word)) {
                continue;
            }

            if (is_numeric($word)) {
                $conditions[] = $word;
                continue;
            }

            if (1 === mb_strlen($word)) {
                continue;
            }

            if (mb_strlen($word) > 7) {
                $conditions[] = mb_substr($word, 0, -3, 'UTF-8');
                continue;
            }

            if (mb_strlen($word) > 5) {
                $conditions[] = mb_substr($word, 0, -1, 'UTF-8');
                continue;
            }

            if (in_array(mb_substr($word, -1, null, 'UTF-8'), ['ě', 'š', 'č', 'ř', 'ž', 'ý', 'á', 'í', 'é', 'ú', 'ů'], true)) {
                $conditions[] = mb_substr($word, 0, -1, 'UTF-8');
                continue;
            }

            $conditions[] = $word;
        }

        return $conditions;
    }
631804
public static function parse($string)
  {
    $attr = [];
    $list = [];

    preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);

    if ( is_array($attr) ){
      $numPairs = count($attr[1]);
      for ($i = 0; $i < $numPairs; $i++){
        $list[$attr[1][$i]] = $attr[2][$i];
      }
    }
    
    return $list;
  }
1243973
private function unserialize($string)
    {
        if (false === $string || null === $string || '' === $string) {
            throw new \InvalidArgumentException('Unable to unserialize value.');
        }
        set_error_handler(
            function () {
                restore_error_handler();
                throw new \InvalidArgumentException('Unable to unserialize value, string is corrupted.');
            },
            E_NOTICE
        );
        $result = unserialize($string);
        restore_error_handler();

        return $result;
    }
95645
public static function fromString( $string ) {
		$values = [
			'1'     => true,
			'y'     => true,
			'yes'   => true,
			'true'  => true,

			'0'     => false,
			'n'     => false,
			'no'    => false,
			'false' => false,
		];

		foreach ( $values as $value => $boolean ) {
			if ( strtolower( $value ) === strtolower( $string ) ) {
				return $boolean;
			}
		}

		// rely on PHP's string to boolean conversion in all other cases
		return (bool) $string;
	}
707172
protected static function _parse($string) {
		if (substr_count($string, '::') !== 2) {
			throw new Exception('Possible data tampering: form signature string has wrong format.');
		}
		list($locked, $excluded) = explode('::', $string, 3);

		return [
			'locked' => unserialize(urldecode($locked)),
			'excluded' => unserialize(urldecode($excluded))
		];
	}
105475
static function split($string, $token) {
        $array = [];
        
        $tok = strtok($string, $token);
        
        while ($tok != false) {
            array_push($array, $tok);
            
            $tok = strtok($token);
        }
        
        return $array;
    }
562016
public function parse(string $string)
    {
        $array = [];

        foreach ($this->splitItems($string) as $item) {
            $array[] = $this->splitItem($item);
        }

        return $array;
    }
1092838
public static function extractSha1( $string ) {
		if( preg_match( '/^(?:(?:urn:)?(?:sha1|bitprint):)?([0-9A-Z]{32})(?:$|\W)/i', $string, $bif ) ) {
			return TOGoS_Base32::decode($bif[1]);
		} else if( preg_match('/^[0-9a-f]{40}$/i', $string) ) {
			return hex2bin($string);
		} else if( strlen($string) == 20 ) {
			return $string;
		} else {
			throw new Exception("Unable to extract SHA-1 from string '$string'");
		}
	}
596847
public static function stringToArray(?string $string): array {
        $result = [];
        $strLen = \strlen($string);
        if (null === $string) return $result;
        if (1 === $strLen) {
            $result[] = $string;
            return $result;
        }
        for ($i = 0; $i < $strLen; $i++) {
            $result[] = $string[$i];
        }
        return $result;
    }
739742
private function splitString($string)
    {
        $result = array();
        for ($i = 0; $i < mb_strlen($string, "UTF-8"); ++$i) {
            $result[] = mb_substr($string, $i, 1, "UTF-8");
        }
        return $result;
    }
781597
public static function decode($string)
    {
        if (!$string) {
            return new ArrayObject();
        }

        $array = json_decode($string, true);

        static::checkLastError();

        if (!is_array($array)) {
            $array = [];
        }

        return ArrayObject::make($array);
    }
954544
private function explodeKey(string $string): array
    {
        [$key, $tag] = \explode(self::SEPARATOR_TAG, $string . self::SEPARATOR_TAG);

        if ($key === self::HIERARCHY_SEPARATOR) {
            $parts = ['root'];
        } else {
            $parts = \explode(self::HIERARCHY_SEPARATOR, $key);
            // remove first element since it is always empty and replace it with 'root'
            $parts[0] = 'root';
        }

        foreach ($parts as &$level) {
            $level .= self::SEPARATOR_TAG . $tag;
        }

        return $parts;
    }
1117436
public function parseString($string, $values)
    {
        $positions = [];
        $pos = 0;
        $offset = 0;

        while (($pos = strpos($string, "?", $offset)) !== false) {
            $positions[] = $pos;
            $offset = $pos + 1;
        }

        $count = count($positions);

        if ($count == 1) {
            $values = array($values);
        }

        for ($i = 0; $i < $count; $i++) {
            $value = $values[$i];
            if ($value instanceof Query) {
                $value = $this->parseValueQuery($value);
            } elseif (is_array($value)) {
                foreach ($value as $key => $subvalue) {
                    if (trim($subvalue) != '') {
                        $value[$key] = is_numeric($subvalue) ? $subvalue : $this->getQuery()->getManager()->getAdapter()->quote($subvalue);
                    } else {
                        unset($value[$key]);
                    }
                }
                $value = "(" . implode(", ", $value) . ")";
            } elseif (is_numeric($value)) {
            } else {
                $value = $this->getQuery()->getManager()->getAdapter()->quote($values[$i]);
            }
            $string = substr_replace($string, $value, strpos($string, '?'), 1);
        }

        return $string;
    }
595074
private function getAnyType($string)
    {
        $anyString = '';

        do {
            $anyString .= $string[0];
            $string = substr($string, 1);

            $typeInfo = $this->scanNextType($string);

            // ignore all until markup reached
            if ($typeInfo['type'] !== self::T_MARKUP_OPEN && $typeInfo['type'] !== self::T_MARKUP_OPEN_ESCAPED) {
                $typeInfo = null;
            }
        } while ($typeInfo === null && $string);

        return [
            'type'   => self::T_ANY,
            'match'  => $anyString,
            'length' => strlen($anyString),
        ];
    }
1164094
protected function parseString($string) {
        $matches = [];

        if (preg_match_all($this->regex, $string, $result) !== false) {
            $matches = $result[0];
        }

        return $matches;
    }
486962
public static function jsonToArray(string $string): array
    {
        static $jsonErrors = [
            JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
            JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch',
            JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
            JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
            JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded',
        ];

        $data = json_decode($string, true);

        if (JSON_ERROR_NONE !== json_last_error()) {
            $last = json_last_error();

            throw new \RuntimeException(
                'Unable to parse JSON data: '
                .(isset($jsonErrors[$last]) ? $jsonErrors[$last] : 'Unknown error')
            );
        }

        return $data;
    }