Search for a valid stack item with file and line not a raw class
call. Return the stack item with this data or null in case not stack item
found

@param  array      $stack
@return array|null
332580
protected static function searchForFileAndLineCalledFromStack(array $stack)
    {
        for ($i=0;$i<count($stack);$i++) {
            if(array_key_exists("file", $stack[$i]) && array_key_exists("line", $stack[$i])) return $stack[$i];
        }

        return null;
    }
644825
public function getNext($step = 1) {
      $position = ($this->position + $step);
      return isset($this->items[$position]) ? $this->items[$position] : null;
    }
566649
private function search($itemName, $type = null)
    {
        if (null === $type) {
            $searchArray = $this->getItems();
        } elseif (self::TYPE_FILE == $type) {
            $searchArray = $this->getFiles();
        } else {
            $searchArray = $this->getFolders();
        }

        foreach ($searchArray as $id => $cloudItem) {
            if ($itemName === $cloudItem->getName()) {
                return $cloudItem;
            }
        }

        return null;
    }
1175342
public function setProcessorsStack(array $stack)
    {
        $this->processorsStack = [];
        foreach (array_reverse($stack) as $processor) {
            $this->pushProcessor($processor);
        }

        return $this;
    }
106209
public static function trace(array $stack) {
		$result = [];

		foreach ($stack as $frame) {
			if (isset($frame['function'])) {
				if (isset($frame['class'])) {
					$result[] = trim($frame['class'], '\\') . '::' . $frame['function'];
				} else {
					$result[] = $frame['function'];
				}
			}
		}
		return $result;
	}
315314
public function stack($types = [])
    {
        if (is_string($types)) {
            $types = explode(',', $types) ?: [];
            $types = array_filter(array_map('trim', $types));
        }

        $files = $this->stack->getList($types);

        return $files;
    }
63190
public static function stack(string $stack)
    {
        if (! static::hasStack($stack)) {
            static::$stacks[$stack] = new StickyContextStack;
        }

        return static::$stacks[$stack];
    }
509880
protected function getArrayItemsSeparator($item)
    {
        $cfg = $this->file->getRequire($this->configFile);

        if (!$cfg) {
            return $this->defaultSeparator;
        }

        $file = $this->getFileContents();

        $arr = array_get($cfg, $item);

        $lastItem = end($arr);
        $preLastItem = prev($arr);

        if (!$lastItem or !$preLastItem) {
            return $this->defaultSeparator;
        }

        preg_match('/\,/', $file, $matchStart, PREG_OFFSET_CAPTURE, strpos($file, $preLastItem));
        $start = array_get(reset($matchStart), 1);

        $searchEnd = preg_match('/[\'"]/', $file, $matchEnd, PREG_OFFSET_CAPTURE, $start);
        $end = array_get(reset($matchEnd), 1);

        $separator = substr($file, $start, $end - $start);

        // remove comments
        $separator = preg_replace('/\/\/.*/ui', '', $separator);
        $separator = preg_replace('/#.*/ui', '', $separator);
        $separator = preg_replace('/\/\*(.*)\*\//ui', '', $separator);

        return $separator;
    }
112480
public function activeTrail($item)
    {
        if (is_null($item)) {
            return null;
        }

        if (!$item instanceof MenuItem) {
            throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
        }

        $stack = array();

        do {
            $stack[]= $item;
        } while ($item = $item->getParent());

        return array_reverse($stack);
    }
1186824
public static function stacktrace( $stack = null, $withPre = false )
	{
		if ( is_null( $stack ) )
			$stack = debug_backtrace();
		$output = $withPre ? '<pre>' : '';

		$stackLen = count( $stack );
		for ( $i = 1; $i < $stackLen; $i++ )
		{
			$entry = $stack[$i];

			$func = $entry['function'] . '(';
			$argsLen = count( $entry['args'] );

			for ( $j = 0; $j < $argsLen; $j++ )
			{
				$my_entry = $entry['args'][$j];

				if ( is_string( $my_entry ) )
					$func .= $my_entry;

				if ( $j < $argsLen - 1 )
					$func .= ', ';
			}
			$func .= ')';

			$entry_file = 'NO_FILE';

			if ( array_key_exists( 'file', $entry ) )
				$entry_file = $entry['file'];

			$entry_line = 'NO_LINE';

			if ( array_key_exists( 'line', $entry ) )
				$entry_line = $entry['line'];

			$output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL;
		}

		if ( $withPre )
			$output .= $output . '</pre>';

		return $output;
	}
1194601
public function resolveWildcard($stackName)
    {
        if (strpos($stackName, '*') === false) {
            return $stackName;
        }

        $helper = new \StackFormation\Helper();
        $stacks = Finder::find($stackName, array_keys($this->getStacksFromApi()));

        if (count($stacks) == 0) {
            throw new \Exception("No matching stack found for '$stackName'");
        } elseif (count($stacks) > 1) {
            throw new \Exception("Found more than one matching stack for '$stackName'.");
        }
        return end($stacks);
    }
1250905
private static function _stack($matches = false)
    {
        static $safe_blocks = [];
        if ($matches !== false) {
            $key = '<' . count($safe_blocks) . '>';
            $safe_blocks[$key] = $matches[0];
            return $key;
        } else {
            $tmp = $safe_blocks;
            unset($safe_blocks);
            return $tmp;
        }
    }
839948
protected static function formatDumpStack($stack, $var)
    {
        $ret = (count($stack) ? join('', $stack) : '');
        $ret .= '<' . (
            is_array($var)
                ? 'array(' . count($var) . ')'
                : get_class($var)
            ) . '>';

        return $ret;
    }
587966
private function interpret(array $line, array $header)
    {
        $item = [];
        foreach ($header as $index => $key) {
            $item[$key] = array_key_exists($index, $line) ? $line[$index] : null;
        }

        return $item;
    }
219142
public function getRequestStack($optional = false)
    {
        if ($this instanceof ContainerAwareInterface) {
            return $this->get('request_stack');
        }

        if (false === $optional && null === $this->requestStack) {
            throw new \RuntimeException('RequestStack not found. Setter not called?');
        }

        return $this->requestStack;
    }
1083720
public function getValue(array $array, string $path)
    {
        // If the $path value is empty, return the entire array graph
        if ($this->isRoot($path)) {
            return $array;
        }

        // If $path doesn't exist returns null. It is not possible to distinghuish between a path that exists and has a
        // null value and a path that doesn't exist at all.
        return $this->pa->getValue($array, $path);
    }
1368849
static  function find($list, $where) {
        if (is_array($where)) {
            foreach ($list as $item) {
                $is_ok = true;
                foreach ($where as $key => $value) {
                    if ($item[ $key ] != $value) {
                        $is_ok = false;
                        break;
                    }
                }
                if ($is_ok) {
                    return $item;
                }
            }
        } else {
            foreach ($list as $item) {
                if ($where($item)) {
                    return $item;
                }
            }
        }
        return null;
    }