@param int   $evaluation
@param array $obligations

@return array
342320
public static function getFulfillObligations(int $evaluation, array $obligations): array
    {
        $result = array_key_exists($evaluation, $obligations) === true ? $obligations[$evaluation] : [];

        return $result;
    }
1285907
public function getValue( $variableSet, $evaluationResult, $log )
	{
		$aspect = $variableSet->aspectModel == 'dimensional'
			? ( $this->occ == 'segment' ? ASPECT_NON_XDT_SEGMENT : ASPECT_NON_XDT_SCENARIO )
			: ( $this->occ == 'segment' ? ASPECT_COMPLETE_SEGMENT : ASPECT_COMPLETE_SCENARIO );

		$sourceFact = $variableSet->getSourceFact( $this->source, $evaluationResult, $aspect, $log );
		if ( ! $sourceFact ) return null;
		$contextRef = FactValues::getContextRef( $sourceFact );
		if ( ! $contextRef ) return null;
		$context = $variableSet->xbrlInstance->getContext( $contextRef );
		// $component = isset( $context['entity'][ $this->occ ]['member'] )
		// 	? $context['entity'][ $this->occ ]['member']
		// 	: array();
		$components = array();
		if ( ! $this->select ) return $components;

		$componentNodes = $this->evaluateXPath( $variableSet, "{$this->select}", array( $this->getSourceName() => $sourceFact ) );

		foreach ( $componentNodes as $node )
		{
			if ( ( $this->occ == 'scenario' || $this->occ == 'segment' ) &&
				 $node->getNamespaceURI() == \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDI] )
			{
				$log->formula_validation( "OCC XPath", "The result of the XPath query is not consistent with ",
					array(
						'occ' => $this->occ,
						'xpath' => $this->select,
						'error' => 'xbrlfe:badSubsequentOCCValue'
					)
				);
			}
			$components[] = array( 'name' => $node->getName(), 'member' => '' );
		}

		return $components;
	}
186384
public function getValue( $variableSet, $evaluationResult, $log )
	{
		$numerators = array();
		$denominators = array();
		$unitRef = "";

		// Create a list of numerators and denominators
		if ( $this->augment )
		{
			$this->getFactorsFromSource( $this->source, $variableSet, $evaluationResult, $log, $numerators, $denominators, $unitRef );
		}

		foreach ( $this->multiplyBy as $numerator )
		{
			$hasMeasure = isset( $numerator['measure'] ) && $numerator['measure'];

			if ( ! $hasMeasure && isset( $numerator['source'] ) )
			{
				$this->getFactorsFromSource( $numerator['source'], $variableSet, $evaluationResult, $log, $numerators, $denominators );
			}

			if ( $hasMeasure )
			{
				// This is an expression that needs evaluating
				$result = $this->evaluateXPath( $variableSet, "{$numerator['measure']} cast as xs:string", $evaluationResult['vars'] );
				$numerators[] = $result->getValue();
			}
		}

		foreach ( $this->divideBy as $denominator )
		{
			$hasMeasure = isset( $denominator['measure'] ) && $denominator['measure'];

			if ( ! $hasMeasure && isset( $denominator['source'] ) )
			{
				$this->getFactorsFromSource( $denominator['source'], $variableSet, $evaluationResult, $log, $denominators, $numerators );
			}

			if ( $hasMeasure )
			{
				// This is an expression that needs evaluating
				$result = $this->evaluateXPath( $variableSet, "{$denominator['measure']} cast as xs:string", $evaluationResult['vars'] );
				$denominators[] = $result->getValue();
			}
		}

		// Cancel mutual numerators and denominators
		$this->cancel( $numerators, $denominators );

		// Return an array appropriately structured
		$result = array();
		if ( ! $denominators )
		{
			if ( count( $numerators ) == 1 )
			{
				$result = reset( $numerators );
			}
			else
			{
				$result = array( 'measures' => $numerators );
			}
		}
		else
		{
			$result = array(
				'divide' => array( 'numerator' => $numerators, 'denominator' => $denominators )
			);
		}

		if ( ! $unitRef ) $unitRef = "unit";
		return array( $unitRef => $result );
	}
