Expand sub-list within a format

@param string Format
@return array Accepted values
@author Luke Lanchester
503584
protected function expand_format_expression($format) {

		$increment = 1;

		if(strpos($format, '/') !== false) {
			list($format, $increment) = explode('/', $format, 2);
			$increment = ($increment === '*') ? 1 : (int) $increment;
		}

		$parts = explode('-', $format, 2);

		$start = array_shift($parts);
		$end = array_shift($parts);

		if($start === '*') $start = $this->min;
		if($end === null) $end = $this->max;

		$start = max($this->min, $start);
		$end = min($this->max, $end);

		if( ($end - $start) < $increment) return array($start);
		return range($start, $end, $increment);

	}
687793
public function subTotal($format = true, $withDiscount = true)
    {
        $total = 0;

        if ($this->count() != 0) {
            foreach ($this->getItems() as $item) {
                $total += $item->subTotal(false, $withDiscount);
            }
        }

        if ($total < 0) {
            $total = 0;
        }

        return $this->formatMoney($total, null, null, $format);
    }
574909
protected function applyFormat($format, $data)
    {

        foreach ($format as $key => $value) {
            $meta = array_values(array_filter($this->formatting, function ($item) use ($value) {
                return $item['name'] === $value['function'] ? true : false;
            }));

            if ($meta && !array_key_exists('class', $value)) {
                $data = $this->applyDefaultFormat($value, $meta[0], $data);
            } else {
                $data = $this->applyCustomFormat($value, $data);
            }
        }

        return $data;
    }
513393
public function parseFormat($format)
  {
    $this->keys = array();

    $regex = '';
    $curr = '';
    $beforeGroup = '';
    $afterGroup = '';

    $split = str_split($format);
    $count = count($split);
    for ($i=0; $i<$count; $i++) {
      $c = $split[$i];
      if ($c == '{') {
        $regex .= preg_quote($curr, '/');
        $curr = '';
        if ($i+1 < $count && $split[$i+1] == '{') {
          $beforeGroup = $i != 0 ? $split[$i-1] : '';
          $i++;
          continue;
        }
      } else if ($c == '}' && ($i+1 < $count && $split[$i+1] == '}')) {
        $afterGroup = $i+2 < $count ? $split[$i+2] : '';
        $regex .= $this->parseCapturingGroup(trim($curr), $beforeGroup, $afterGroup);
        $curr = '';
        $i++;
        continue;
      }
      $curr .= $c;
    }

    if (empty($this->keys)) {
      throw new \InvalidArgumentException('$format must have at least one capturing group');
    }

    # use /s flag so that wildcard char also matches "\n"
    $this->regex = '/^' . $regex . preg_quote($curr, '/') . '$/s';
  }
829654
private function getResourceLookup($format)
    {
        if(in_array($format, self::$formats)){
            if(!isset($this->lookups)){
                $this->lookups = [
                    'list' => $this->getServiceManager()->get(ListResourceLookup::SERVICE_ID),
                    'tree' => $this->getServiceManager()->get(TreeResourceLookup::SERVICE_ID)
                ];
            }
            return $this->lookups[$format];
        }
        return null;
    }
317523
public function format(string $format)
    {
        if (! $this->validateManipulation($format, 'format')) {
            throw InvalidManipulation::invalidParameter(
                'format',
                $format,
                $this->getValidManipulationOptions('format')
            );
        }

        return $this->addManipulation('format', $format);
    }
1352077
private function unpackInput($format)
    {
        $code = version_compare(PHP_VERSION, '5.5.0-dev', '>=') ? 'a' : 'A';

        try {
            $result = unpack($format . 'result/' . $code . '*input', $this->input);
        } catch (\Exception $e) {
            throw new RangeException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }

        $this->input = $result['input'];

        return $result['result'];
    }
