Formulas/Resources/Formulas/Formula.php
private function getConceptAspectQName( $sourceFact, $evaluationResult, $log )
	{
		// Get the concept name from the source
		if ( is_null( $this->conceptRule ) )
		{
			if ( is_null( $sourceFact ) )
			{
				return null;
			}

			// Make sure the namespace is valid in the instance document and use the instance document prefix if different
			// BMS 2018-03-01 Using the function getPrefixForDocumentNamespace can be a problem because if more than one
			//				  prefix references the same namespace then only the last prefix in the original namespace list
			//				  will be returned.  Instead, look for a namespace for the prefix.  If one exists then the prefix
			//				  is OK.  If not then look up an alternative prefix. Or failing that, add the fact's prefix and
			//				  namespace to the document's namespace collection
			// $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			$namespace = $this->xbrlInstance->getNamespaceForPrefix( $sourceFact->getPrefix() );
			$instancePrefix = $namespace && $namespace == $sourceFact->getNamespaceURI()
				? $instancePrefix = $sourceFact->getPrefix()
				: $this->xbrlInstance->getPrefixForDocumentNamespace( $sourceFact->getNamespaceURI() );
			if ( ! $instancePrefix )
			{
				$this->xbrlInstance->addNamespace( $sourceFact->getPrefix(), $sourceFact->getNamespaceURI() );
				$instancePrefix = $sourceFact->getPrefix();
			}

			return new QName( $instancePrefix, $sourceFact->getNamespaceURI(), $sourceFact->getLocalName() );
		}
		else
		{
			/**
			 * @var Concept $concept
			 */
			$concept = Concept::fromArray( $this->conceptRule );
			// This function will throw an exception if there is a problem so there is no return value to check
			$this->checkSAVConflicts( $concept->source, ASPECT_CONCEPT, $evaluationResult, $log );
			/**
			 * @var QName $conceptQName
			 */
			$conceptQName = $concept->getValue( $this, $evaluationResult, $log );
			// BMS 2018-03-01 See comments above with the same date
			// $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			$namespace = $this->xbrlInstance->getNamespaceForPrefix( $conceptQName->prefix );
			$instancePrefix = $namespace && $namespace == $conceptQName->namespaceURI
				? $instancePrefix = $conceptQName->prefix
				: $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			if ( ! $instancePrefix )
			{
				$this->xbrlInstance->addNamespace( $conceptQName->prefix, $conceptQName->namespaceURI );
				$instancePrefix = $conceptQName->prefix;
			}
			$conceptQName->prefix = $instancePrefix;
			return $conceptQName;
		}

	}
private function getConceptAspectQName( $sourceFact, $evaluationResult, $log )
	{
		// Get the concept name from the source
		if ( is_null( $this->conceptRule ) )
		{
			if ( is_null( $sourceFact ) )
			{
				return null;
			}

			// Make sure the namespace is valid in the instance document and use the instance document prefix if different
			// BMS 2018-03-01 Using the function getPrefixForDocumentNamespace can be a problem because if more than one
			//				  prefix references the same namespace then only the last prefix in the original namespace list
			//				  will be returned.  Instead, look for a namespace for the prefix.  If one exists then the prefix
			//				  is OK.  If not then look up an alternative prefix. Or failing that, add the fact's prefix and
			//				  namespace to the document's namespace collection
			// $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			$namespace = $this->xbrlInstance->getNamespaceForPrefix( $sourceFact->getPrefix() );
			$instancePrefix = $namespace && $namespace == $sourceFact->getNamespaceURI()
				? $instancePrefix = $sourceFact->getPrefix()
				: $this->xbrlInstance->getPrefixForDocumentNamespace( $sourceFact->getNamespaceURI() );
			if ( ! $instancePrefix )
			{
				$this->xbrlInstance->addNamespace( $sourceFact->getPrefix(), $sourceFact->getNamespaceURI() );
				$instancePrefix = $sourceFact->getPrefix();
			}

			return new QName( $instancePrefix, $sourceFact->getNamespaceURI(), $sourceFact->getLocalName() );
		}
		else
		{
			/**
			 * @var Concept $concept
			 */
			$concept = Concept::fromArray( $this->conceptRule );
			// This function will throw an exception if there is a problem so there is no return value to check
			$this->checkSAVConflicts( $concept->source, ASPECT_CONCEPT, $evaluationResult, $log );
			/**
			 * @var QName $conceptQName
			 */
			$conceptQName = $concept->getValue( $this, $evaluationResult, $log );
			// BMS 2018-03-01 See comments above with the same date
			// $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			$namespace = $this->xbrlInstance->getNamespaceForPrefix( $conceptQName->prefix );
			$instancePrefix = $namespace && $namespace == $conceptQName->namespaceURI
				? $instancePrefix = $conceptQName->prefix
				: $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
			if ( ! $instancePrefix )
			{
				$this->xbrlInstance->addNamespace( $conceptQName->prefix, $conceptQName->namespaceURI );
				$instancePrefix = $conceptQName->prefix;
			}
			$conceptQName->prefix = $instancePrefix;
			return $conceptQName;
		}

	}
