Formulas/Resources/Assertions/ExistenceAssertion.php
private function evaluationInternal( $exists )
	{
		// \XBRL_Log::getInstance()->info( "Process existence assertion" );

		// Although I cannot find any reference to it in the documentation, it seems that only unique derived facts
		// should be compared.  Uniquenesss in this case appears to be derived facts that have the same contributing variables.
		// Conformance test 34120 V-13 has this issue.  In this test there are 7 facts produced but 1 is a duplicates.
		// The TupleDictionary works well for this scenario
		if ( ! $this->pastEvaluationHashes ) $this->pastEvaluationHashes = new \TupleDictionary();

		$vars = $this->getBindingsAsVars();
		$varsCopy = $vars;
		foreach ( $varsCopy as $name => /** @var DOMXPathNavigator $var */ $var )
		{
			$varsCopy[ $name ] = $var instanceof DOMXPathNavigator
				? $var->getUnderlyingObject()->getNodePath()
				: ( $var instanceof Undefined
						? ""
						: ( is_object( $var ) ?  $var->getTypedValue() : $var ) );
		}

		if ( $this->pastEvaluationHashes->exists( $varsCopy ) )
		{
			return;
		}

		$this->pastEvaluationHashes->addValue( $varsCopy, 1 );

		$evaluationResult = array( 'vars' => $vars, 'lastFactBinding' => $this->getLastFactBinding() );
		$evaluationResult['uncoveredAspectFacts'] = $evaluationResult['lastFactBinding'] instanceof FactVariableBinding
			? $evaluationResult['lastFactBinding']->uncoveredAspectFacts
			: array();

		if ( ! $exists )
		{
			$this->notSatisfied[] = $evaluationResult;
			return;
		}

		try
		{
			// Check all variables are not all fallback and that preconditions are met
			if ( ! parent::evaluateResult() )
			{
				throw new \Exception();
			}

		}
		catch( \Exception $ex )
		{
			$this->notSatisfied[] = $evaluationResult;
			return;
		}

		$this->satisfied[] = $evaluationResult;

	}
private function evaluationInternal( $exists )
	{
		// \XBRL_Log::getInstance()->info( "Process existence assertion" );

		// Although I cannot find any reference to it in the documentation, it seems that only unique derived facts
		// should be compared.  Uniquenesss in this case appears to be derived facts that have the same contributing variables.
		// Conformance test 34120 V-13 has this issue.  In this test there are 7 facts produced but 1 is a duplicates.
		// The TupleDictionary works well for this scenario
		if ( ! $this->pastEvaluationHashes ) $this->pastEvaluationHashes = new \TupleDictionary();

		$vars = $this->getBindingsAsVars();
		$varsCopy = $vars;
		foreach ( $varsCopy as $name => /** @var DOMXPathNavigator $var */ $var )
		{
			$varsCopy[ $name ] = $var instanceof DOMXPathNavigator
				? $var->getUnderlyingObject()->getNodePath()
				: ( $var instanceof Undefined
						? ""
						: ( is_object( $var ) ?  $var->getTypedValue() : $var ) );
		}

		if ( $this->pastEvaluationHashes->exists( $varsCopy ) )
		{
			return;
		}

		$this->pastEvaluationHashes->addValue( $varsCopy, 1 );

		$evaluationResult = array( 'vars' => $vars, 'lastFactBinding' => $this->getLastFactBinding() );
		$evaluationResult['uncoveredAspectFacts'] = $evaluationResult['lastFactBinding'] instanceof FactVariableBinding
			? $evaluationResult['lastFactBinding']->uncoveredAspectFacts
			: array();

		if ( ! $exists )
		{
			$this->notSatisfied[] = $evaluationResult;
			return;
		}

		try
		{
			// Check all variables are not all fallback and that preconditions are met
			if ( ! parent::evaluateResult() )
			{
				throw new \Exception();
			}

		}
		catch( \Exception $ex )
		{
			$this->notSatisfied[] = $evaluationResult;
			return;
		}

		$this->satisfied[] = $evaluationResult;

	}
private function evaluationInternal ( $ exists ) { // \XBRL_Log::getInstance()->info( "Process existence assertion" );
 // Although I cannot find any reference to it in the documentation, it seems that only unique derived facts
 // should be compared.  Uniquenesss in this case appears to be derived facts that have the same contributing variables.
 // Conformance test 34120 V-13 has this issue.  In this test there are 7 facts produced but 1 is a duplicates.
 // The TupleDictionary works well for this scenario
 if ( ! $ this -> pastEvaluationHashes ) $ this -> pastEvaluationHashes = new \ TupleDictionary ( ) ; $ vars = $ this -> getBindingsAsVars ( ) ; $ varsCopy = $ vars ; foreach ( $ varsCopy as $ name => /** @var DOMXPathNavigator $var */ $ var ) { $ varsCopy [ $ name ] = $ var instanceof DOMXPathNavigator ? $ var -> getUnderlyingObject ( ) -> getNodePath ( ) : ( $ var instanceof Undefined ? "" : ( is_object ( $ var ) ? $ var -> getTypedValue ( ) : $ var ) ) ; } if ( $ this -> pastEvaluationHashes -> exists ( $ varsCopy ) ) { return ; } $ this -> pastEvaluationHashes -> addValue ( $ varsCopy , 1 ) ; $ evaluationResult = array ( 'vars' => $ vars , 'lastFactBinding' => $ this -> getLastFactBinding ( ) ) ; $ evaluationResult [ 'uncoveredAspectFacts' ] = $ evaluationResult [ 'lastFactBinding' ] instanceof FactVariableBinding ? $ evaluationResult [ 'lastFactBinding' ] -> uncoveredAspectFacts : array ( ) ; if ( ! $ exists ) { $ this -> notSatisfied [ ] = $ evaluationResult ; return ; } try { // Check all variables are not all fallback and that preconditions are met
 if ( ! parent :: evaluateResult ( ) ) { throw new \ Exception ( ) ; } } catch ( \ Exception $ ex ) { $ this -> notSatisfied [ ] = $ evaluationResult ; return ; } $ this -> satisfied [ ] = $ evaluationResult ; }
Common function for evaluation
@param bool $exists
@return void
@throws \Exception
Common function for evaluation