/*!
Get limitation array

\return access limitation array
6150
function limitArray()
    {
        $limitValues = $this->attribute( 'values' );

        $valueArray = array();

        foreach ( array_keys( $limitValues ) as $valueKey )
        {
            $valueArray[] = $limitValues[$valueKey]->attribute( 'value' );
        }

        return array( $this->attribute( 'identifier' ) => $valueArray );
    }
492931
function getAllowedMovesFromArrays(arrMoves) {
    return arrMoves.reduce(function (moves, a) {
        return moves.concat(getAllowedMovesFromArray(a));
    }, []);
}
1070211
private function getPermissionArray()
    {
        $permissionArray = array(
            'can_add'           => false,
            'subtree_limit'     => $this->Attribute->contentClassAttribute()->attribute( eZTagsType::SUBTREE_LIMIT_FIELD ),
            'allowed_locations' => array(),
            'allowed_locations_tags' => false );

        $userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess( 'tags', 'add' );

        if ( $userLimitations['accessWord'] == 'no' )
            return $permissionArray;

        $userLimitations = isset( $userLimitations['simplifiedLimitations']['Tag'] ) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
        $limitTag = eZTagsObject::fetchWithMainTranslation( $permissionArray['subtree_limit'] );

        if ( empty( $userLimitations ) )
        {
            if ( $permissionArray['subtree_limit'] == 0 || $limitTag instanceof eZTagsObject )
            {
                $permissionArray['allowed_locations'] = array( $permissionArray['subtree_limit'] );

                if ( $limitTag instanceof eZTagsObject )
                    $permissionArray['allowed_locations_tags'] = array( $limitTag );
            }
        }
        else if ( $permissionArray['subtree_limit'] == 0 )
        {
            $permissionArray['allowed_locations_tags'] = array();

            /** @var eZTagsObject[] $userLimitations */
            $userLimitations = eZTagsObject::fetchList( array( 'id' => array( $userLimitations ) ), null, null, true );
            if ( is_array( $userLimitations ) && !empty( $userLimitations ) )
            {
                foreach ( $userLimitations as $limitation )
                {
                    $permissionArray['allowed_locations'][] = $limitation->attribute( 'id' );
                    $permissionArray['allowed_locations_tags'][] = $limitation;
                }
            }
        }
        else if ( $limitTag instanceof eZTagsObject )
        {
            /** @var eZTagsObject[] $userLimitations */
            $userLimitations = eZTagsObject::fetchList( array( 'id' => array( $userLimitations ) ), null, null, true );
            if ( is_array( $userLimitations ) && !empty( $userLimitations ) )
            {
                $pathString = $limitTag->attribute( 'path_string' );
                foreach ( $userLimitations as $limitation )
                {
                    if ( strpos( $pathString, '/' . $limitation->attribute( 'id' ) . '/' ) !== false )
                    {
                        $permissionArray['allowed_locations'] = array( $permissionArray['subtree_limit'] );
                        $permissionArray['allowed_locations_tags'] = array( $limitTag );
                        break;
                    }
                }
            }
        }

        if ( !empty( $permissionArray['allowed_locations'] ) )
            $permissionArray['can_add'] = true;

        return $permissionArray;
    }
984508
function memoryLimitRequirement()
    {
        $memoryLimit = ini_get('memory_limit');
        $bytes = $this->getByteSize($memoryLimit);

        $humanLimit = $memoryLimit . ($memoryLimit === -1 ? ' (no limit)' : '');
        $memo = "Craft requires a minimum PHP memory limit of 256M. The memory_limit directive in php.ini is currently set to {$humanLimit}.";

        return array(
            'name' => 'Memory Limit',
            'mandatory' => false,
            'condition' => $bytes === -1 || $bytes >= 268435456,
            'memo' => $memo,
        );
    }
1009076
private function groupLimitationValues(array $limitationValues)
    {
        $objectStateHandler = $this->persistence->objectStateHandler();
        $stateGroups = $objectStateHandler->loadAllGroups();
        $groupedLimitationValues = [];
        foreach ($stateGroups as $stateGroup) {
            $states = $objectStateHandler->loadObjectStates($stateGroup->id);
            $stateIds = array_map(function ($state) {
                return $state->id;
            }, $states);
            $limitationValuesGroup = array_intersect($stateIds, $limitationValues);
            if (!empty($limitationValuesGroup)) {
                $groupedLimitationValues[] = array_values($limitationValuesGroup);
            }
        }

        return $groupedLimitationValues;
    }
128202
protected function getLimitCondition( $limits = array() ){
		if( !is_array( $limits ) )
			return;
		$limit		= !isset( $limits[1] ) ? 0 : abs( $limits[1] );
		$offset		= !isset( $limits[0] ) ? 0 : abs( $limits[0] );
		if( $limit )
			return ' LIMIT '.$limit.' OFFSET '.$offset;
	}
915835
public function limit($length, $offset = 0)
    {
        // Type checking: designed for consistency with DataList::limit()
        if (!is_numeric($length) || !is_numeric($offset)) {
            Deprecation::notice(
                '4.3',
                'Arguments to ArrayList::limit() should be numeric'
            );
        }

        if ($length < 0 || $offset < 0) {
            Deprecation::notice(
                '4.3',
                'Arguments to ArrayList::limit() should be positive'
            );
        }

        if (!$length) {
            if ($length === 0) {
                Deprecation::notice(
                    '4.3',
                    "limit(0) is deprecated in SS4. In SS5 a limit of 0 will instead return no records."
                );
            }

            $length = count($this->items);
        }

        $list = clone $this;
        $list->items = array_slice($this->items, $offset, $length);

        return $list;
    }