1156781
protected function getForceFormatOptions(FormatInterface $format)
	{
		$formatExtensions = $format->getExtensions();
		
		if (count($formatExtensions) > 0)
		{
			if ( ! file_exists(__DIR__.'/../../bin/ffmpeg_fmt.php'))
			{
				return [];
			}
			
			$ffmpeg_fmt = (array) require __DIR__.'/../../bin/ffmpeg_fmt.php';
			
			foreach ($ffmpeg_fmt as $format_string => $extensions)
			{
				if (array_intersect($formatExtensions, $extensions))
				{
					return ['force_format' => $format_string];
				}
			}
		}
		
		return [];
	}
268747
private function convertFormat($format)
    {
        if (is_array($format)) {
            // sounds like the format is already done, let's keep it as it is
            return $format;
        }
        if (array_key_exists($format, $this->formats)) {
            // it's a format defined in config, let's use all defined parameters
            return $this->formats[$format];
        } elseif (preg_match("/^([0-9]*)x([0-9]*)/", $format)) {
            // it's a custom [width]x[height] format, let's make a thumb
            return array('thumbnail' => $format);
        } else {
            throw new InvalidArgumentException(sprintf("Unknown IM format: %s", $format));
        }
    }
304998
public function to($format, array $options = []) {
		$default = ['indexed' => true];
		$options += $default;
		$options['internal'] = !$options['indexed'];
		unset($options['indexed']);

		$this->offsetGet(null);
		if (!$options['internal'] && !is_scalar(current($this->_index))) {
			$options['internal'] = true;
		}
		return parent::to($format, $options);
	}
1366794
function expandInheritance( $table )
    {
        $newTable = array();
        foreach ( $table as $tableItem )
        {
            if ( is_string( $tableItem ) )
            {
                $identifier = $tableItem;
                $subTable = $this->mappingTable( $identifier );
                if ( !$subTable )
                {
                    eZDebug::writeError( "Failed to fetch mapping table for identifier: '$identifier'" );
                }
                else
                {
                    $subTable = $this->expandInheritance( $subTable );
                    $newTable = array_merge( $newTable, $subTable );
                }
            }
            else
            {
                $newTable[] = $tableItem;
            }
        }
        return $newTable;
    }
728259
public function format($format = '')
    {
        if ($this->isHollow()) {
            $format = $this->format;
        } else {
            $format = $format ?: $this->format;
        }

        return parent::format($format);
    }
633222
private function validateDiff($format)
    {
        $keywords = [
            'from',
            'since',
            'age',
            'till',
            'until',
        ];
        $op       = null;
        foreach ($keywords as $keyword) {
            $len = strlen($keyword);
            if (substr($format, -$len) === $keyword) {
                $op     = $keyword;
                $format = substr($format, 0, strlen($format) - $len);
                if (!$format && 'age' == $op) {
                    $format = 'years';
                }
                break;
            }
        }

        return [$op, isset($this->formatInterval[$format]) ? $this->formatInterval[$format] : null];
    }
292055
protected function getFormat($format)
    {
        if ($format === false) {
            $format = 'none';
        }
        
        $types = [
            'none' => \IntlDateFormatter::NONE,
            'short' => \IntlDateFormatter::SHORT,
            'medium' => \IntlDateFormatter::MEDIUM,
            'long' => \IntlDateFormatter::LONG,
            'full' => \IntlDateFormatter::FULL
        ];
        
        return isset($types[$format]) ? $types[$format] : null;
    }
1158991
public function setFormat($format)
    {
        if (JFactory::getApplication()->getCfg('sef_suffix') && $format === 'feed') {
            $format = 'rss';
        }

        return parent::setFormat($format);
    }
220873
public function getPostInstructions($format = 'plain')
    {
        $content = [];

        if (\count($this->postInstructions) == 0) {
            return null;
        }

        ksort($this->postInstructions);

        foreach ($this->postInstructions as $version => $instructions) {
            $content[] = sprintf("## %s", $version);
            foreach ($instructions as $instruction) {
                $content[] = sprintf("%s", $instruction);
            }
        }

        $content = implode("\n\n", $content);

        if ($format === 'html') {
            $content = Markdown::defaultTransform($content);
        }

        return $content;
    }
454189
public function setFormat($format) {
        $upperFormat = strtoupper($format);
        $this->searchParams->config->searchFormat = array_search($upperFormat, SearchFormat::$__names);
    }