private function getConceptAspectQName ( $ sourceFact , $ evaluationResult , $ log ) { // Get the concept name from the source
 if ( is_null ( $ this -> conceptRule ) ) { if ( is_null ( $ sourceFact ) ) { return null ; } // Make sure the namespace is valid in the instance document and use the instance document prefix if different
 // BMS 2018-03-01 Using the function getPrefixForDocumentNamespace can be a problem because if more than one
 //				  prefix references the same namespace then only the last prefix in the original namespace list
 //				  will be returned.  Instead, look for a namespace for the prefix.  If one exists then the prefix
 //				  is OK.  If not then look up an alternative prefix. Or failing that, add the fact's prefix and
 //				  namespace to the document's namespace collection
 // $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
 $ namespace = $ this -> xbrlInstance -> getNamespaceForPrefix ( $ sourceFact -> getPrefix ( ) ) ; $ instancePrefix = $ namespace && $ namespace == $ sourceFact -> getNamespaceURI ( ) ? $ instancePrefix = $ sourceFact -> getPrefix ( ) : $ this -> xbrlInstance -> getPrefixForDocumentNamespace ( $ sourceFact -> getNamespaceURI ( ) ) ; if ( ! $ instancePrefix ) { $ this -> xbrlInstance -> addNamespace ( $ sourceFact -> getPrefix ( ) , $ sourceFact -> getNamespaceURI ( ) ) ; $ instancePrefix = $ sourceFact -> getPrefix ( ) ; } return new QName ( $ instancePrefix , $ sourceFact -> getNamespaceURI ( ) , $ sourceFact -> getLocalName ( ) ) ; } else { /**
			 * @var Concept $concept
			 */ $ concept = Concept :: fromArray ( $ this -> conceptRule ) ; // This function will throw an exception if there is a problem so there is no return value to check
 $ this -> checkSAVConflicts ( $ concept -> source , ASPECT_CONCEPT , $ evaluationResult , $ log ) ; /**
			 * @var QName $conceptQName
			 */ $ conceptQName = $ concept -> getValue ( $ this , $ evaluationResult , $ log ) ; // BMS 2018-03-01 See comments above with the same date
 // $instancePrefix =  $this->xbrlInstance->getPrefixForDocumentNamespace( $conceptQName->namespaceURI );
 $ namespace = $ this -> xbrlInstance -> getNamespaceForPrefix ( $ conceptQName -> prefix ) ; $ instancePrefix = $ namespace && $ namespace == $ conceptQName -> namespaceURI ? $ instancePrefix = $ conceptQName -> prefix : $ this -> xbrlInstance -> getPrefixForDocumentNamespace ( $ conceptQName -> namespaceURI ) ; if ( ! $ instancePrefix ) { $ this -> xbrlInstance -> addNamespace ( $ conceptQName -> prefix , $ conceptQName -> namespaceURI ) ; $ instancePrefix = $ conceptQName -> prefix ; } $ conceptQName -> prefix = $ instancePrefix ; return $ conceptQName ; } }
Get the concept to be used for this fact.  If a concept rule does not exist, use the formula source value
@param DOMXPathNavigator $sourceFact
@param array $evaluationResult
@param \XBRL_Log $log
@return QName|NULL
Get the concept to be used for this fact . If a concept rule does not exist use the formula source value