@param        $string
@param string $fieldName
@param bool   $assoc

@return mixed

@throws \Exception
421186
public function decodeArray($string, $fieldName = null, $assoc = false)
    {
        if (empty($string)) {
            return [];
        }
        $array = self::decode($string, $fieldName, $assoc);
        if (is_string($array)) {
            $array = self::decode($array, $fieldName, $assoc);
        }
        if (!is_array($array)) {
            throw new \Exception('The field '.$fieldName.' is not a JSON array as expected.');
        }

        return $array;
    }
669359
public static function initializeByString($string) {
        $Object = json_decode($string);
        $result = self::checkStatus($Object->status);
        if ($result === true) {
            $Status = new self();
            $Status->setStatus($Object->status)
                ->setReceipt(Receipt::initializeByObject($Object->receipt));
            return $Status;
        } else {
            $Exception = new $result($string, $Object->status);
            throw $Exception;
        }
    }
1019012
public static function decode(
        string $json,
        bool $assoc = true,
        int $depth = 512,
        int $options = 0,
        string $context = ''
    ) {
        // Clear json_last_error()
        json_encode(null);

        $value = json_decode($json, $assoc, $depth, $options);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonError(
                sprintf(
                    'Unable to decode JSON: %s. %s',
                    json_last_error_msg(),
                    $context
                )
            );
        }

        return $value;
    }
316665
public function jsonDecode($string, $assoc = false)
    {
        if (is_string($string)) {
            return json_decode($string, $assoc);
        }
        return null;
    }
1333921
public function getAssociation($fieldName)
    {
        if (!$this->hasAssociation($fieldName)) {
            throw MappingException::associationNotFound($this->name, $fieldName);
        }

        return $this->mappings[$fieldName];
    }
896695
public function write($string)
    {
        $fileName = $this->getFileName();
        $handle = $this->getHandle();

        if (fwrite($handle, $string) === false) {
            throw new \Exception('Cannot write to file ' . $fileName);
        }
    }
982535
function get_record($dn, $assoc=false)
    {
        $res = $this->result = null;

        if ($this->ready && $dn) {
            $dn = self::dn_decode($dn);

            if ($rec = $this->ldap->get_entry($dn)) {
                $rec = array_change_key_case($rec, CASE_LOWER);
            }

            // Use ldap_list to get subentries like country (c) attribute (#1488123)
            if (!empty($rec) && $this->sub_filter) {
                if ($entries = $this->ldap->list_entries($dn, $this->sub_filter, array_keys($this->prop['sub_fields']))) {
                    foreach ($entries as $entry) {
                        $lrec = array_change_key_case($entry, CASE_LOWER);
                        $rec  = array_merge($lrec, $rec);
                    }
                }
            }

            if (!empty($rec)) {
                // Add in the dn for the entry.
                $rec['dn'] = $dn;
                $res = $this->_ldap2result($rec);
                $this->result = new rcube_result_set(1);
                $this->result->add($res);
            }
        }

        return $assoc ? $res : $this->result;
    }
5070
public function getPostData($assoc = false)
    {
        $postData = $this->request->getJsonRawBody($assoc);

        if (!is_object($postData) && !$assoc) {
            return new stdClass();
        }

        if (!is_array($postData) && $assoc) {
            return [];
        }

        return $postData;
    }
964225
public function translate($string) {

        // get selected signature

        if(empty($this->signature) === false) {
            if (array_key_exists($string, $this->signature) === false) {
                return $string;
            }
            return $this->signature[$string];
        }
        else {
            throw new Exception('Could not find translate signature');
        }
    }
1360313
function getAttributes($asString = false)
    {
        if ($asString) {
            return $this->_getAttrString($this->_attributes);
        } else {
            return $this->_attributes;
        }
    }
568831
public function xml($assoc = false, $fromEncoding = null, $toEncoding = 'UTF-8')
    {
        $xml = simplexml_load_string($this->body($fromEncoding, $toEncoding), null, LIBXML_NOCDATA | LIBXML_COMPACT);
        if($assoc)
        {
            $xml = (array)$xml;
        }
        return $xml;
    }