673432
public static function evaluatePolicy(
        ContextInterface $context,
        int $match,
        array $encodedPolicy,
        ?LoggerInterface $logger
    ): array {
        assert(Encoder::isPolicy($encodedPolicy));
        assert($match !== TargetMatchEnum::NO_TARGET);

        /** @see http://docs.oasis-open.org/xacml/3.0/xacml-3.0-core-spec-os-en.html #7.12 (table 5) */

        // Reminder on obligations and advice (from 7.18)
        //---------------------------------------------------------------------
        // no obligations or advice SHALL be returned to the PEP if the rule,
        // policies, or policy sets from which they are drawn are not evaluated,
        // or if their evaluated result is "Indeterminate" or "NotApplicable",
        // or if the decision resulting from evaluating the rule, policy,
        // or policy set does not match the decision resulting from evaluating
        // an enclosing policy set.

        $policyName = null;
        if ($logger !== null) {
            $policyName = Encoder::policyName($encodedPolicy);
            $matchName  = TargetMatchEnum::toString($match);
            $logger->debug("Policy '$policyName' evaluation started for match '$matchName'.");
        }

        if ($match === TargetMatchEnum::MATCH || $match === TargetMatchEnum::INDETERMINATE) {
            list ($evaluation, $obligations, $advice) = BaseRuleAlgorithm::callRuleAlgorithm(
                $context,
                Encoder::rulesData(Encoder::policyRules($encodedPolicy)),
                $logger
            );

            if ($match === TargetMatchEnum::INDETERMINATE) {
                // evaluate final result in accordance to table 7
                $correctedEvaluation = static::correctEvaluationOnIntermediateTarget($evaluation, $logger);
                $result              = static::packEvaluationResult($correctedEvaluation);
            } else {
                $obligationsMap = Encoder::policyObligations($encodedPolicy);
                $adviceMap      = Encoder::policyAdvice($encodedPolicy);
                $result         = static::packEvaluationResult(
                    $evaluation,
                    static::mergeFulfilledObligations($obligations, $evaluation, $obligationsMap),
                    static::mergeAppliedAdvice($advice, $evaluation, $adviceMap)
                );
            }
        } else {
            assert($match === TargetMatchEnum::NOT_MATCH);
            $result = static::packEvaluationResult(EvaluationEnum::NOT_APPLICABLE);
        }

        $logger === null ?: $logger->debug("Policy '$policyName' evaluation ended.");

        return $result;
    }
836590
public function evaluate($expression, $values=[]) {
        if(is_array($values)) {
            return parent::evaluate($expression, $values);
        } else {
            return $this->parse($expression, $values->getKeys())->getNodes()->evaluate($this->functions, $values);
        }
    }
517198
public function findAttachedBoundaryActivities(VirtualExecution $execution): array
    {
        $model = $execution->getProcessModel();
        $activities = [];
        
        foreach ($model->findNodes() as $node) {
            $behavior = $node->getBehavior();
            
            if ($behavior instanceof AbstractBoundaryActivity) {
                if ($this->activityId == $behavior->getAttachedTo()) {
                    $activities[] = $node;
                }
            }
        }
        
        return $activities;
    }
1222275
public function getInterests(array $interests): array
    {
        $tokens = [];

        foreach ($interests as $interest) {
            $retrieved = $this->repository->retrieve($interest);

            if (!is_null($retrieved)) {
                if(is_string($retrieved)) {
                    $tokens[] = $retrieved;
                }

                if(is_array($retrieved)) {
                    foreach($retrieved as $token) {
                        if(is_string($token)) {
                            $tokens[] = $token;
                        }
                    }
                }
            }
        }

        if (empty($tokens)) {
            throw ExpoRegistrarException::emptyInterests();
        }

        return $tokens;
    }
1189130
public function evaluateExpressions(array $expressions): array
    {
        $res = [];
        foreach ($expressions as $expression) {
            $res[] = $this->evaluateExpression($expression);
        }

        return $res;
    }
1334634
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $context = $flowQuery->getContext();
        if ($context instanceof \Iterator) {
            $context = iterator_to_array($context);
        }
        if (isset($arguments[0]) && isset($arguments[1])) {
            $context = array_slice($context, (integer)$arguments[0], (integer)$arguments[1] - (integer)$arguments[0]);
        } elseif (isset($arguments[0])) {
            $context = array_slice($context, (integer)$arguments[0]);
        }

        $flowQuery->setContext($context);
    }
1245490
public function fetchPairs(string $statement, array $bindings = []): array
    {
        $sth = $this->execute($statement, $bindings);

        $result = $sth->fetchAll(PDO::FETCH_KEY_PAIR);

        $this->freeResource($sth);

        return $result;
    }
476006
public function getTasks($tasks, $throwException = false)
    {
        $data = $this->query($throwException);

        $ret = [];
        foreach ($tasks as $task) {
            $ret[$task->getId()] = $this->formatTask($task, $data);
        }

        return $ret;
    }
