@param $cmd string
@param $filter callback|NULL

@return string[]|NULL
@throws ShellException
188320
protected function extractFromCommand($cmd, $filter = null) {
		$output = [];
		$exitCode = null;
		$this->begin();
		exec("$cmd", $output, $exitCode);
		$this->end();
		if(/*$exitCode !== 0 || */!is_array($output)) {
			throw new ShellException("Command $cmd failed.");
		}
		/** @var string $filter */
		if($filter !== null) {
			$newArray = [];
			foreach($output as $line) {
				$value = $filter($line);
				if($value === false) {
					continue;
				}
				$newArray[] = $value;
			}
			$output = $newArray;
		}
		if(!isset($output[0])) // empty array
		{
			return null;
		}
		return $output;
	}
1154389
protected function prepareFilter(array $filter)
    {
        foreach ($filter as $code => &$value) {
            if ($code === 'id') {
                intval($value);

                if ($value <= 0) {
                    throw new ArgumentNullException($code);
                }
            } elseif ($code === 'base') {

                if (!is_bool($value)) {
                    throw new ArgumentNullException($code);
                }

            } else {
                trim(htmlspecialchars($value));

                if (strlen($value) <= 0) {
                    throw new ArgumentNullException($code);
                }
            }
        }

        return $filter;
    }
665520
public static syslog_ui_cmd[] get_filtered(nitro_service service, String filter) throws Exception
	{
		syslog_ui_cmd obj = new syslog_ui_cmd();
		options option = new options();
		option.set_filter(filter);
		syslog_ui_cmd[] response = (syslog_ui_cmd[]) obj.getfiltered(service, option);
		return response;
	}
1166091
public function getServices($filter = null)
	{
		$services = array();

		// Create the request
		$request = new client\Request('/api/mpegts/service/grid');

		if ($filter)
			$request->setFilter($filter);

		// Get the response
		$response = $this->_client->getResponse($request);
		$rawContent = $response->getContent();

		$content = json_decode($rawContent);

		foreach ($content->entries as $entry)
			$services[] = model\Service::fromRawEntry($entry);

		return $services;
	}
993870
public function getHlblocks($filter = array()) {
        $dbres = HL\HighloadBlockTable::getList(
            array(
                'select' => array('*'),
                'filter' => $filter,
            )
        );

        $result = [];
        while ($hlblock = $dbres->fetch()) {
            $hlblock['LANG'] = $this->getHblockLangs($hlblock['ID']);
            $result[] = $hlblock;
        }

        return $result;
    }
275124
protected function filter(UpdateIncidentCommand $command)
    {
        $params = [
            'name'             => $command->name,
            'status'           => $command->status,
            'message'          => $command->message,
            'visible'          => $command->visible,
            'stickied'         => $command->stickied,
            'component_id'     => $command->component_id,
            'component_status' => $command->component_status,
            'notify'           => $command->notify,
        ];

        return array_filter($params, function ($val) {
            return $val !== null;
        });
    }
834269
public static function getOptions($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/options' . $filter->toQuery(), 'Option');
    }
879850
public function subCommands($commandName)
    {
        $Shell = $this->getShell($commandName);

        if (!$Shell) {
            return [];
        }

        $taskMap = $this->Tasks->normalizeArray((array)$Shell->tasks);
        $return = array_keys($taskMap);
        $return = array_map('Cake\Utility\Inflector::underscore', $return);

        $shellMethodNames = ['main', 'help', 'getOptionParser', 'initialize', 'runCommand'];

        $baseClasses = ['Object', 'Shell', 'AppShell'];

        $Reflection = new ReflectionClass($Shell);
        $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC);
        $methodNames = [];
        foreach ($methods as $method) {
            $declaringClass = $method->getDeclaringClass()->getShortName();
            if (!in_array($declaringClass, $baseClasses)) {
                $methodNames[] = $method->getName();
            }
        }

        $return = array_merge($return, array_diff($methodNames, $shellMethodNames));
        sort($return);

        return $return;
    }