1239060
public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL )
	{
		$vcard	= new ADT_VCard;
		return self::parseInto( $string, $vcard, $charsetIn, $charsetOut );
	}
1003529
public function relations($tableName = null, $assoc = false)
    {
        if (is_array($tableName))
        {
            $relations = $this->getKey('relations', $assoc);
            if ($assoc)
            {
                return array_intersect_key($relations, array_flip($tableName));
            }
            else
            {
                return (object) array_intersect_key((array) $relations, array_flip($tableName));
            }
        }
        elseif ($tableName !== null)
        {
            return $assoc ? $this->getKey('relations', $assoc)[$tableName] : $this->getKey('relations', $assoc)->{$tableName};
        }

        return $this->getKey('relations', $assoc);
    }
131187
public function userAutocompleteAction($string)
    {
        $manager = $this->getSiteManager();
        $account = $this->getCurrentUser();

        if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) {
            throw $this->createAccessDeniedException();
        }

        $database = $this->getDatabaseConnection();
        $q = $database
            ->select('users', 'u')
            ->fields('u', ['uid', 'name'])
            ->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE')
            ->condition('u.uid', [0, 1], 'NOT IN')
            ->orderBy('u.name', 'asc')
            ->range(0, 16)
            ->addTag('ucms_user_access')
        ;

        $suggest = [];

        foreach ($q->execute()->fetchAll() as $record) {
            $key = $record->name . ' [' . $record->uid . ']';
            $suggest[$key] = check_plain($record->name);
        }

        return new JsonResponse($suggest);
    }
995421
public function _($string, $jsSafe = false)
	{
		//$key = str_replace( ' ', '_', strtoupper( trim( $string ) ) );echo '<br />'.$key;
        $key = strtoupper($string);
		$key = (substr($key, 0, 1) === '_') ? substr($key, 1) : $key;

		if (isset($this->_strings[$key])) {

            $string = $this->_debug ? "&bull;".$this->_strings[$key]."&bull;" : $this->_strings[$key];

            if ($this->_debug) {
                $caller = $this->_getCallerInfo();

                if (!array_key_exists($key, $this->_used)) {
					$this->_used[$key] = array();
				}

				$this->_used[$key][] = $caller;
			}

		} else {

            if (defined($string)) {

                $string = $this->_debug ? '!!'.constant($string).'!!' : constant($string);

				// Store debug information
				if ( $this->_debug ) {
                    $caller = $this->_getCallerInfo();

					if (!array_key_exists($key, $this->_used)) {
						$this->_used[$key] = array();
					}

					$this->_used[$key][] = $caller;
				}

			} elseif ($this->_debug) {

                $caller	= $this->_getCallerInfo();
				$caller['string'] = $string;

				if(!array_key_exists($key, $this->_orphans)) {
					$this->_orphans[$key] = array();
				}

				$this->_orphans[$key][] = $caller;
				$string = '??'.$string.'??';
			}
		}

		if ($jsSafe) {
			$string = addslashes($string);
		}

		return $string;
	}
799057
public static function decode(string $data, bool $assoc = false, int $depth = 512, int $options = 0)
    {
        $json          = json_decode($data, $assoc, $depth, $options);
        $jsonLastError = json_last_error();

        if ($jsonLastError !== JSON_ERROR_NONE) {
            throw new \InvalidArgumentException('Failed to decode JSON: ' . json_last_error_msg(), $jsonLastError);
        }

        return $json;
    }
900639
protected function __getResult($stmt, string $index = null, bool $assoc = null){
		$assoc = $assoc ?? true;

		if(is_bool($stmt)){
			return $stmt; // @codeCoverageIgnore
		}

		return parent::getResult([$stmt, 'fetch'], [$assoc ? PDO::FETCH_ASSOC : PDO::FETCH_NUM], $index, $assoc);
	}