Apply an rule executes the rule and runs the result proof

@param string 		$rule
@param callback		$callback
@param array 			$params
@return bool
486488
protected function apply_rule( $rule, $callback, $params, $reverse )
	{
		$data_key = array_shift( $params );

		// In case of that the requested data set does not exist
		// we always set the test as failure.
		if ( !array_key_exists( $data_key, $this->data ) )
		{
			return $this->proof_result( $rule, $data_key, ( $reverse ? true : false ) );
		}

		$call_arguments = array( $data_key, $this->data[$data_key] );

		// add the other params to our call parameters
		$call_arguments = array_merge( $call_arguments, $params );

		$result = (bool) call_user_func_array( $callback, $call_arguments );

		if ( $reverse )
		{
			$result = !$result;
		}

		return $this->proof_result( $rule, $data_key, $result );
	}
322590
public function call($callback, array $parameters = array())
    {
        $this->events[] = $event = new CallbackEvent($this->mutex, $callback, $parameters);

        return $event;
    }
58035
protected function _run_rule($rule, &$value, $params, $field)
	{
		if (($rule = $this->_find_rule($rule)) === false)
		{
			return;
		}

		$output = call_fuel_func_array(reset($rule), array_merge(array($value), $params));

		if ($output === false and ($value !== false or key($rule) == 'required'))
		{
			throw new \Validation_Error($field, $value, $rule, $params);
		}
		elseif ($output !== true)
		{
			$value = $output;
		}
	}
510891
public function updateRule($rule) {
        $logger = $GLOBALS['logger'];
        $path    = 'rules/update';
        $request = $this->_remoteServer->put(
            $path,
            array('Content-Type'=>'application/json'),
            $rule
        );
        try {
            $response = $request->send();
            if ($response->getStatusCode() !== 200) {
                throw new \Exception('Unable to handle request');
            }
            $rawResponse = $response->getBody('true');
            return $rawResponse;
        } catch (\Exception $e) {
            throw $e; 
        }
        
    }
384111
public function evaluateRule($rule, $limit = null)
    {
        return $this->rulesEngineProvider->evaluate($rule)->getQueryResults($limit);
    }
644078
public function apply($filter, Closure $callback = null)
    {
        // If the supplied filter is an array then we'll treat it as an array of filters that are
        // to be applied to the resource.
        if (is_array($filter))
        {
            return $this->applyFromArray($filter);
        }

        $filter = $this->factory->get('filter')->make($filter)->setResource($this);

        is_callable($callback) and call_user_func($callback, $filter);

        return $this->filters[$filter->getFilter()] = $filter;
    }
74488
public static function some(array $set, Closure $callback) {
        foreach ($set as $value) {
            if ($callback($value, $value)) {
                return true;
            }
        }

        return false;
    }
805928
public function addValidator($rule, $callback)
    {
        $method = 'validate_'.$rule;

        if (method_exists(__CLASS__, $method) || isset($this->validation_methods[$rule])) {
            throw new Exception("Validator rule '$rule' already exists.");
        }

        $this->validation_methods[$rule] = $callback;

        return $this;
    }
1350117
private function processCallback($callback, $value, $params = [])
    {
        if ($callback) {
            if (is_string($callback)) {
                $callback = [$this->parent, $callback];
            }

            array_unshift($params, $value);
            $value = call_user_func_array($callback, $params);
        }

        return $value;
    }
1205009
protected function runProcess($callback = null)
    {
        $process = $this->processBuilder
            ->setArguments(
                $this->prepareArguments()
            )
            ->getProcess();

        // exit code
        $result = $process->run($callback);

        // text-mode
        if (null === $callback) {
            $result = $process->getOutput();

            if (false === $process->isSuccessful()) {
                $process->getErrorOutput();
            }
        }

        return $result;
    }
141280
function(rule, callback){
        var res = [];
        callback = callback || function(){};
        this.eachGroup(function(item){
            if(rule.group == item.name){
                callback.call(item, item);
                res.push(item);
            }
        });
        return res;
    }
152158
protected function hasRule(array $keyRules, $ruleNames)
    {

        $ruleNames = (array)$ruleNames;

        foreach ($keyRules as $ruleName=>$parameters) {
            if (in_array($ruleName, $ruleNames)) {
                return true;
            }
        }

        return false;
    }
1171949
protected function makeRule($check, $rule): RuleInterface
    {
        $args = $this->parser->parseArgs($rule);
        $message = $this->parser->parseMessage($rule);

        if (!is_array($check)) {
            return new CallableRule($check, $args, $message);
        }

        if (is_string($check[0]) && $this->config->hasChecker($check[0])) {
            $check[0] = $this->config->getChecker($check[0])->resolve($this->factory);

            return new CheckerRule($check[0], $check[1], $args, $message);
        }

        if (!is_object($check[0])) {
            $check[0] = (new Autowire($check[0]))->resolve($this->factory);
        }

        return new CallableRule($check, $args, $message);
    }
383179
protected function reduce($rule)
    {
        list($name, $reduce) = $this->getRule($rule);

        $this->current = null;
        $value = null;

        if ($reduce > 0) {
            $this->states = array_slice($this->states, 0, -$reduce);
            $value = array_slice($this->stack, -$reduce);
            $this->stack = array_slice($this->stack, 0, -$reduce);
        }

        array_unshift($this->queue, $this->createSyntaxNonterminal($name, $value));
    }
596315
protected function executeCallback($callback, $args)
    {
        if (is_string($callback)) {
            return $this->callStringCallback($callback, $args);
        } elseif ($callback instanceof Closure) {
            return call_user_func_array($callback, $args);
        }

        return '';
    }
227217
public static function trigger($condition=true,...$params) {
        //$this->middle(false);
        if ($condition == false) {
            return false;
        }

        return call_user_func_array([get_called_class(),'run'],$params);
    }
1054081
public function addRule(string $name, callable $callback, string $message = null): self
    {
        if ($message === null) {
            $message = static::ERROR_DEFAULT;
        }

        static::assertRuleCallback($callback);

        static::$_rules[$name] = $callback;
        static::$_ruleMessages[$name] = $message;

        return $this;
    }