585427
private function tempFilters($filter)
    {
        $f = $filter[1];
        $elements = explode('\'', $f);

        // Hack to make "dot" works on filters
        for ($i=0, $m=0; $i<count($elements); $i++) {
            if ($m%2 == 0) {
                if ($i > 0 && substr($elements[$i-1], 0, 1) == '\\') {
                    continue;
                }

                $e = explode('.', $elements[$i]);
                $str = ''; $first = true;
                foreach ($e as $substr) {
                    if ($first) {
                        $str = $substr;
                        $first = false;
                        continue;
                    }

                    $end = null;
                    if (false !== $pos = $this->strpos_array($substr, $this->keywords)) {
                        list($substr, $end) = array(substr($substr, 0, $pos), substr($substr, $pos, strlen($substr)));
                    }

                    $str .= '[' . $substr . ']';
                    if (null !== $end) {
                        $str .= $end;
                    }
                }
                $elements[$i] = $str;
            }

            $m++;
        }

        return "[#" . (array_push($this->result, implode('\'', $elements)) - 1) . "]";
    }
262819
private static function determineFilterInOrNotInList(array $filter, QueryBuilder $queryBuilder)
    {
        if (!\in_array($filter['operation'], ['IN', 'NOT IN'])) {
            return null;
        }

        return static::filterInOrNotInList($filter, $queryBuilder);
    }
737165
protected function getPredicatesFromFilterCondition($filter)
    {
        $predicates = [];
        $regex = "/(^|\b)(\w+\:\w+)\.(l|u)(\b|$)/";
        foreach($filter as $key=>$condition)
        {
            if(is_string($key))
            {
                $numMatches = preg_match_all($regex, $key, $matches);
                for($i = 0; $i < $numMatches; $i++)
                {
                    if(isset($matches[2][$i]))
                    {
                        $predicates[] = $matches[2][$i];
                    }
                }
            }
            if(is_string($condition))
            {
                $numMatches = preg_match_all($regex, $condition, $matches);
                for($i = 0; $i < $numMatches; $i++)
                {
                    if(isset($matches[2][$i]))
                    {
                        $predicates[] = $matches[2][$i];
                    }
                }
            }
            elseif(is_array($condition))
            {
                array_merge($predicates, $this->getPredicatesFromFilterCondition($condition));
            }
        }
        return $predicates;
    }
417549
public function findQuery($cmd) {
        foreach ($cmd as $backend => $val)
            if (preg_match('/'.$backend.'/', $this->db->driver()))
                return $val;
        trigger_error(sprintf('DB Engine `%s` is not supported for this action.', $this->db->driver()),E_USER_ERROR);
    }
33073
protected function getFilterParams(array &$filters, $filter)
    {
        $fragments = preg_split('%;%', $filter, -1, PREG_SPLIT_NO_EMPTY);

        $name = array_shift($fragments);
        $params = [];

        foreach ($fragments as $param) {
            list($key, $value)  = explode('=', $param);
            $params[$key] = $value;
        }

        $filters[$name] = $params;
    }
591614
public function getComments($filter = null)
    {
        $comments = $this->comments;

        if ($filter !== null) {
            $comments = array_filter($comments, function ($c) use ($filter) {
                return $c['context'] == $filter;
            });
        }

        return $comments;
    }
1030890
private static function get_filter_callbacks( $filter ) {
		global $wp_filter;

		if ( ! isset( $wp_filter[ $filter ] ) ) {
			return false;
		}

		if ( is_a( $wp_filter[ $filter ], 'WP_Hook' ) ) {
			$callbacks = $wp_filter[ $filter ]->callbacks;
		} else {
			$callbacks = $wp_filter[ $filter ];
		}
		if ( is_array( $callbacks ) ) {
			return $callbacks;
		}
		return false;
	}
1200460
public function getMethods($filter = -1)
    {
        $return = parent::getMethods($filter);
        foreach ($return as $key => $val) {
            $return[$key] = new ReflectionMethod($this->getName(), $val->getName());
        }

        return $return;
    }
1290465
public function getParamsWithout($filter)
    {
        // Convert $filter to array if necessary
        if (!is_array($filter)) {
            $filter = preg_split("/, */", $filter, -1, PREG_SPLIT_NO_EMPTY);
        }

        $params = array_keys($this->getParams());
        $filter = array_merge(array_diff($params, $filter), array_diff($filter, $params));

        return $this->getParamsWith($filter);
    }