897228
function canAssignSectionList()
    {
        $access = $this->hasAccessTo( 'section', 'assign' );

        if ( $access['accessWord'] == 'yes' )
        {
            return array( '*' );
        }
        else if ( $access['accessWord'] == 'limited' )
        {
            $allowedSectionIDList = array();
            foreach ( $access['policies'] as $policy )
            {
                if ( isset( $policy['NewSection'] ) )
                {
                    if ( is_array( $policy['NewSection'] ) && !empty( $policy['NewSection'] ) )
                    {
                        $allowedSectionIDList = array_merge( $allowedSectionIDList, $policy['NewSection'] );
                    }
                }
                else
                {
                    return array( '*' );
                }
            }
            $allowedSectionIDList = array_unique( $allowedSectionIDList );
            return $allowedSectionIDList;
        }
        return array();
    }
950171
public function limits($options = [])
    {
        $url = $this->getBaseUrl();
        $url .= '/limits';

        $limits = $this->request($url, $options);

        return $limits;
    }
319688
protected function get_indexing_restrictions() {
        global $DB;

        // This includes completely empty configdata, and also three other values that are
        // equivalent to empty:
        // - A serialized completely empty object.
        // - A serialized object with one field called '0' (string not int) set to boolean false
        //   (this can happen after backup and restore, at least historically).
        // - A serialized null.
        $stupidobject = (object)[];
        $zero = '0';
        $stupidobject->{$zero} = false;
        return [$DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ? AND " .
                $DB->sql_compare_text('bi.configdata') . " != ?",
                ['', base64_encode(serialize((object)[])), base64_encode(serialize($stupidobject)),
                base64_encode(serialize(null))]];
    }
626609
public function parseLimitation(array $limitation)
    {
        if (!array_key_exists('_identifier', $limitation)) {
            throw new Exceptions\Parser("Missing '_identifier' attribute for Limitation.");
        }

        $limitationObject = $this->getLimitationByIdentifier($limitation['_identifier']);

        if (!isset($limitation['values']['ref']) || !is_array($limitation['values']['ref'])) {
            throw new Exceptions\Parser('Invalid format for limitation values in Limitation.');
        }

        $limitationValues = array();
        foreach ($limitation['values']['ref'] as $limitationValue) {
            if (!array_key_exists('_href', $limitationValue)) {
                throw new Exceptions\Parser('Invalid format for limitation values in Limitation.');
            }

            $limitationValues[] = $limitationValue['_href'];
        }

        $limitationObject->limitationValues = $limitationValues;

        return $limitationObject;
    }
309644
protected function getLimit($limit = null)
    {
        if (null === $limit) {
            $limit = $this->getDefaultLimit();
        }

        return $this->validateLimit($limit);
    }
1093695
public function getFlattenedLimitationsValues(LookupLimitationResult $lookupLimitations): array
    {
        $limitationsValues = [];

        /** @var \eZ\Publish\API\Repository\Values\User\LookupPolicyLimitations $lookupPolicyLimitation */
        foreach ($lookupLimitations->lookupPolicyLimitations as $lookupPolicyLimitation) {
            /** @var \eZ\Publish\API\Repository\Values\User\Limitation $limitation */
            foreach ($lookupPolicyLimitation->limitations as $limitation) {
                $limitationsValues[] = $limitation->limitationValues;
            }
        }

        return !empty($limitationsValues) ? array_unique(array_merge(...$limitationsValues)) : $limitationsValues;
    }
834099
protected function get()
    {
        $a = 0;
        $b = 1;
        $to = $this->getMaxLimit();
        while (0 < $to) {
            yield $a;

            list($a, $b) = [$b, $a + $b];
            --$to;
        }
    }
1045974
public function limit($var, $depth, array &$references = [])
    {
        if ($depth > $this->depthLimit) {
            return '*DEPTH LIMIT*';
        }

        if (is_array($var)) {
            return $this->limitArray($var, $depth, $references);
        }

        if (is_object($var)) {
            return $this->limitObject($var, $depth, $references);
        }

        return $var;
    }
186841
function GetArrayLimit($nrows,$offset=-1)
	{
		if ($offset <= 0) {
			$arr = $this->GetArray($nrows);
			return $arr;
		}
		for ($i=1; $i < $offset; $i++)
			if (!@OCIFetch($this->_queryID)) {
				$arr = array();
				return $arr;
			}
		$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
		if ($ret === false) {
			$arr = array();
			return $arr;
		}
		$this->fields = $ret;
		$this->_updatefields();
		$results = array();
		$cnt = 0;
		while (!$this->EOF && $nrows != $cnt) {
			$results[$cnt++] = $this->fields;
			$this->MoveNext();
		}

		return $results;
	}
665159
public static function GetCacheLimiterList () {
		return [
			static::CACHE_LIMITER_PUBLIC				=> static::CACHE_LIMITER_PUBLIC,
			static::CACHE_LIMITER_PRIVATE_NO_EXPIRE		=> static::CACHE_LIMITER_PRIVATE_NO_EXPIRE,
			static::CACHE_LIMITER_PRIVATE				=> static::CACHE_LIMITER_PRIVATE,
			static::CACHE_LIMITER_NOCACHE				=> static::CACHE_LIMITER_NOCACHE,
			static::CACHE_LIMITER_NOT_SEND_HEADER		=> static::CACHE_LIMITER_NOT_SEND_HEADER,
		];
	}