1303527
public function setObligations(array $obligations): self
    {
        // check every item is Obligation (debug mode only)
        assert(call_user_func(
            function () use ($obligations) {
                foreach ($obligations as $item) {
                    assert($item instanceof ObligationInterface);
                }
                return true;
            }
        ) === true);

        $this->obligations = $obligations;

        return $this;
    }
574921
public static function getAppliedAdvice(int $evaluation, array $advice): array
    {
        $result = array_key_exists($evaluation, $advice) === true ? $advice[$evaluation] : [];

        return $result;
    }
1131886
public static function fromExpressions(array $expressions, IEvaluationContext $context = null)
    {
        $evaluator            = new self($context);
        $namespace            = $evaluator->context->getNamespace();
        $contextParameterName = self::CONTEXT_PARAMETER_NAME;
        $variableTable        = $evaluator->context->getVariableTable();

        //Replace any non value types with references in the variable table.
        $expressions = (new DynamicExpressionWalker([
                ValueExpression::getType() =>
                        function (ValueExpression $expression) use ($evaluator, $variableTable, &$name) {
                            $value = $expression->getValue();
                            if (!ValueExpression::isValueType($value)) {
                                $name = $name !== null ? $name : 0;
                                do {
                                    $name++;
                                } while (isset($variableTable['o' . $name]));

                                $name                             = 'o' . $name;
                                $evaluator->extraVariables[$name] = $value;

                                return Expression::variable(Expression::value($name));
                            }

                            return $expression;
                        }
        ]))->walkAll($expressions);

        $bodyCode = '';
        foreach ($evaluator->extraVariables + $variableTable as $variable => $value) {
            $variableName = Expression::value($variable);
            $variableCode = Expression::variable($variableName)->compile();
            $bodyCode .= "$variableCode =& $$contextParameterName" . '[' . $variableName->compile() . '];';
        }

        $bodyCode .= "unset($$contextParameterName);";
        $bodyCode .= implode(';', Expression::compileAll($expressions)) . ';';
        $evaluator->code = <<<PHP
namespace {$namespace} {
    return function ($$contextParameterName) {
        $bodyCode
    };
}
PHP;

        $evaluator->initializeEvaluator();

        return $evaluator;
    }
589278
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeAggregateIdentifiers = [];
        if (isset($arguments[0]) && !empty($arguments[0])) {
            $parsedFilter = FizzleParser::parseFilterGroup($arguments[0]);
            if ($this->earlyOptimizationOfFilters($flowQuery, $parsedFilter)) {
                return;
            }
        }

        /** @var TraversableNodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            foreach ($contextNode->findChildNodes() as $childNode) {
                if (!isset($outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()])) {
                    $output[] = $childNode;
                    $outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()] = true;
                }
            }
        }
        $flowQuery->setContext($output);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
999640
protected function getDependencies($dependencies, $params = [], $isRoute = false)
    {
        $resolving = [];

        foreach ($dependencies as $dependency) {
            if ($dependency->isDefaultValueAvailable()) {
                $resolving = $this->getDependencyDefaultValue($dependency, $params, $resolving, $isRoute);
            } elseif(isset($params[$dependency->name])) {
                $resolving[] = $params[$dependency->name];
            } else {
                if ($dependency->getClass() === null) {
                    throw new Exception("The [ $" . "{$dependency->name} ] is not instantiable.");
                }

                $className = $dependency->getClass()->name;

                if (!isset($this->resolved[$className])) {
                    $this->resolved[$className] = $this->make($className);
                    $resolving[] = $this->resolved[$className];
                } else {
                    $resolving[] = $this->resolved[$className];
                }
            }
        }

        return $resolving;
    }
1162042
public function getValue( $variableSet, $evaluationResult, $log )
	{
		$aspect = $variableSet->aspectModel == 'dimensional'
			? ( $this->occ == 'segment' ? ASPECT_NON_XDT_SEGMENT : ASPECT_NON_XDT_SCENARIO )
			: ( $this->occ == 'segment' ? ASPECT_COMPLETE_SEGMENT : ASPECT_COMPLETE_SCENARIO );

		$sourceFact = $variableSet->getSourceFact( $this->source, $evaluationResult, $aspect, $log );
		if ( ! $sourceFact ) return null;
		$contextRef = FactValues::getContextRef( $sourceFact );
		if ( ! $contextRef ) return null;
		$context = $variableSet->xbrlInstance->getContext( $contextRef );
		// $component = isset( $context['entity'][ $this->occ ]['member'] )
		// 	? $context['entity'][ $this->occ ]['member']
		// 	: array();
		$component = array();
		foreach ( $this->occList as $member )
		{
			$component[] = array( 'name' => $member, 'member' => '' );
		}

		return $component;
	}