repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
bseddon/XBRL
XBRL-QName.php
QNamex.toArray
public function toArray() { $result = array( 'localname' => $this->localName ); if ( isset( $this->prefix ) ) array( 'prefix' => $this->prefix ); if ( isset( $this->namespaceURI ) ) array( 'namespace' => $this->namespaceURI ); return $result; }
php
public function toArray() { $result = array( 'localname' => $this->localName ); if ( isset( $this->prefix ) ) array( 'prefix' => $this->prefix ); if ( isset( $this->namespaceURI ) ) array( 'namespace' => $this->namespaceURI ); return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "array", "(", "'localname'", "=>", "$", "this", "->", "localName", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "prefix", ")", ")", "array", "(", "'prefix'", "=>", "$", "t...
Convert the QName to an array
[ "Convert", "the", "QName", "to", "an", "array" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-QName.php#L520-L526
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.setConceptualModelRoles
public static function setConceptualModelRoles( $taxonomy = null ) { $cmTaxonomy = $taxonomy ? $taxonomy->getTaxonomyForXSD("cm.xsd") : null; if ( $cmTaxonomy ) { $nonDimensionalRoleRef = $cmTaxonomy->getNonDimensionalRoleRefs( XBRL_Constants::$defaultLinkRole ); if ( isset( $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ] ) ) { $cmArcRoles = $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ]; self::$conceptualModelRoles = $cmArcRoles; return; } } // Fallback self::$conceptualModelRoles = self::$defaultConceptualModelRoles; }
php
public static function setConceptualModelRoles( $taxonomy = null ) { $cmTaxonomy = $taxonomy ? $taxonomy->getTaxonomyForXSD("cm.xsd") : null; if ( $cmTaxonomy ) { $nonDimensionalRoleRef = $cmTaxonomy->getNonDimensionalRoleRefs( XBRL_Constants::$defaultLinkRole ); if ( isset( $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ] ) ) { $cmArcRoles = $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ]; self::$conceptualModelRoles = $cmArcRoles; return; } } // Fallback self::$conceptualModelRoles = self::$defaultConceptualModelRoles; }
[ "public", "static", "function", "setConceptualModelRoles", "(", "$", "taxonomy", "=", "null", ")", "{", "$", "cmTaxonomy", "=", "$", "taxonomy", "?", "$", "taxonomy", "->", "getTaxonomyForXSD", "(", "\"cm.xsd\"", ")", ":", "null", ";", "if", "(", "$", "cmT...
Sets some model roles if there are any in the taxonomy or sets the default model roles @param XBRL $taxonomy A taxonomy to use or null
[ "Sets", "some", "model", "roles", "if", "there", "are", "any", "in", "the", "taxonomy", "or", "sets", "the", "default", "model", "roles" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L98-L115
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.supportedFeatures
public function supportedFeatures( $feature = null ) { return $feature ? ( isset( $this->features[ $feature ] ) ? $this->features[ $feature ] : array() ) : $this->featrues; }
php
public function supportedFeatures( $feature = null ) { return $feature ? ( isset( $this->features[ $feature ] ) ? $this->features[ $feature ] : array() ) : $this->featrues; }
[ "public", "function", "supportedFeatures", "(", "$", "feature", "=", "null", ")", "{", "return", "$", "feature", "?", "(", "isset", "(", "$", "this", "->", "features", "[", "$", "feature", "]", ")", "?", "$", "this", "->", "features", "[", "$", "feat...
Gets an array containing a list of extra features supported usually by descendent implementation @param string $feature (optional) If supplied just the array for the feature is returned or all features. If supplied and not found an empty array is returned @return array By default there are no additional features so the array is empty
[ "Gets", "an", "array", "containing", "a", "list", "of", "extra", "features", "supported", "usually", "by", "descendent", "implementation" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L261-L266
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.renderPresentationNetworks
public function renderPresentationNetworks( $networks, $instance, $formulas, $observer, $evaluationResults, $echo = true ) { $result = array(); foreach ( $networks as $elr => $network ) { // error_log( $elr ); $result[ $elr ] = array( 'entities' => $this->renderPresentationNetwork( $network, $elr, $instance, $formulas, $observer, $evaluationResults, $echo ), 'text' => $networks[ $elr ]['text'] ); } return $result; }
php
public function renderPresentationNetworks( $networks, $instance, $formulas, $observer, $evaluationResults, $echo = true ) { $result = array(); foreach ( $networks as $elr => $network ) { // error_log( $elr ); $result[ $elr ] = array( 'entities' => $this->renderPresentationNetwork( $network, $elr, $instance, $formulas, $observer, $evaluationResults, $echo ), 'text' => $networks[ $elr ]['text'] ); } return $result; }
[ "public", "function", "renderPresentationNetworks", "(", "$", "networks", ",", "$", "instance", ",", "$", "formulas", ",", "$", "observer", ",", "$", "evaluationResults", ",", "$", "echo", "=", "true", ")", "{", "$", "result", "=", "array", "(", ")", ";"...
Renders an evidence package for a set of networks @param array $networks @param XBRL_Instance $instance @param XBRL_Formulas $formulas @param Observer $observer @param bool $echo @return array
[ "Renders", "an", "evidence", "package", "for", "a", "set", "of", "networks" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L296-L310
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.findConceptInFormula
private function findConceptInFormula( &$formulasForELR, $taxonomy, $element ) { if ( ! $formulasForELR ) return false; $conceptClark = "{" . $taxonomy->getNamespace() . "}" . $element['name']; foreach ( $formulasForELR as $variableSet ) { foreach ( $variableSet->variablesByQName as $qname => $variable ) { if ( ! $variable instanceof FactVariable ) continue; foreach ( $variable->filters as $x => $filter ) { if ( ! $filter instanceof ConceptName ) continue; foreach ( $filter->qnames as $clark ) { if ( $clark == $conceptClark ) return true;; } } } } return false; }
php
private function findConceptInFormula( &$formulasForELR, $taxonomy, $element ) { if ( ! $formulasForELR ) return false; $conceptClark = "{" . $taxonomy->getNamespace() . "}" . $element['name']; foreach ( $formulasForELR as $variableSet ) { foreach ( $variableSet->variablesByQName as $qname => $variable ) { if ( ! $variable instanceof FactVariable ) continue; foreach ( $variable->filters as $x => $filter ) { if ( ! $filter instanceof ConceptName ) continue; foreach ( $filter->qnames as $clark ) { if ( $clark == $conceptClark ) return true;; } } } } return false; }
[ "private", "function", "findConceptInFormula", "(", "&", "$", "formulasForELR", ",", "$", "taxonomy", ",", "$", "element", ")", "{", "if", "(", "!", "$", "formulasForELR", ")", "return", "false", ";", "$", "conceptClark", "=", "\"{\"", ".", "$", "taxonomy"...
Look for a concept in each formula's filter @param array $formulasForELR (ref) Array of formulas defined for the ELR @param XBRL_DFR $taxonomy @param array $element @return boolean
[ "Look", "for", "a", "concept", "in", "each", "formula", "s", "filter" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L703-L726
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.fixupFormulas
public function fixupFormulas() { // Find the class-equivalentClass arc role(s) $taxonomies = $this->context->getTaxonomiesWithArcRoleTypeId('class-equivalentClass'); $arcRoles = array_map( function( /** @var XBRL $taxonomy */ $taxonomy ) { $arcRole = $taxonomy->getArcRoleTypeForId( 'class-equivalentClass' ); if ( ! $arcRole ) return ''; return str_replace( 'link:definitionArc/', '', $arcRole ); }, $taxonomies ); if ( ! $arcRoles ) return; $nonDimensionalRoleRef = $this->getNonDimensionalRoleRefs(); $classEquivalents = null; foreach ( $arcRoles as $arcRole ) { if ( ! isset( $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ] ) ) continue; $classEquivalents = $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ]; break; } if ( ! $classEquivalents ) return; foreach ( $this->getImportedSchemas() as $label => $taxonomy ) { if ( ! $taxonomy->getHasFormulas() ) continue; $resources = $taxonomy->getGenericResource('filter', 'conceptName' ); if ( ! $resources ) continue; $baseTaxonomy = null; // $this->getBaseTaxonomy() ? $this->getTaxonomyForXSD( $this->getBaseTaxonomy() ) : null; foreach ( $classEquivalents['arcs'] as $fac => $gaaps ) { $facTaxonomy = $this->getTaxonomyForXSD( $fac ); if ( ! $facTaxonomy ) continue; $facElement = $facTaxonomy->getElementById( $fac ); if ( ! $facElement ) continue; $facClark = "{{$facTaxonomy->getNamespace()}}{$facElement['name']}"; foreach ( $resources as $resource ) { $changed = false; foreach ( $resource['filter']['qnames'] as $qnIndex => $qname ) { if ( $qname != $facClark ) continue; foreach ( $gaaps as $gaapLabel => $gaap ) { $gaapTaxonomy = $this->getTaxonomyForXSD( $gaapLabel ); if ( ! $gaapTaxonomy ) continue; $gaapElement = $gaapTaxonomy->getElementById( $gaapLabel ); if ( ! $gaapElement ) continue; // $gaapClark = "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}"; $gaapClark = $baseTaxonomy ? "{{$baseTaxonomy->getNamespace()}}{$gaapElement['name']}" : "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}"; echo "{$resource['linkbase']} - {$resource['resourceName']}: from $facClark to $gaapClark\n"; //$taxonomy->genericRoles['roles'] // [ $resource['roleUri'] ] // ['resources'] // [ $resource['linkbase'] ] // [ $resource['resourceName'] ] // [ $resource['index'] ]['qnames'][ $qnIndex ] = $gaapClark; if ( $resource['filter']['qnames'][ $qnIndex ] == $facClark ) { $resource['filter']['qnames'][ $qnIndex ] = $gaapClark; } else { $resource['filter']['qnames'][] = $gaapClark; } $changed = true; } } if ( $changed ) { $taxonomy->updateGenericResource( $resource['roleUri'], $resource['linkbase'], $resource['resourceName'], $resource['index'], $resource['filter'] ); } } } } }
php
public function fixupFormulas() { // Find the class-equivalentClass arc role(s) $taxonomies = $this->context->getTaxonomiesWithArcRoleTypeId('class-equivalentClass'); $arcRoles = array_map( function( /** @var XBRL $taxonomy */ $taxonomy ) { $arcRole = $taxonomy->getArcRoleTypeForId( 'class-equivalentClass' ); if ( ! $arcRole ) return ''; return str_replace( 'link:definitionArc/', '', $arcRole ); }, $taxonomies ); if ( ! $arcRoles ) return; $nonDimensionalRoleRef = $this->getNonDimensionalRoleRefs(); $classEquivalents = null; foreach ( $arcRoles as $arcRole ) { if ( ! isset( $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ] ) ) continue; $classEquivalents = $nonDimensionalRoleRef[ XBRL_Constants::$defaultLinkRole ][ $arcRole ]; break; } if ( ! $classEquivalents ) return; foreach ( $this->getImportedSchemas() as $label => $taxonomy ) { if ( ! $taxonomy->getHasFormulas() ) continue; $resources = $taxonomy->getGenericResource('filter', 'conceptName' ); if ( ! $resources ) continue; $baseTaxonomy = null; // $this->getBaseTaxonomy() ? $this->getTaxonomyForXSD( $this->getBaseTaxonomy() ) : null; foreach ( $classEquivalents['arcs'] as $fac => $gaaps ) { $facTaxonomy = $this->getTaxonomyForXSD( $fac ); if ( ! $facTaxonomy ) continue; $facElement = $facTaxonomy->getElementById( $fac ); if ( ! $facElement ) continue; $facClark = "{{$facTaxonomy->getNamespace()}}{$facElement['name']}"; foreach ( $resources as $resource ) { $changed = false; foreach ( $resource['filter']['qnames'] as $qnIndex => $qname ) { if ( $qname != $facClark ) continue; foreach ( $gaaps as $gaapLabel => $gaap ) { $gaapTaxonomy = $this->getTaxonomyForXSD( $gaapLabel ); if ( ! $gaapTaxonomy ) continue; $gaapElement = $gaapTaxonomy->getElementById( $gaapLabel ); if ( ! $gaapElement ) continue; // $gaapClark = "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}"; $gaapClark = $baseTaxonomy ? "{{$baseTaxonomy->getNamespace()}}{$gaapElement['name']}" : "{{$gaapTaxonomy->getNamespace()}}{$gaapElement['name']}"; echo "{$resource['linkbase']} - {$resource['resourceName']}: from $facClark to $gaapClark\n"; //$taxonomy->genericRoles['roles'] // [ $resource['roleUri'] ] // ['resources'] // [ $resource['linkbase'] ] // [ $resource['resourceName'] ] // [ $resource['index'] ]['qnames'][ $qnIndex ] = $gaapClark; if ( $resource['filter']['qnames'][ $qnIndex ] == $facClark ) { $resource['filter']['qnames'][ $qnIndex ] = $gaapClark; } else { $resource['filter']['qnames'][] = $gaapClark; } $changed = true; } } if ( $changed ) { $taxonomy->updateGenericResource( $resource['roleUri'], $resource['linkbase'], $resource['resourceName'], $resource['index'], $resource['filter'] ); } } } } }
[ "public", "function", "fixupFormulas", "(", ")", "{", "// Find the class-equivalentClass arc role(s)\r", "$", "taxonomies", "=", "$", "this", "->", "context", "->", "getTaxonomiesWithArcRoleTypeId", "(", "'class-equivalentClass'", ")", ";", "$", "arcRoles", "=", "array_...
If there are class-equivalent arcs check all formula filters to see if they need to be updated
[ "If", "there", "are", "class", "-", "equivalent", "arcs", "check", "all", "formula", "filters", "to", "see", "if", "they", "need", "to", "be", "updated" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L731-L822
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.renderComponentTable
private function renderComponentTable( $network, $elr ) { $table = $this->getTaxonomyDescriptionForIdWithDefaults( reset( $network['tables'] ) ); $componentTable = " <div class='component-table'>" . " <div class='ct-header'>Component: Network plus Table</div>" . " <div class='ct-body'>" . " <div class='ct-body-header network'>Network</div>" . " <div class='ct-body-content network'>" . " <div>{$network['text']}</div>" . " <div>$elr</div>" . " </div>" . " <div class='ct-body-header hypercube'>Table</div>" . " <div class='ct-body-content hypercube'>$table</div>" . " </div>" . " </div>"; return $componentTable; }
php
private function renderComponentTable( $network, $elr ) { $table = $this->getTaxonomyDescriptionForIdWithDefaults( reset( $network['tables'] ) ); $componentTable = " <div class='component-table'>" . " <div class='ct-header'>Component: Network plus Table</div>" . " <div class='ct-body'>" . " <div class='ct-body-header network'>Network</div>" . " <div class='ct-body-content network'>" . " <div>{$network['text']}</div>" . " <div>$elr</div>" . " </div>" . " <div class='ct-body-header hypercube'>Table</div>" . " <div class='ct-body-content hypercube'>$table</div>" . " </div>" . " </div>"; return $componentTable; }
[ "private", "function", "renderComponentTable", "(", "$", "network", ",", "$", "elr", ")", "{", "$", "table", "=", "$", "this", "->", "getTaxonomyDescriptionForIdWithDefaults", "(", "reset", "(", "$", "network", "[", "'tables'", "]", ")", ")", ";", "$", "co...
Renders the component table @param array $network @param string $elr @return string
[ "Renders", "the", "component", "table" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L1474-L1493
train
bseddon/XBRL
XBRL-DFR.php
XBRL_DFR.renderSlicers
private function renderSlicers( $network, $entityQName ) { $slicers = " <div>" . " <div>Slicers</div>" . " <div class='slicers'>" . " <div class='slicer-header'>Reporting Entity [Axis]</div>" . " <div class='slicer-content'>{$entityQName->localName} ({$entityQName->namespaceURI})</div>"; foreach ( $network['axes'] as $label => $axis) { if ( ! isset( $axis['dimension'] ) ) continue; if ( count( $axis['members'] ) > 1 ) continue; $memberLabel = key($axis['members'] ); if ( isset( $network['axes'][ $memberLabel ] ) ) continue; $dimension = $this->getTaxonomyDescriptionForIdWithDefaults( $label ); $slicers .= " <div class='slicer-header'>$dimension</div>"; /** @var QName $memberQName */ $memberQName = reset( $axis['members'] ); $memberTaxonomy = $this->getTaxonomyForNamespace( $memberQName->namespaceURI ); $memberElement = $memberTaxonomy->getElementByName( $memberQName->localName ); $member = $this->getTaxonomyDescriptionForIdWithDefaults( $memberTaxonomy->getTaxonomyXSD() . "#" . $memberElement['id'] ); $slicers .= " <div class='slicer-content'>$member</div>"; } $slicers .= " </div>" . " </div>"; return $slicers; }
php
private function renderSlicers( $network, $entityQName ) { $slicers = " <div>" . " <div>Slicers</div>" . " <div class='slicers'>" . " <div class='slicer-header'>Reporting Entity [Axis]</div>" . " <div class='slicer-content'>{$entityQName->localName} ({$entityQName->namespaceURI})</div>"; foreach ( $network['axes'] as $label => $axis) { if ( ! isset( $axis['dimension'] ) ) continue; if ( count( $axis['members'] ) > 1 ) continue; $memberLabel = key($axis['members'] ); if ( isset( $network['axes'][ $memberLabel ] ) ) continue; $dimension = $this->getTaxonomyDescriptionForIdWithDefaults( $label ); $slicers .= " <div class='slicer-header'>$dimension</div>"; /** @var QName $memberQName */ $memberQName = reset( $axis['members'] ); $memberTaxonomy = $this->getTaxonomyForNamespace( $memberQName->namespaceURI ); $memberElement = $memberTaxonomy->getElementByName( $memberQName->localName ); $member = $this->getTaxonomyDescriptionForIdWithDefaults( $memberTaxonomy->getTaxonomyXSD() . "#" . $memberElement['id'] ); $slicers .= " <div class='slicer-content'>$member</div>"; } $slicers .= " </div>" . " </div>"; return $slicers; }
[ "private", "function", "renderSlicers", "(", "$", "network", ",", "$", "entityQName", ")", "{", "$", "slicers", "=", "\"\t<div>\"", ".", "\"\t\t<div>Slicers</div>\"", ".", "\"\t\t<div class='slicers'>\"", ".", "\"\t\t\t<div class='slicer-header'>Reporting Entity [Axis]</div>\...
Renders the slicers table @param array $network @param QName $entityQName @return string
[ "Renders", "the", "slicers", "table" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-DFR.php#L1612-L1645
train
bseddon/XBRL
Formulas/Resources/Assertions/ExistenceAssertion.php
ExistenceAssertion.validate
public function validate( $variableSet, $nsMgr ) { if ( ! $this->test ) return true; try { $expression = XPath2Expression::Compile( $this->test, $nsMgr ); $this->testXPath2Expression = $expression; $variableRefs = $this->getVariableRefs(); foreach ( $variableRefs as $qname => $variableRef ) { // Look for general or fact variables with this qname if ( isset( $this->variablesByQName[ (string)$variableRef ] ) ) { \XBRL_Log::getInstance()->existenceassertion_validation( "Existent assertion", "An existance assertion test cannot reference fact or general variables", array( 'label' => $this->label, 'error' => 'xbrleae:variableReferenceNotAllowed' ) ); } } return true; } catch ( Exception $ex ) { \XBRL_Log::getInstance()->valueassertion_validation( "Value assertion", "Failed to compile test expression", array( 'test expression' => $this->test, 'error' => $ex instanceof XPath2Exception ? $ex->ErrorCode : get_class( $ex ), 'reason' => $ex->getMessage() ) ); return false; } }
php
public function validate( $variableSet, $nsMgr ) { if ( ! $this->test ) return true; try { $expression = XPath2Expression::Compile( $this->test, $nsMgr ); $this->testXPath2Expression = $expression; $variableRefs = $this->getVariableRefs(); foreach ( $variableRefs as $qname => $variableRef ) { // Look for general or fact variables with this qname if ( isset( $this->variablesByQName[ (string)$variableRef ] ) ) { \XBRL_Log::getInstance()->existenceassertion_validation( "Existent assertion", "An existance assertion test cannot reference fact or general variables", array( 'label' => $this->label, 'error' => 'xbrleae:variableReferenceNotAllowed' ) ); } } return true; } catch ( Exception $ex ) { \XBRL_Log::getInstance()->valueassertion_validation( "Value assertion", "Failed to compile test expression", array( 'test expression' => $this->test, 'error' => $ex instanceof XPath2Exception ? $ex->ErrorCode : get_class( $ex ), 'reason' => $ex->getMessage() ) ); return false; } }
[ "public", "function", "validate", "(", "$", "variableSet", ",", "$", "nsMgr", ")", "{", "if", "(", "!", "$", "this", "->", "test", ")", "return", "true", ";", "try", "{", "$", "expression", "=", "XPath2Expression", "::", "Compile", "(", "$", "this", ...
If a test property exists it MUST NOT have dependencies on fact or general variables @param VariableSet $variableSet @param XmlNamespaceManager $nsMgr
[ "If", "a", "test", "property", "exists", "it", "MUST", "NOT", "have", "dependencies", "on", "fact", "or", "general", "variables" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Assertions/ExistenceAssertion.php#L137-L178
train
bseddon/XBRL
Formulas/Resources/Assertions/ExistenceAssertion.php
ExistenceAssertion.evaluationInternal
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; }
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\" );\r", "// Although I cannot find any reference to it in the documentation, it seems that only unique derived facts\r", "// should be compared. Uniquen...
Common function for evaluation @param bool $exists @return void @throws \Exception
[ "Common", "function", "for", "evaluation" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Assertions/ExistenceAssertion.php#L209-L265
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.AddFilter
public function AddFilter( $filter ) { $this->filters[] = $filter; if ( count( $this->filters ) <= 1 ) return; usort( $this->filters, function( /** @var Filter $a */ $a, /** @var Filter $b */ $b ) { return $a->sortPriority > $b->sortPriority ? 1 : ( $a->sortPriority < $b->sortPriority ? -1 : 0 ); } ); }
php
public function AddFilter( $filter ) { $this->filters[] = $filter; if ( count( $this->filters ) <= 1 ) return; usort( $this->filters, function( /** @var Filter $a */ $a, /** @var Filter $b */ $b ) { return $a->sortPriority > $b->sortPriority ? 1 : ( $a->sortPriority < $b->sortPriority ? -1 : 0 ); } ); }
[ "public", "function", "AddFilter", "(", "$", "filter", ")", "{", "$", "this", "->", "filters", "[", "]", "=", "$", "filter", ";", "if", "(", "count", "(", "$", "this", "->", "filters", ")", "<=", "1", ")", "return", ";", "usort", "(", "$", "this"...
Add the filters in a defined order starting with the concept filter to aid performance @param Filter $filter
[ "Add", "the", "filters", "in", "a", "defined", "order", "starting", "with", "the", "concept", "filter", "to", "aid", "performance" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L223-L235
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.aspectsMatch
public function aspectsMatch( $testableAspects, $uncoveredAspectFacts, $variableSet, &$facts, $negate = false, $resetCaches = true ) { if ( count( $variableSet->factVariableBindings ) == 1 ) { // TODO If there is just one variable binding in the variable set and there is a dimensional // uncovered aspect and the dimensional aspect fact is a tuple handle it // (see Arelle:FormulaEvaluator.py.ImplicitFilters line 629) // Need an example before implementing this } // Indexes to prevent redundant lookups if ( $resetCaches ) { $this->factComponentsCache = array(); $this->factElementCache = array(); $this->factQNameCache = array(); $this->factParentCache = array(); $this->factNamespaceCache = array(); $this->factCache = array(); $this->dimensionElementCache = array(); $this->contextDimensionCache = array(); $this->equalityDefinitionsCache = array(); } $matches = array(); $misMatches = array(); $types = \XBRL_Types::getInstance(); foreach ( $facts as /** @var DOMXPathNavigator $fact */ $fact ) { if ( is_null( $fact ) ) continue; foreach ( $testableAspects as $aspect ) { $aspectFact = $uncoveredAspectFacts[ $aspect ]; // BMS 2018-02-11 Changed from 'continue' when the aspect fact is null. // This will tend only to occur where there is a an uncovered dimension // such as in test 43210 V-05. The Arelle equivalent is aspectMatches() // line 670 in FormulaEvaluator.py // BMS 2018-02-16 This is not correct and no longer necessary if ( is_null( $aspectFact ) ) { // $misMatches[] = $fact; continue; } // The fact will always match itself if ( $aspectFact->getUnderlyingObject()->isSameNode( $fact->getUnderlyingObject() ) ) { continue; } switch ( $aspect ) { case ASPECT_LOCATION: if ( $fact->getUnderlyingObject()->parentNode->isSameNode( $aspectFact->getUnderlyingObject()->parentNode ) ) { continue 2; } break; case ASPECT_CONCEPT: if ( $fact->getNamespaceURI() == $aspectFact->getNamespaceURI() && $fact->getLocalName() == $aspectFact->getLocalName() ) { continue 2; } break; default: if ( FactValues::isTuple( $fact ) ) break; $factComponents = $this->getFactDetails( $variableSet, $types, $fact ); $aspectComponents = $this->getFactDetails( $variableSet, $types, $aspectFact ); $result = $this->aspectMatch( $variableSet, $types, $aspect, $aspectComponents, $factComponents ); if ( $result ) continue 2; break; } $misMatches[] = $fact; continue 2; } $matches[] = $fact; } return $negate ? $misMatches : $matches; }
php
public function aspectsMatch( $testableAspects, $uncoveredAspectFacts, $variableSet, &$facts, $negate = false, $resetCaches = true ) { if ( count( $variableSet->factVariableBindings ) == 1 ) { // TODO If there is just one variable binding in the variable set and there is a dimensional // uncovered aspect and the dimensional aspect fact is a tuple handle it // (see Arelle:FormulaEvaluator.py.ImplicitFilters line 629) // Need an example before implementing this } // Indexes to prevent redundant lookups if ( $resetCaches ) { $this->factComponentsCache = array(); $this->factElementCache = array(); $this->factQNameCache = array(); $this->factParentCache = array(); $this->factNamespaceCache = array(); $this->factCache = array(); $this->dimensionElementCache = array(); $this->contextDimensionCache = array(); $this->equalityDefinitionsCache = array(); } $matches = array(); $misMatches = array(); $types = \XBRL_Types::getInstance(); foreach ( $facts as /** @var DOMXPathNavigator $fact */ $fact ) { if ( is_null( $fact ) ) continue; foreach ( $testableAspects as $aspect ) { $aspectFact = $uncoveredAspectFacts[ $aspect ]; // BMS 2018-02-11 Changed from 'continue' when the aspect fact is null. // This will tend only to occur where there is a an uncovered dimension // such as in test 43210 V-05. The Arelle equivalent is aspectMatches() // line 670 in FormulaEvaluator.py // BMS 2018-02-16 This is not correct and no longer necessary if ( is_null( $aspectFact ) ) { // $misMatches[] = $fact; continue; } // The fact will always match itself if ( $aspectFact->getUnderlyingObject()->isSameNode( $fact->getUnderlyingObject() ) ) { continue; } switch ( $aspect ) { case ASPECT_LOCATION: if ( $fact->getUnderlyingObject()->parentNode->isSameNode( $aspectFact->getUnderlyingObject()->parentNode ) ) { continue 2; } break; case ASPECT_CONCEPT: if ( $fact->getNamespaceURI() == $aspectFact->getNamespaceURI() && $fact->getLocalName() == $aspectFact->getLocalName() ) { continue 2; } break; default: if ( FactValues::isTuple( $fact ) ) break; $factComponents = $this->getFactDetails( $variableSet, $types, $fact ); $aspectComponents = $this->getFactDetails( $variableSet, $types, $aspectFact ); $result = $this->aspectMatch( $variableSet, $types, $aspect, $aspectComponents, $factComponents ); if ( $result ) continue 2; break; } $misMatches[] = $fact; continue 2; } $matches[] = $fact; } return $negate ? $misMatches : $matches; }
[ "public", "function", "aspectsMatch", "(", "$", "testableAspects", ",", "$", "uncoveredAspectFacts", ",", "$", "variableSet", ",", "&", "$", "facts", ",", "$", "negate", "=", "false", ",", "$", "resetCaches", "=", "true", ")", "{", "if", "(", "count", "(...
Filter the provided facts matching them with any implicit filters from other variables @param array $testableAspects @param array[DOMXPathNavigator] $uncoveredAspectFacts @param Formula $variableSet @param array[DOMXPathNavigator] $facts (by reference) A list of facts to filter @param bool $negate @param bool $resetCaches When true the caches will be reset. Might be set to false when its helpful for them to persist between calls such as in partitionFacts() @return NULL
[ "Filter", "the", "provided", "facts", "matching", "them", "with", "any", "implicit", "filters", "from", "other", "variables" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L631-L725
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.getFactDetails
private function getFactDetails( $variableSet, $types, $fact ) { $factHash = spl_object_hash( $fact ); if ( ! isset( $this->factCache[ $factHash ] ) ) { // Record the QName and other cache information if not defined if ( ! isset( $this->factQNameCache[ $factHash ] ) ) { // Look up the namespace to find the schema prefix $factNamespace = $fact->getNamespaceURI(); if ( ! isset( $this->factNamespaceCache[ $factNamespace ] ) ) { $factTaxonomy = $variableSet->xbrlTaxonomy->getTaxonomyForNamespace( $fact->getNamespaceURI() ); // Record the mapping $this->factNamespaceCache[ $factNamespace ] = $factTaxonomy->getPrefix(); } // Retrieve the prefix to create a QName $factPrefix = $this->factNamespaceCache[ $factNamespace ]; $factQName = new QName( $factPrefix, $fact->getNamespaceURI(), $fact->getLocalName() ); // And record it against the fact hash $this->factQNameCache[ $factHash ] = $factQName; // If there is no element cached for the QName get it can record it if ( ! isset( $this->factElementCache[ $factQName->clarkNotation() ] ) ) { $this->factElementCache[ $factQName->clarkNotation() ] = $types->getElement( $factQName->localName, $factQName->prefix ); } } $factQName = $this->factQNameCache[ $factHash ]; if ( ! isset( $this->factComponentsCache[ $factHash ] ) ) { $this->factComponentsCache[ $factHash ] = $this->getFactComponents( $variableSet, $fact ); } $factComponents = $this->factComponentsCache[ $factHash ]; $factComponents['factHash'] = $factHash; $factComponents['qname'] = $factQName; $factComponents['fact'] = $fact; $this->factCache[ $factHash ] = $factComponents; } return $this->factCache[ $factHash ]; }
php
private function getFactDetails( $variableSet, $types, $fact ) { $factHash = spl_object_hash( $fact ); if ( ! isset( $this->factCache[ $factHash ] ) ) { // Record the QName and other cache information if not defined if ( ! isset( $this->factQNameCache[ $factHash ] ) ) { // Look up the namespace to find the schema prefix $factNamespace = $fact->getNamespaceURI(); if ( ! isset( $this->factNamespaceCache[ $factNamespace ] ) ) { $factTaxonomy = $variableSet->xbrlTaxonomy->getTaxonomyForNamespace( $fact->getNamespaceURI() ); // Record the mapping $this->factNamespaceCache[ $factNamespace ] = $factTaxonomy->getPrefix(); } // Retrieve the prefix to create a QName $factPrefix = $this->factNamespaceCache[ $factNamespace ]; $factQName = new QName( $factPrefix, $fact->getNamespaceURI(), $fact->getLocalName() ); // And record it against the fact hash $this->factQNameCache[ $factHash ] = $factQName; // If there is no element cached for the QName get it can record it if ( ! isset( $this->factElementCache[ $factQName->clarkNotation() ] ) ) { $this->factElementCache[ $factQName->clarkNotation() ] = $types->getElement( $factQName->localName, $factQName->prefix ); } } $factQName = $this->factQNameCache[ $factHash ]; if ( ! isset( $this->factComponentsCache[ $factHash ] ) ) { $this->factComponentsCache[ $factHash ] = $this->getFactComponents( $variableSet, $fact ); } $factComponents = $this->factComponentsCache[ $factHash ]; $factComponents['factHash'] = $factHash; $factComponents['qname'] = $factQName; $factComponents['fact'] = $fact; $this->factCache[ $factHash ] = $factComponents; } return $this->factCache[ $factHash ]; }
[ "private", "function", "getFactDetails", "(", "$", "variableSet", ",", "$", "types", ",", "$", "fact", ")", "{", "$", "factHash", "=", "spl_object_hash", "(", "$", "fact", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "factCache", "[", "...
Return a stored details array or create one and store it @param Formula $variableSet @param \XBRL_Types $types @param DOMXPathNavigator $fact @return array
[ "Return", "a", "stored", "details", "array", "or", "create", "one", "and", "store", "it" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L775-L821
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.getFactComponents
private function getFactComponents( $variableSet, $fact ) { // Lookup the contextRef and unitRef $contextRef = FactValues::getContextRef( $fact ); $unitRef = FactValues::getUnitRef( $fact ); return array( 'contextRef' => $contextRef, 'unitRef' => $unitRef, ); }
php
private function getFactComponents( $variableSet, $fact ) { // Lookup the contextRef and unitRef $contextRef = FactValues::getContextRef( $fact ); $unitRef = FactValues::getUnitRef( $fact ); return array( 'contextRef' => $contextRef, 'unitRef' => $unitRef, ); }
[ "private", "function", "getFactComponents", "(", "$", "variableSet", ",", "$", "fact", ")", "{", "// Lookup the contextRef and unitRef\r", "$", "contextRef", "=", "FactValues", "::", "getContextRef", "(", "$", "fact", ")", ";", "$", "unitRef", "=", "FactValues", ...
Returns the unit and context for the fact as an array indexed by 'context' and 'unit' respectively @param Formula $variableSet @param DOMXPathNavigator $fact return array
[ "Returns", "the", "unit", "and", "context", "for", "the", "fact", "as", "an", "array", "indexed", "by", "context", "and", "unit", "respectively" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L829-L839
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.getComponentForPath
private function getComponentForPath( $path, $context ) { foreach ( $path as $element ) { if ( ! $context ) continue; if ( ! isset( $context[ $element ] ) ) { $context = array(); continue; } $context = $context[ $element ]; } return $context; }
php
private function getComponentForPath( $path, $context ) { foreach ( $path as $element ) { if ( ! $context ) continue; if ( ! isset( $context[ $element ] ) ) { $context = array(); continue; } $context = $context[ $element ]; } return $context; }
[ "private", "function", "getComponentForPath", "(", "$", "path", ",", "$", "context", ")", "{", "foreach", "(", "$", "path", "as", "$", "element", ")", "{", "if", "(", "!", "$", "context", ")", "continue", ";", "if", "(", "!", "isset", "(", "$", "co...
Get the components for the path requested @param array $path @param array $context @return array
[ "Get", "the", "components", "for", "the", "path", "requested" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L1128-L1142
train
bseddon/XBRL
Formulas/Resources/Variables/FactVariable.php
FactVariable.getDimensionFromComponent
private function getDimensionFromComponent( $variableSet, $dimQName, $dimElement, $context ) { $typed = isset( $dimElement['typedDomainRef'] ); // Could be in context or in the entity foreach ( Formula::$componentPaths as $path ) { $component = $this->getComponentForPath( $path, $context ); if ( ! $component ) continue; // Look for the dimension type but if not found try a different path if ( ! isset( $component[ $typed ? 'typedMember' : 'explicitMember' ] ) ) continue; foreach ( $component[ $typed ? 'typedMember' : 'explicitMember' ] as $dimension ) { // See if the qname of the dimension is the same at the aspect QName $qname = qname( $dimension['dimension'], $variableSet->xbrlInstance->getInstanceNamespaces() ); if ( ! $qname->equals( $dimQName ) ) continue; return $dimension; } } return array(); }
php
private function getDimensionFromComponent( $variableSet, $dimQName, $dimElement, $context ) { $typed = isset( $dimElement['typedDomainRef'] ); // Could be in context or in the entity foreach ( Formula::$componentPaths as $path ) { $component = $this->getComponentForPath( $path, $context ); if ( ! $component ) continue; // Look for the dimension type but if not found try a different path if ( ! isset( $component[ $typed ? 'typedMember' : 'explicitMember' ] ) ) continue; foreach ( $component[ $typed ? 'typedMember' : 'explicitMember' ] as $dimension ) { // See if the qname of the dimension is the same at the aspect QName $qname = qname( $dimension['dimension'], $variableSet->xbrlInstance->getInstanceNamespaces() ); if ( ! $qname->equals( $dimQName ) ) continue; return $dimension; } } return array(); }
[ "private", "function", "getDimensionFromComponent", "(", "$", "variableSet", ",", "$", "dimQName", ",", "$", "dimElement", ",", "$", "context", ")", "{", "$", "typed", "=", "isset", "(", "$", "dimElement", "[", "'typedDomainRef'", "]", ")", ";", "// Could be...
Retrieve the dimension information from a context @param Formula $variableSet @param QName $dimQName The QName of the defining dimension name @param QName $dimElement The QName of the defining dimension member @param array $context An array containing contet information @return array
[ "Retrieve", "the", "dimension", "information", "from", "a", "context" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/FactVariable.php#L1152-L1176
train
bseddon/XBRL
XBRL-Types.php
XBRL_Types.clearElements
public function clearElements() { parent::clearElements(); $types = new self(); $types->fromFile(); $this->elements = $types->elements; }
php
public function clearElements() { parent::clearElements(); $types = new self(); $types->fromFile(); $this->elements = $types->elements; }
[ "public", "function", "clearElements", "(", ")", "{", "parent", "::", "clearElements", "(", ")", ";", "$", "types", "=", "new", "self", "(", ")", ";", "$", "types", "->", "fromFile", "(", ")", ";", "$", "this", "->", "elements", "=", "$", "types", ...
Remove all existing element information @return void
[ "Remove", "all", "existing", "element", "information" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Types.php#L75-L81
train
bseddon/XBRL
XBRL-Types.php
XBRL_Types.xbrlItemTypeNames
public function xbrlItemTypeNames() { if ( is_null( $this->xbrlItemTypesCache ) ) { $this->xbrlItemTypesCache = array_keys( $this->xbrlItemTypes() ); } return $this->xbrlItemTypesCache; }
php
public function xbrlItemTypeNames() { if ( is_null( $this->xbrlItemTypesCache ) ) { $this->xbrlItemTypesCache = array_keys( $this->xbrlItemTypes() ); } return $this->xbrlItemTypesCache; }
[ "public", "function", "xbrlItemTypeNames", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "xbrlItemTypesCache", ")", ")", "{", "$", "this", "->", "xbrlItemTypesCache", "=", "array_keys", "(", "$", "this", "->", "xbrlItemTypes", "(", ")", ")",...
Returns a list of all the xBRL defined types @return string[]
[ "Returns", "a", "list", "of", "all", "the", "xBRL", "defined", "types" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Types.php#L162-L169
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Aspect.php
Aspect.__static
public static function __static() { Aspect::$aspectTests = array( ASPECT_LOCATION => Aspect::$locationTest, ASPECT_CONCEPT => Aspect::$conceptTest, ASPECT_COMPLETE_SCENARIO => Aspect::$completeScenarioTest, ASPECT_COMPLETE_SEGMENT => Aspect::$completeSegmentTest, ASPECT_ENTITY_IDENTIFIER => Aspect::$entityIdentifierTest, ASPECT_PERIOD => Aspect::$periodTest, ASPECT_NON_XDT_SCENARIO => Aspect::$nonXDTScenarioTest, ASPECT_NON_XDT_SEGMENT => Aspect::$nonXDTSegmentTest, ASPECT_UNIT => Aspect::$unitTest, ); }
php
public static function __static() { Aspect::$aspectTests = array( ASPECT_LOCATION => Aspect::$locationTest, ASPECT_CONCEPT => Aspect::$conceptTest, ASPECT_COMPLETE_SCENARIO => Aspect::$completeScenarioTest, ASPECT_COMPLETE_SEGMENT => Aspect::$completeSegmentTest, ASPECT_ENTITY_IDENTIFIER => Aspect::$entityIdentifierTest, ASPECT_PERIOD => Aspect::$periodTest, ASPECT_NON_XDT_SCENARIO => Aspect::$nonXDTScenarioTest, ASPECT_NON_XDT_SEGMENT => Aspect::$nonXDTSegmentTest, ASPECT_UNIT => Aspect::$unitTest, ); }
[ "public", "static", "function", "__static", "(", ")", "{", "Aspect", "::", "$", "aspectTests", "=", "array", "(", "ASPECT_LOCATION", "=>", "Aspect", "::", "$", "locationTest", ",", "ASPECT_CONCEPT", "=>", "Aspect", "::", "$", "conceptTest", ",", "ASPECT_COMPLE...
Mock static constructor
[ "Mock", "static", "constructor" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Aspect.php#L208-L221
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Aspect.php
Aspect.storeAspect
public function storeAspect( $node, $type ) { $node['type'] = 'aspect'; $node['aspectType'] = $type; $node['combinable'] = $this->combinable; return $node; }
php
public function storeAspect( $node, $type ) { $node['type'] = 'aspect'; $node['aspectType'] = $type; $node['combinable'] = $this->combinable; return $node; }
[ "public", "function", "storeAspect", "(", "$", "node", ",", "$", "type", ")", "{", "$", "node", "[", "'type'", "]", "=", "'aspect'", ";", "$", "node", "[", "'aspectType'", "]", "=", "$", "type", ";", "$", "node", "[", "'combinable'", "]", "=", "$",...
Stores a node array with a resource type name of 'aspect' @param array $node A an array representation of the resource node @param string $type 'location' | 'period' | 'concept' | 'entityIdentifier'
[ "Stores", "a", "node", "array", "with", "a", "resource", "type", "name", "of", "aspect" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Aspect.php#L274-L281
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Aspect.php
Aspect.getSourceQName
public function getSourceQName() { // Use the cached name if there is one. if ( ! $this->qname ) { if ( ! property_exists( $this, 'source' ) ) return null; $this->qname = $qname = new QName( $this->source['originalPrefix'], $this->source['namespace'], $this->source['name'] ); } return $this->qname; }
php
public function getSourceQName() { // Use the cached name if there is one. if ( ! $this->qname ) { if ( ! property_exists( $this, 'source' ) ) return null; $this->qname = $qname = new QName( $this->source['originalPrefix'], $this->source['namespace'], $this->source['name'] ); } return $this->qname; }
[ "public", "function", "getSourceQName", "(", ")", "{", "// Use the cached name if there is one.\r", "if", "(", "!", "$", "this", "->", "qname", ")", "{", "if", "(", "!", "property_exists", "(", "$", "this", ",", "'source'", ")", ")", "return", "null", ";", ...
Return the QName of the 'source' property if any @return QName|null
[ "Return", "the", "QName", "of", "the", "source", "property", "if", "any" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Aspect.php#L304-L314
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Unit.php
Unit.getAdditionalNamespaces
public function getAdditionalNamespaces( $variableSet, $evaluationResult ) { $namespaces = array(); foreach ( $this->multiplyBy as $numerator ) { if ( ! isset( $numerator['measure'] ) || ! $numerator['measure'] ) continue; // This is an expression that needs evaluating $result = $this->evaluateXPath( $variableSet, "{$numerator['measure']}", $evaluationResult['vars'] ); if ( $result instanceof XPath2Item ) { $result = $result->getTypedValue(); } // Should report an error here if ( ! $result instanceof QNameValue ) continue; $namespaces[ $result->Prefix ] = $result->NamespaceUri; } foreach ( $this->divideBy as $denominator ) { if ( ! isset( $denominator['measure'] ) || ! $denominator['measure'] ) continue; // This is an expression that needs evaluating $result = $this->evaluateXPath( $variableSet, "{$denominator['measure']}", $evaluationResult['vars'] ); if ( $result instanceof XPath2Item ) { $result = $result->getTypedValue(); } // Should report an error here if ( ! $result instanceof QNameValue ) continue; $namespaces[ $result->Prefix ] = $result->NamespaceUri; } return $namespaces; }
php
public function getAdditionalNamespaces( $variableSet, $evaluationResult ) { $namespaces = array(); foreach ( $this->multiplyBy as $numerator ) { if ( ! isset( $numerator['measure'] ) || ! $numerator['measure'] ) continue; // This is an expression that needs evaluating $result = $this->evaluateXPath( $variableSet, "{$numerator['measure']}", $evaluationResult['vars'] ); if ( $result instanceof XPath2Item ) { $result = $result->getTypedValue(); } // Should report an error here if ( ! $result instanceof QNameValue ) continue; $namespaces[ $result->Prefix ] = $result->NamespaceUri; } foreach ( $this->divideBy as $denominator ) { if ( ! isset( $denominator['measure'] ) || ! $denominator['measure'] ) continue; // This is an expression that needs evaluating $result = $this->evaluateXPath( $variableSet, "{$denominator['measure']}", $evaluationResult['vars'] ); if ( $result instanceof XPath2Item ) { $result = $result->getTypedValue(); } // Should report an error here if ( ! $result instanceof QNameValue ) continue; $namespaces[ $result->Prefix ] = $result->NamespaceUri; } return $namespaces; }
[ "public", "function", "getAdditionalNamespaces", "(", "$", "variableSet", ",", "$", "evaluationResult", ")", "{", "$", "namespaces", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "multiplyBy", "as", "$", "numerator", ")", "{", "if", "(", ...
Returns an array of additional prefixes and namespaces used by measures defined @param Formula $variableSet @param array $evaluationResult @return array
[ "Returns", "an", "array", "of", "additional", "prefixes", "and", "namespaces", "used", "by", "measures", "defined" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Unit.php#L145-L180
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Unit.php
Unit.cancel
private function cancel( &$numerators, &$denominators ) { if ( ! $denominators ) return; foreach ( $numerators as $key => $numerator ) { $found = array_search( $numerator, $denominators ); if ( $found === false ) continue; unset( $numerators[ $key ] ); unset( $denominators[ $found ] ); } }
php
private function cancel( &$numerators, &$denominators ) { if ( ! $denominators ) return; foreach ( $numerators as $key => $numerator ) { $found = array_search( $numerator, $denominators ); if ( $found === false ) continue; unset( $numerators[ $key ] ); unset( $denominators[ $found ] ); } }
[ "private", "function", "cancel", "(", "&", "$", "numerators", ",", "&", "$", "denominators", ")", "{", "if", "(", "!", "$", "denominators", ")", "return", ";", "foreach", "(", "$", "numerators", "as", "$", "key", "=>", "$", "numerator", ")", "{", "$"...
Cancel out the common items in the set of numerators and denominators @param array $numerators @param array $denominators
[ "Cancel", "out", "the", "common", "items", "in", "the", "set", "of", "numerators", "and", "denominators" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Unit.php#L267-L278
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Unit.php
Unit.getFactorsFromSource
private function getFactorsFromSource( $source, $variableSet, $evaluationResult, $log, &$numerators, &$denominators, &$unitRef = null ) { $sourceFact = $variableSet->getSourceFactWithErrorLogging( $source, $evaluationResult, ASPECT_UNIT, $log ); // If the rule is to augment the existing values fill the numerators and denominator arrays $unitRef = FactValues::getUnitRef( $sourceFact ); if (! $unitRef ) return; $unit = $variableSet->xbrlInstance->getUnit( $unitRef ); if ( is_array( $unit ) ) { if ( isset( $unit['measures'] ) ) { $numerators = array_merge( $numerators, $unit['measures'] ); } if ( isset( $unit['divide'] ) ) { if ( $unit['divide']['numerators'] ) { $numerators = array_merge( $numerators, $unit['divide']['numerators'] ); } if ( $unit['divide']['denominators'] ) { $denominators = array_merge( $denominators, $unit['divide']['denominators'] ); } } } else { $numerators[] = $unit; } }
php
private function getFactorsFromSource( $source, $variableSet, $evaluationResult, $log, &$numerators, &$denominators, &$unitRef = null ) { $sourceFact = $variableSet->getSourceFactWithErrorLogging( $source, $evaluationResult, ASPECT_UNIT, $log ); // If the rule is to augment the existing values fill the numerators and denominator arrays $unitRef = FactValues::getUnitRef( $sourceFact ); if (! $unitRef ) return; $unit = $variableSet->xbrlInstance->getUnit( $unitRef ); if ( is_array( $unit ) ) { if ( isset( $unit['measures'] ) ) { $numerators = array_merge( $numerators, $unit['measures'] ); } if ( isset( $unit['divide'] ) ) { if ( $unit['divide']['numerators'] ) { $numerators = array_merge( $numerators, $unit['divide']['numerators'] ); } if ( $unit['divide']['denominators'] ) { $denominators = array_merge( $denominators, $unit['divide']['denominators'] ); } } } else { $numerators[] = $unit; } }
[ "private", "function", "getFactorsFromSource", "(", "$", "source", ",", "$", "variableSet", ",", "$", "evaluationResult", ",", "$", "log", ",", "&", "$", "numerators", ",", "&", "$", "denominators", ",", "&", "$", "unitRef", "=", "null", ")", "{", "$", ...
Fill the numerators and denominators arrays from the specified source @param array $source An array containing the qname of the source to use @param Formula $variableSet @param array $evaluationResult @param \XBRL_Log $log @param array $numerators List to populate with numerators @param array $denominators List to populate with denominators @param string The unitRef of the source (if there is one) @return null @throws An exception if the source is not valid
[ "Fill", "the", "numerators", "and", "denominators", "arrays", "from", "the", "specified", "source" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Unit.php#L292-L326
train
bseddon/XBRL
Formulas/FactValues.php
FactValues.getDecimals
public static function getDecimals( $fact ) { if ( ! $fact instanceof DOMXPathNavigator ) { throw new \Exception( "Invalid fact variable passed to FactValues::getDecimals" ); } $fact = $fact->CloneInstance(); if ( $fact->MoveToAttribute( "decimals", null ) ) { return $fact->getValue(); } return false; }
php
public static function getDecimals( $fact ) { if ( ! $fact instanceof DOMXPathNavigator ) { throw new \Exception( "Invalid fact variable passed to FactValues::getDecimals" ); } $fact = $fact->CloneInstance(); if ( $fact->MoveToAttribute( "decimals", null ) ) { return $fact->getValue(); } return false; }
[ "public", "static", "function", "getDecimals", "(", "$", "fact", ")", "{", "if", "(", "!", "$", "fact", "instanceof", "DOMXPathNavigator", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid fact variable passed to FactValues::getDecimals\"", ")", ";", "}...
Get the decimals ref from XBRL instance @param DOMXPathNavigator $fact @return string|bool @throws \Exception
[ "Get", "the", "decimals", "ref", "from", "XBRL", "instance" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/FactValues.php#L100-L114
train
bseddon/XBRL
Formulas/FactValues.php
FactValues.isItem
public static function isItem( $fact ) { $prefix = \XBRL_Types::getInstance()->getPrefixForNamespace( $fact->getNamespaceURI() ); $name = "{$prefix}:{$fact->getLocalName()}"; $element = \XBRL_Types::getInstance()->getElement( $name); if ( ! $element || ! isset( $element['substitutionGroup'] ) ) return false; $result = \XBRL_Types::getInstance()->resolveToSubstitutionGroup( $element['substitutionGroup'] , array( "xbrli:item" ) ); return $result; }
php
public static function isItem( $fact ) { $prefix = \XBRL_Types::getInstance()->getPrefixForNamespace( $fact->getNamespaceURI() ); $name = "{$prefix}:{$fact->getLocalName()}"; $element = \XBRL_Types::getInstance()->getElement( $name); if ( ! $element || ! isset( $element['substitutionGroup'] ) ) return false; $result = \XBRL_Types::getInstance()->resolveToSubstitutionGroup( $element['substitutionGroup'] , array( "xbrli:item" ) ); return $result; }
[ "public", "static", "function", "isItem", "(", "$", "fact", ")", "{", "$", "prefix", "=", "\\", "XBRL_Types", "::", "getInstance", "(", ")", "->", "getPrefixForNamespace", "(", "$", "fact", "->", "getNamespaceURI", "(", ")", ")", ";", "$", "name", "=", ...
Get the precision ref from XBRL instance @param DOMXPathNavigator $fact @return bool @throws \Exception
[ "Get", "the", "precision", "ref", "from", "XBRL", "instance" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/FactValues.php#L184-L193
train
bseddon/XBRL
Formulas/FactValues.php
FactValues.getType
public static function getType( $fact ) { if ( ! $fact instanceof DOMXPathNavigator ) { throw new \Exception( "Invalid fact variable passed to FactValues::isItem" ); } return \XBRL_Types::getInstance()->getTypeForDOMNode( $fact->getUnderlyingObject() ); }
php
public static function getType( $fact ) { if ( ! $fact instanceof DOMXPathNavigator ) { throw new \Exception( "Invalid fact variable passed to FactValues::isItem" ); } return \XBRL_Types::getInstance()->getTypeForDOMNode( $fact->getUnderlyingObject() ); }
[ "public", "static", "function", "getType", "(", "$", "fact", ")", "{", "if", "(", "!", "$", "fact", "instanceof", "DOMXPathNavigator", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid fact variable passed to FactValues::isItem\"", ")", ";", "}", "ret...
Get the schema type for the fact @param DOMXPathNavigator $fact @return string|bool @throws \Exception
[ "Get", "the", "schema", "type", "for", "the", "fact" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/FactValues.php#L218-L226
train
bseddon/XBRL
Formulas/FactValues.php
FactValues.getDimensionsForFact
public static function getDimensionsForFact( $variableSet, $fact ) { $contextRef = FactValues::getContextRef( $fact ); return FactValues::getDimensionsInContextRef( $variableSet, $contextRef ); }
php
public static function getDimensionsForFact( $variableSet, $fact ) { $contextRef = FactValues::getContextRef( $fact ); return FactValues::getDimensionsInContextRef( $variableSet, $contextRef ); }
[ "public", "static", "function", "getDimensionsForFact", "(", "$", "variableSet", ",", "$", "fact", ")", "{", "$", "contextRef", "=", "FactValues", "::", "getContextRef", "(", "$", "fact", ")", ";", "return", "FactValues", "::", "getDimensionsInContextRef", "(", ...
Return the dimensions associated with the fact. This will look up the context ref. @param VariableSet $variableSet @param DOMXPathNavigator $fact @return array An array of the dimension (keys) and members (values)
[ "Return", "the", "dimensions", "associated", "with", "the", "fact", ".", "This", "will", "look", "up", "the", "context", "ref", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/FactValues.php#L234-L238
train
bseddon/XBRL
Formulas/FactVariableBinding.php
FactVariableBinding.setFallbackValue
public function setFallbackValue( $variableSet, $alwaysUseFallbackValue = false ) { if ( is_null( $this->var->fallbackValue ) ) return false; if ( ! $alwaysUseFallbackValue && ! is_null( $this->facts ) ) return false; $this->facts = null; $vars = $variableSet->getParametersAsVars(); // Evaluate the fallback value. Should return an XPath2Item $fallbackResult = $this->var->evaluateXPath( $variableSet, $this->var->fallbackValue, $vars ); $this->yieldedFact = $fallbackResult; $this->isFallback = true; return true; }
php
public function setFallbackValue( $variableSet, $alwaysUseFallbackValue = false ) { if ( is_null( $this->var->fallbackValue ) ) return false; if ( ! $alwaysUseFallbackValue && ! is_null( $this->facts ) ) return false; $this->facts = null; $vars = $variableSet->getParametersAsVars(); // Evaluate the fallback value. Should return an XPath2Item $fallbackResult = $this->var->evaluateXPath( $variableSet, $this->var->fallbackValue, $vars ); $this->yieldedFact = $fallbackResult; $this->isFallback = true; return true; }
[ "public", "function", "setFallbackValue", "(", "$", "variableSet", ",", "$", "alwaysUseFallbackValue", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "var", "->", "fallbackValue", ")", ")", "return", "false", ";", "if", "(", "!", "...
Provides a binding the chance to set a fallback value and return true or return false Set a fallback value for the related variable if it has a fallback value @param VariableSet $variableSet @param bool alwaysUseFallbackValue @return boolean
[ "Provides", "a", "binding", "the", "chance", "to", "set", "a", "fallback", "value", "and", "return", "true", "or", "return", "false", "Set", "a", "fallback", "value", "for", "the", "related", "variable", "if", "it", "has", "a", "fallback", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/FactVariableBinding.php#L71-L86
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Concept.php
Concept.getSourceFact
private function getSourceFact( $variableSet, $evaluationResult, $log ) { $sourceQName = null; if ( count( $this->qname ) ) { $sourceQName = new QName( $this->qname[0]['originalPrefix'], $this->qname[0]['namespace'], $this->qname[0]['name'] ); if ( ! $sourceQName ) return null; } elseif ( count( $this->qnameExpression ) ) { $qname = $this->evaluateXPath( $variableSet, $this->qnameExpression[0], $evaluationResult['vars'] ); if ( $qname instanceof XPath2Item ) { $qname = $qname->getTypedValue(); } if ( ! $qname ) return null; $sourceQName = new QName( $qname->Prefix, $qname->NamespaceUri, $qname->LocalName ); } else { return null; } // OK, got the source fact but it might be a variable in which case the value of the variable will be required if ( isset( $variableSet->variablesByQName[ $sourceQName->clarkNotation() ] ) ) { if ( ! isset( $evaluationResult['vars'][ $sourceQName->clarkNotation() ] ) ) { $log->formula_validation( "Concept aspect", "Unable to find variable", array( 'variable' => $sourceQName->clarkNotation(), 'error' => 'xbrlfe:incompleteConceptRule' ) ); } // Get the evaluation value for this variable $fact = $evaluationResult['vars'][ $sourceQName->clarkNotation() ]; if ( $fact instanceof XPath2NodeIterator ) { // Get the first fact while (true) { foreach ( $fact as $node ) { if ( ! $node instanceof DOMXPathNavigator ) continue; $fact = $node; break 2; } $fact = null; break; } } if ( $fact instanceof XPathNavigator ) { $sourceQName = new QName( $fact->getPrefix(), $fact->getNamespaceURI(), $fact->getLocalName() ); } else { $log->formula_validation( "Concept aspect", "The variable reference does not point to a result node", array( 'variable' => $sourceQName->clarkNotation(), 'error' => 'xbrlfe:incompleteConceptRule' ) ); } } return $sourceQName; }
php
private function getSourceFact( $variableSet, $evaluationResult, $log ) { $sourceQName = null; if ( count( $this->qname ) ) { $sourceQName = new QName( $this->qname[0]['originalPrefix'], $this->qname[0]['namespace'], $this->qname[0]['name'] ); if ( ! $sourceQName ) return null; } elseif ( count( $this->qnameExpression ) ) { $qname = $this->evaluateXPath( $variableSet, $this->qnameExpression[0], $evaluationResult['vars'] ); if ( $qname instanceof XPath2Item ) { $qname = $qname->getTypedValue(); } if ( ! $qname ) return null; $sourceQName = new QName( $qname->Prefix, $qname->NamespaceUri, $qname->LocalName ); } else { return null; } // OK, got the source fact but it might be a variable in which case the value of the variable will be required if ( isset( $variableSet->variablesByQName[ $sourceQName->clarkNotation() ] ) ) { if ( ! isset( $evaluationResult['vars'][ $sourceQName->clarkNotation() ] ) ) { $log->formula_validation( "Concept aspect", "Unable to find variable", array( 'variable' => $sourceQName->clarkNotation(), 'error' => 'xbrlfe:incompleteConceptRule' ) ); } // Get the evaluation value for this variable $fact = $evaluationResult['vars'][ $sourceQName->clarkNotation() ]; if ( $fact instanceof XPath2NodeIterator ) { // Get the first fact while (true) { foreach ( $fact as $node ) { if ( ! $node instanceof DOMXPathNavigator ) continue; $fact = $node; break 2; } $fact = null; break; } } if ( $fact instanceof XPathNavigator ) { $sourceQName = new QName( $fact->getPrefix(), $fact->getNamespaceURI(), $fact->getLocalName() ); } else { $log->formula_validation( "Concept aspect", "The variable reference does not point to a result node", array( 'variable' => $sourceQName->clarkNotation(), 'error' => 'xbrlfe:incompleteConceptRule' ) ); } } return $sourceQName; }
[ "private", "function", "getSourceFact", "(", "$", "variableSet", ",", "$", "evaluationResult", ",", "$", "log", ")", "{", "$", "sourceQName", "=", "null", ";", "if", "(", "count", "(", "$", "this", "->", "qname", ")", ")", "{", "$", "sourceQName", "=",...
Returns the fact associated with the formula source @param VariableSet $variableSet @param array $evaluationResult @param \XBRL_Log $log @return DOMXPathNavigator|null
[ "Returns", "the", "fact", "associated", "with", "the", "formula", "source" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Concept.php#L136-L206
train
bseddon/XBRL
Formulas/Resources/Variables/Implementation.php
Implementation.execute
public function execute( $signature, $context, $provider, $args, $parameters ) { if ( count( $args ) != count( $this->inputs ) ) { \XBRL_Log::getInstance()->formula_validation( "Custom function", "The number of parameters passed does not match the number of inputs expected", array( 'error' => 'xbrlcfie:inputMismatch', 'name' => "{$signature->name['originalPrefix']}:{$signature->name['name']}" ) ); } $vars = array(); foreach ( $this->inputs as $key => $name ) { $vars[ $name ] = $args[ $key ]; } foreach ( $parameters as $qname => $parameter ) { $vars[ $qname ] = $parameter->select; } $variableSet = new VariableSet(); $variableSet->xbrlInstance = $context->xbrlInstance; $variableSet->xbrlTaxonomy = $context->xbrlTaxonomy; $variableSet->nsMgr = $context->NamespaceManager; foreach ( $this->steps as $name => $step ) { $result = $this->evaluateXPath( $variableSet, $step, $vars ); $vars[ $name ] = $result; } return $this->evaluateXPath( $variableSet, $this->output, $vars ); }
php
public function execute( $signature, $context, $provider, $args, $parameters ) { if ( count( $args ) != count( $this->inputs ) ) { \XBRL_Log::getInstance()->formula_validation( "Custom function", "The number of parameters passed does not match the number of inputs expected", array( 'error' => 'xbrlcfie:inputMismatch', 'name' => "{$signature->name['originalPrefix']}:{$signature->name['name']}" ) ); } $vars = array(); foreach ( $this->inputs as $key => $name ) { $vars[ $name ] = $args[ $key ]; } foreach ( $parameters as $qname => $parameter ) { $vars[ $qname ] = $parameter->select; } $variableSet = new VariableSet(); $variableSet->xbrlInstance = $context->xbrlInstance; $variableSet->xbrlTaxonomy = $context->xbrlTaxonomy; $variableSet->nsMgr = $context->NamespaceManager; foreach ( $this->steps as $name => $step ) { $result = $this->evaluateXPath( $variableSet, $step, $vars ); $vars[ $name ] = $result; } return $this->evaluateXPath( $variableSet, $this->output, $vars ); }
[ "public", "function", "execute", "(", "$", "signature", ",", "$", "context", ",", "$", "provider", ",", "$", "args", ",", "$", "parameters", ")", "{", "if", "(", "count", "(", "$", "args", ")", "!=", "count", "(", "$", "this", "->", "inputs", ")", ...
Execute the implementation @param Signature $signature @param XPath2Context $context @param NodeProvider $provider @param array $args @param array[Parameter] $parameters @return mixed
[ "Execute", "the", "implementation" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Variables/Implementation.php#L159-L196
train
bseddon/XBRL
Formulas/Formulas.php
Formulas.ProcessFormulaResource
public static function ProcessFormulaResource( $taxonomy, $roleUri, $linkbaseHref, $label, $node, $domNode, $log ) { $localName = $domNode->localName; if ( ! isset( Formulas::$formulaElements[ $localName ] ) ) { return false; } if ( ! property_exists( $taxonomy->context, "formulaResources" ) ) { $taxonomy->context->formulaResources = array(); } // Construct a name for the class that will handle the element // resource using definitions in the static array $formulaElements $filterName = '\\XBRL\\Formulas\\Resources\\' . Formulas::$formulaElements[ $localName ]['part'] . ( isset( Formulas::$formulaElements[ $localName ]['className'] ) ? Formulas::$formulaElements[ $localName ]['className'] : ucfirst( $localName ) ); /** * @var Resource $filter */ $filter = new $filterName; $resource = $filter->process( $localName, $taxonomy, $roleUri, $linkbaseHref, $label, $node, $domNode, $log ); return $resource; }
php
public static function ProcessFormulaResource( $taxonomy, $roleUri, $linkbaseHref, $label, $node, $domNode, $log ) { $localName = $domNode->localName; if ( ! isset( Formulas::$formulaElements[ $localName ] ) ) { return false; } if ( ! property_exists( $taxonomy->context, "formulaResources" ) ) { $taxonomy->context->formulaResources = array(); } // Construct a name for the class that will handle the element // resource using definitions in the static array $formulaElements $filterName = '\\XBRL\\Formulas\\Resources\\' . Formulas::$formulaElements[ $localName ]['part'] . ( isset( Formulas::$formulaElements[ $localName ]['className'] ) ? Formulas::$formulaElements[ $localName ]['className'] : ucfirst( $localName ) ); /** * @var Resource $filter */ $filter = new $filterName; $resource = $filter->process( $localName, $taxonomy, $roleUri, $linkbaseHref, $label, $node, $domNode, $log ); return $resource; }
[ "public", "static", "function", "ProcessFormulaResource", "(", "$", "taxonomy", ",", "$", "roleUri", ",", "$", "linkbaseHref", ",", "$", "label", ",", "$", "node", ",", "$", "domNode", ",", "$", "log", ")", "{", "$", "localName", "=", "$", "domNode", "...
Processes a node to extract formula or variable information @param \XBRL $taxonomy The taxonomy referencing the linkbase being processed @param string $roleUri @param string $linkbaseHref @param string $label @param \SimpleXMLElement $node A \SimpleXMLElement reference to the node to be processed @param \DOMNode $domNode A \DOMNode reference to the node to be processed @param \XBRL_Log $log $log
[ "Processes", "a", "node", "to", "extract", "formula", "or", "variable", "information" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Formulas.php#L253-L283
train
bseddon/XBRL
Formulas/Resources/Assertions/ValueAssertion.php
ValueAssertion.validate
public function validate( $variableSet, $nsMgr ) { if ( isset( $this->test ) && ! empty( $this->test ) ) { try { $expression = XPath2Expression::Compile( $this->test, $nsMgr ); $this->testXPath2Expression = $expression; } catch ( Exception $ex ) { \XBRL_Log::getInstance()->valueassertion_validation( "Value assertion", "Failed to compile test expression", array( 'test expression' => $this->test, 'error' => $ex instanceof XPath2Exception ? $ex->ErrorCode : get_class( $ex ), 'reason' => $ex->getMessage() ) ); return false; } } return true; }
php
public function validate( $variableSet, $nsMgr ) { if ( isset( $this->test ) && ! empty( $this->test ) ) { try { $expression = XPath2Expression::Compile( $this->test, $nsMgr ); $this->testXPath2Expression = $expression; } catch ( Exception $ex ) { \XBRL_Log::getInstance()->valueassertion_validation( "Value assertion", "Failed to compile test expression", array( 'test expression' => $this->test, 'error' => $ex instanceof XPath2Exception ? $ex->ErrorCode : get_class( $ex ), 'reason' => $ex->getMessage() ) ); return false; } } return true; }
[ "public", "function", "validate", "(", "$", "variableSet", ",", "$", "nsMgr", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "test", ")", "&&", "!", "empty", "(", "$", "this", "->", "test", ")", ")", "{", "try", "{", "$", "expression", "="...
Check the 'select' and 'as' @param VariableSet $variableSet @param XmlNamespaceManager $nsMgr @return bool @throws FormulasException
[ "Check", "the", "select", "and", "as" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Assertions/ValueAssertion.php#L135-L160
train
bseddon/XBRL
Formulas/Resources/Resource.php
Resource.fromArray
public static function fromArray( $source ) { try { $classname = get_called_class(); if ( ! class_exists( $classname ) ) { \XBRL_Log::getInstance()->err( "The class '$classname' does not exist" ); return null; } $instance = new $classname(); if ( ! $instance instanceof Resource ) { \XBRL_Log::getInstance()->err( "The class instance being created MUST inherit from 'XBRL\\Formulas\\Resources\\Resources'" ); return null; } $has = get_object_vars( $instance ); foreach ( $has as $name => $oldValue ) { if ( ! isset( $source[ $name ] ) ) continue; $instance->$name = $source[ $name ]; } return $instance; } catch( \Exception $ex ) { return null; } }
php
public static function fromArray( $source ) { try { $classname = get_called_class(); if ( ! class_exists( $classname ) ) { \XBRL_Log::getInstance()->err( "The class '$classname' does not exist" ); return null; } $instance = new $classname(); if ( ! $instance instanceof Resource ) { \XBRL_Log::getInstance()->err( "The class instance being created MUST inherit from 'XBRL\\Formulas\\Resources\\Resources'" ); return null; } $has = get_object_vars( $instance ); foreach ( $has as $name => $oldValue ) { if ( ! isset( $source[ $name ] ) ) continue; $instance->$name = $source[ $name ]; } return $instance; } catch( \Exception $ex ) { return null; } }
[ "public", "static", "function", "fromArray", "(", "$", "source", ")", "{", "try", "{", "$", "classname", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "\\", "XBRL_Log", "::", "getInstance", ...
Populate an instance with values from an array @param array $source An array of values to add to the class @return Resource
[ "Populate", "an", "instance", "with", "values", "from", "an", "array" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Resource.php#L71-L104
train
bseddon/XBRL
Formulas/Resources/Resource.php
Resource.valueToString
public static function valueToString( $value, $includePrefix = true ) { if ( $value instanceof DOMXPathNavigator ) { return ( $includePrefix ? "({$value->getName()}: " : '' ) . $value->getValue() . ( $includePrefix ? ")" : '' ); } else if ( $value instanceof XPath2NodeIterator ) { $sb = array(); /** * @var XPath2NodeIterator $value */ foreach ( $value as /** @var XPathItem $item */ $item ) { if ( $item instanceof ExprIterator ) { $inner = array(); foreach ( $item as $value ) { $inner[] = $value instanceof XPath2Item ? $value->getValue() : $value->getInnerXml(); } $sb[] = ( $includePrefix ? "(sub-sequence) " : '' ) . "[" . implode( ",", $inner ) . "]"; } else if ( $item->getIsNode() ) { /** * @var XPathNavigator $nav */ $nav = $item; $sb[] = ( $includePrefix ? "({$nav->getName()}) = " : '' ) . $nav->getValue(); } else { $sb[] = htmlentities( (string)$item, ENT_NOQUOTES | ENT_XML1 ); // ->getValue(); } } return ( $includePrefix ? "(sequence) " : '' ) . "[" . implode( ",", $sb ) . "]"; } else if ( $value instanceof \Iterator ) { $substitution = ( $includePrefix ? "(sequence) = " : '' ) . "[" . implode( ",", array_map( function( /** @var DOMXPathNavigator $item */ $item ) { return $item->getValue(); }, iterator_to_array( $value ) ) ) . "]"; } else if ( $value instanceof XPathItem ) { /** * @var XPathItem $item */ $item = $value; if ( $item->getIsNode() ) { return $item->getInnerXml(); } else { return (string)$item; // ->getValue(); } } else if ( $value instanceof Undefined ) { return null; } return XPath2Convert::ToString( $value ); }
php
public static function valueToString( $value, $includePrefix = true ) { if ( $value instanceof DOMXPathNavigator ) { return ( $includePrefix ? "({$value->getName()}: " : '' ) . $value->getValue() . ( $includePrefix ? ")" : '' ); } else if ( $value instanceof XPath2NodeIterator ) { $sb = array(); /** * @var XPath2NodeIterator $value */ foreach ( $value as /** @var XPathItem $item */ $item ) { if ( $item instanceof ExprIterator ) { $inner = array(); foreach ( $item as $value ) { $inner[] = $value instanceof XPath2Item ? $value->getValue() : $value->getInnerXml(); } $sb[] = ( $includePrefix ? "(sub-sequence) " : '' ) . "[" . implode( ",", $inner ) . "]"; } else if ( $item->getIsNode() ) { /** * @var XPathNavigator $nav */ $nav = $item; $sb[] = ( $includePrefix ? "({$nav->getName()}) = " : '' ) . $nav->getValue(); } else { $sb[] = htmlentities( (string)$item, ENT_NOQUOTES | ENT_XML1 ); // ->getValue(); } } return ( $includePrefix ? "(sequence) " : '' ) . "[" . implode( ",", $sb ) . "]"; } else if ( $value instanceof \Iterator ) { $substitution = ( $includePrefix ? "(sequence) = " : '' ) . "[" . implode( ",", array_map( function( /** @var DOMXPathNavigator $item */ $item ) { return $item->getValue(); }, iterator_to_array( $value ) ) ) . "]"; } else if ( $value instanceof XPathItem ) { /** * @var XPathItem $item */ $item = $value; if ( $item->getIsNode() ) { return $item->getInnerXml(); } else { return (string)$item; // ->getValue(); } } else if ( $value instanceof Undefined ) { return null; } return XPath2Convert::ToString( $value ); }
[ "public", "static", "function", "valueToString", "(", "$", "value", ",", "$", "includePrefix", "=", "true", ")", "{", "if", "(", "$", "value", "instanceof", "DOMXPathNavigator", ")", "{", "return", "(", "$", "includePrefix", "?", "\"({$value->getName()}: \"", ...
Convert a variable result to a text representation @param mixed $value @param bool $includePrefix (default: true) When true a prefix indicating the type of value will be included @return string|NULL
[ "Convert", "a", "variable", "result", "to", "a", "text", "representation" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Resource.php#L240-L311
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Dimension.php
Dimension.contextToIndex
public static function contextToIndex( $context, $explicit, $formula = null, $aspectDimension = null ) { $result = array(); foreach ( $context as $key => $dimension ) { $qname = qname( $dimension['dimension'], $formula->xbrlInstance->getInstanceNamespaces() ); if ( $qname->clarkNotation() != $aspectDimension ) continue; if ( $explicit ) { $result[ $dimension['dimension'] ][ $dimension['member'] ] = $dimension['member']; } else { $result[ $dimension['dimension'] ] = $dimension['member']; } } return $result; }
php
public static function contextToIndex( $context, $explicit, $formula = null, $aspectDimension = null ) { $result = array(); foreach ( $context as $key => $dimension ) { $qname = qname( $dimension['dimension'], $formula->xbrlInstance->getInstanceNamespaces() ); if ( $qname->clarkNotation() != $aspectDimension ) continue; if ( $explicit ) { $result[ $dimension['dimension'] ][ $dimension['member'] ] = $dimension['member']; } else { $result[ $dimension['dimension'] ] = $dimension['member']; } } return $result; }
[ "public", "static", "function", "contextToIndex", "(", "$", "context", ",", "$", "explicit", ",", "$", "formula", "=", "null", ",", "$", "aspectDimension", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "context...
Convers an XBRL_Instance version of a dimension segment or scenario to an indexed version @param array $context @param bool $explicit True if the array being converted prepresents an explicit dimension @param Formula $formula @param string $aspectDimension @return array
[ "Convers", "an", "XBRL_Instance", "version", "of", "a", "dimension", "segment", "or", "scenario", "to", "an", "indexed", "version" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Dimension.php#L60-L79
train
bseddon/XBRL
Formulas/Resources/Formulas/Aspects/Dimension.php
Dimension.IndexToContext
public static function IndexToContext( $index ) { $result = array(); foreach ( $index as $dimension => $members ) { foreach ( $members as $memberQName => $member ) { if ( is_array( $member ) ) { $x = array( $memberQName => $member ); // Remove the dimension from the member foreach ( $x as $key => $xml ) { // $x[ $key ] = str_replace( "</$memberQName>", "", str_replace( "<$memberQName>", "", $xml ) ); } $result[] = array( 'dimension' => $dimension, 'member' => $x ); } else { $result[] = array( 'dimension' => $dimension, 'member' => $member ); } } } return $result; }
php
public static function IndexToContext( $index ) { $result = array(); foreach ( $index as $dimension => $members ) { foreach ( $members as $memberQName => $member ) { if ( is_array( $member ) ) { $x = array( $memberQName => $member ); // Remove the dimension from the member foreach ( $x as $key => $xml ) { // $x[ $key ] = str_replace( "</$memberQName>", "", str_replace( "<$memberQName>", "", $xml ) ); } $result[] = array( 'dimension' => $dimension, 'member' => $x ); } else { $result[] = array( 'dimension' => $dimension, 'member' => $member ); } } } return $result; }
[ "public", "static", "function", "IndexToContext", "(", "$", "index", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "index", "as", "$", "dimension", "=>", "$", "members", ")", "{", "foreach", "(", "$", "members", "as", "$"...
Convert a dimension into a context @param array $index @return array
[ "Convert", "a", "dimension", "into", "a", "context" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Aspects/Dimension.php#L86-L111
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.getValidMembers
private function getValidMembers( $dimensionalNode ) { $result = array(); if ( ! $dimensionalNode || $dimensionalNode['nodeclass'] !== 'dimensional' ) { return $result; } if ( $dimensionalNode['taxonomy_element']['type'] === 'uk-types:domainItemType' ) { $result[ $dimensionalNode['taxonomy_element']['id'] ] = true; } if ( ! isset( $dimensionalNode['children'] ) ) { return $result; } foreach ( $dimensionalNode['children'] as $nodeKey => $node ) { $result += $this->getValidMembers( $node ); } return $result; }
php
private function getValidMembers( $dimensionalNode ) { $result = array(); if ( ! $dimensionalNode || $dimensionalNode['nodeclass'] !== 'dimensional' ) { return $result; } if ( $dimensionalNode['taxonomy_element']['type'] === 'uk-types:domainItemType' ) { $result[ $dimensionalNode['taxonomy_element']['id'] ] = true; } if ( ! isset( $dimensionalNode['children'] ) ) { return $result; } foreach ( $dimensionalNode['children'] as $nodeKey => $node ) { $result += $this->getValidMembers( $node ); } return $result; }
[ "private", "function", "getValidMembers", "(", "$", "dimensionalNode", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "!", "$", "dimensionalNode", "||", "$", "dimensionalNode", "[", "'nodeclass'", "]", "!==", "'dimensional'", ")", "{", "r...
Get a list of all the members @param array $dimensionalNode @return array An array of the member ids
[ "Get", "a", "list", "of", "all", "the", "members" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L720-L744
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.afterMainTaxonomy
public function afterMainTaxonomy() { // Run the pruning process over the roles taxonomy $map = array( XBRL_US_GAAP_2015::$us_GAAP_2013_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2013_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2013_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, ); /** * @var XBRL $taxonomy */ $taxonomy = false; if ( isset( $map[ $this->getNamespace() ] ) ) { $taxonomy = $this->getTaxonomyForNamespace( $map[ $this->getNamespace() ] ); } if ( ! $taxonomy ) { foreach ( array_unique( array_values( $map ) ) as $namespace => $roleNamespace ) { if ( ! ( $taxonomy = $this->getTaxonomyForNamespace( $roleNamespace ) ) ) continue; break; } if ( ! $taxonomy ) { $this->log()->err( "The Roles schema cannot be located for taxonomy with namespace '{$this->getNamespace()}'" ); exit; } } // /** // * @var XBRL $taxonomy // */ // $taxonomy = $this->getTaxonomyForNamespace( XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS ); // if ( ! $taxonomy ) // { // $taxonomy = $this->getTaxonomyForNamespace( XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS ); // if ( ! $taxonomy ) // { // $this->log()->err( "The Roles schema cannot be located for 2014 or 2015" ); // exit; // } // } if ( $this->context->isExtensionTaxonomy() ) { // This is needed because the definitions and presentations are loaded into // the roles schema which is loaded early so an additional fixup is required. $taxonomy->fixupPresentationHypercubes(); $taxonomy->fixupDefinitionRoles(); // Mainly adds a 'paths' index to the 'hierarchy' element of each role. } $this->context->locale = 'en_US'; $taxonomy->context->locale = 'en_US'; }
php
public function afterMainTaxonomy() { // Run the pruning process over the roles taxonomy $map = array( XBRL_US_GAAP_2015::$us_GAAP_2013_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2013_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2013_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2013_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2014_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2015_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2016_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2016_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2017_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2017_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, XBRL_US_GAAP_2015::$us_GAAP_2018_ENTRY_POINT_ALL_NS => XBRL_US_GAAP_2015::$us_GAAP_2018_ROLES_NS, ); /** * @var XBRL $taxonomy */ $taxonomy = false; if ( isset( $map[ $this->getNamespace() ] ) ) { $taxonomy = $this->getTaxonomyForNamespace( $map[ $this->getNamespace() ] ); } if ( ! $taxonomy ) { foreach ( array_unique( array_values( $map ) ) as $namespace => $roleNamespace ) { if ( ! ( $taxonomy = $this->getTaxonomyForNamespace( $roleNamespace ) ) ) continue; break; } if ( ! $taxonomy ) { $this->log()->err( "The Roles schema cannot be located for taxonomy with namespace '{$this->getNamespace()}'" ); exit; } } // /** // * @var XBRL $taxonomy // */ // $taxonomy = $this->getTaxonomyForNamespace( XBRL_US_GAAP_2015::$us_GAAP_2015_ROLES_NS ); // if ( ! $taxonomy ) // { // $taxonomy = $this->getTaxonomyForNamespace( XBRL_US_GAAP_2015::$us_GAAP_2014_ROLES_NS ); // if ( ! $taxonomy ) // { // $this->log()->err( "The Roles schema cannot be located for 2014 or 2015" ); // exit; // } // } if ( $this->context->isExtensionTaxonomy() ) { // This is needed because the definitions and presentations are loaded into // the roles schema which is loaded early so an additional fixup is required. $taxonomy->fixupPresentationHypercubes(); $taxonomy->fixupDefinitionRoles(); // Mainly adds a 'paths' index to the 'hierarchy' element of each role. } $this->context->locale = 'en_US'; $taxonomy->context->locale = 'en_US'; }
[ "public", "function", "afterMainTaxonomy", "(", ")", "{", "// Run the pruning process over the roles taxonomy\r", "$", "map", "=", "array", "(", "XBRL_US_GAAP_2015", "::", "$", "us_GAAP_2013_NS", "=>", "XBRL_US_GAAP_2015", "::", "$", "us_GAAP_2013_ROLES_NS", ",", "XBRL_US...
Provides an opportunity for a descendant class implemenentation to take action when the main taxonomy is loaded
[ "Provides", "an", "opportunity", "for", "a", "descendant", "class", "implemenentation", "to", "take", "action", "when", "the", "main", "taxonomy", "is", "loaded" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L749-L826
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.beforeDimensionalPruned
protected function beforeDimensionalPruned( $dimensionalNode, &$parentNode ) { return parent::beforeDimensionalPruned( $dimensionalNode, $parentNode ); // The dimensional information probably contains valid dimensional information // That indicate which members of possible hypercubes are valid for the nodes // of the parent. $members = $this->getValidMembers( $dimensionalNode ); if ( count( $members ) ) { $parentNode['members'] = $members; } return true; }
php
protected function beforeDimensionalPruned( $dimensionalNode, &$parentNode ) { return parent::beforeDimensionalPruned( $dimensionalNode, $parentNode ); // The dimensional information probably contains valid dimensional information // That indicate which members of possible hypercubes are valid for the nodes // of the parent. $members = $this->getValidMembers( $dimensionalNode ); if ( count( $members ) ) { $parentNode['members'] = $members; } return true; }
[ "protected", "function", "beforeDimensionalPruned", "(", "$", "dimensionalNode", ",", "&", "$", "parentNode", ")", "{", "return", "parent", "::", "beforeDimensionalPruned", "(", "$", "dimensionalNode", ",", "$", "parentNode", ")", ";", "// The dimensional information ...
This function is overridden to add the members to the parent node before it is deleted @param array $dimensionalNode A node which has element 'nodeclass' === 'dimensional' @param array $parentNode The parent node so it can be updated @return bool True if the dimensional information should be deleted
[ "This", "function", "is", "overridden", "to", "add", "the", "members", "to", "the", "parent", "node", "before", "it", "is", "deleted" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L835-L850
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.primaryItemsAllowed
protected function primaryItemsAllowed( $nodes, $roleRefKey ) { foreach ( $nodes as $nodeKey => $node ) { if ( $this->nodeIsHypercube( $node ) ) return true; if ( ! isset( $node['children'] ) || ! count( $node['children'] ) ) continue; $result = $this->primaryItemsAllowed( $node['children'], $roleRefKey ); if ( $result ) return true; } return false; }
php
protected function primaryItemsAllowed( $nodes, $roleRefKey ) { foreach ( $nodes as $nodeKey => $node ) { if ( $this->nodeIsHypercube( $node ) ) return true; if ( ! isset( $node['children'] ) || ! count( $node['children'] ) ) continue; $result = $this->primaryItemsAllowed( $node['children'], $roleRefKey ); if ( $result ) return true; } return false; }
[ "protected", "function", "primaryItemsAllowed", "(", "$", "nodes", ",", "$", "roleRefKey", ")", "{", "foreach", "(", "$", "nodes", "as", "$", "nodeKey", "=>", "$", "node", ")", "{", "if", "(", "$", "this", "->", "nodeIsHypercube", "(", "$", "node", ")"...
Provides a descendant implementation a chance to define whether or not primary items are allowed for a node in a presentation hierarchy In US-GAAP taxonomies, primary items are only relevant when there is a statement table. Without this check, invalid hypercubes and dimensions can be added. @param array $nodes An array of presentation hierarchy nodes @param string $roleRefKey @return bool True if primary items are allowed (default: true)
[ "Provides", "a", "descendant", "implementation", "a", "chance", "to", "define", "whether", "or", "not", "primary", "items", "are", "allowed", "for", "a", "node", "in", "a", "presentation", "hierarchy", "In", "US", "-", "GAAP", "taxonomies", "primary", "items",...
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L1044-L1056
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.accumulateCommonHypercubesForNode
protected function accumulateCommonHypercubesForNode( $node, $roleRefKey ) { return ! $this->nodeIsHypercube( $node ); return ! $this->nodeIsHypercube( $node ) && ! $this->nodeIsLineItemsAxis( $node ); }
php
protected function accumulateCommonHypercubesForNode( $node, $roleRefKey ) { return ! $this->nodeIsHypercube( $node ); return ! $this->nodeIsHypercube( $node ) && ! $this->nodeIsLineItemsAxis( $node ); }
[ "protected", "function", "accumulateCommonHypercubesForNode", "(", "$", "node", ",", "$", "roleRefKey", ")", "{", "return", "!", "$", "this", "->", "nodeIsHypercube", "(", "$", "node", ")", ";", "return", "!", "$", "this", "->", "nodeIsHypercube", "(", "$", ...
Provides a descendant implementation a chance to define whether or not common hypercubes should be accumulated for a node. @param array $node An array of presentation hierarchy nodes @param string $roleRefKey @return bool True if primary items are allowed (default: true)
[ "Provides", "a", "descendant", "implementation", "a", "chance", "to", "define", "whether", "or", "not", "common", "hypercubes", "should", "be", "accumulated", "for", "a", "node", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L1064-L1070
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.displayNode
public function displayNode( $node ) { return ! isset( $node['label'] ) || ( ! $this->nodeIsHypercube( $node ) && ! $this->nodeIsLineItemsAxis( $node ) && ! $this->nodeIsAxis( $node ) /* && ( ( isset( $node['children'] ) && count( $node['children'] ) ) || ( isset( $node['elements'] ) && count( $node['elements'] ) ) ) */ ); }
php
public function displayNode( $node ) { return ! isset( $node['label'] ) || ( ! $this->nodeIsHypercube( $node ) && ! $this->nodeIsLineItemsAxis( $node ) && ! $this->nodeIsAxis( $node ) /* && ( ( isset( $node['children'] ) && count( $node['children'] ) ) || ( isset( $node['elements'] ) && count( $node['elements'] ) ) ) */ ); }
[ "public", "function", "displayNode", "(", "$", "node", ")", "{", "return", "!", "isset", "(", "$", "node", "[", "'label'", "]", ")", "||", "(", "!", "$", "this", "->", "nodeIsHypercube", "(", "$", "node", ")", "&&", "!", "$", "this", "->", "nodeIsL...
Return false if the node should not be displayed. May delegate to the taxonomy instance. @param array $node @return bool
[ "Return", "false", "if", "the", "node", "should", "not", "be", "displayed", ".", "May", "delegate", "to", "the", "taxonomy", "instance", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L1077-L1089
train
bseddon/XBRL
XBRL-US-GAAP-2015.php
XBRL_US_GAAP_2015.getTaxonomyDescriptionForId
public function getTaxonomyDescriptionForId( $href, $roles = null, $lang = null, $extendedLinkRole = null ) { $result = parent::getTaxonomyDescriptionForId( $href, $roles, $lang, $extendedLinkRole ); if ( ! $result ) { // Swap the labels with those of the base taxonomy if ( parent::swapLabelsFromBackup() ) { // Try looking for the label $result = parent::getTaxonomyDescriptionForId( $href, $roles, $lang ); // Swap the labels back parent::swapLabelsFromBackup(); } // Last resort if ( ! $result && $this->getBaseTaxonomy() !== null ) { // Swap the labels with those of the base taxonomy if ( parent::swapLabelsFromBackup() ) { // Try looking for the label $result = parent::getTaxonomyDescriptionForId( $this->getBaseTaxonomy() . '#' . $href, $roles, $lang ); // Swap the labels back parent::swapLabelsFromBackup(); } } } return $result; }
php
public function getTaxonomyDescriptionForId( $href, $roles = null, $lang = null, $extendedLinkRole = null ) { $result = parent::getTaxonomyDescriptionForId( $href, $roles, $lang, $extendedLinkRole ); if ( ! $result ) { // Swap the labels with those of the base taxonomy if ( parent::swapLabelsFromBackup() ) { // Try looking for the label $result = parent::getTaxonomyDescriptionForId( $href, $roles, $lang ); // Swap the labels back parent::swapLabelsFromBackup(); } // Last resort if ( ! $result && $this->getBaseTaxonomy() !== null ) { // Swap the labels with those of the base taxonomy if ( parent::swapLabelsFromBackup() ) { // Try looking for the label $result = parent::getTaxonomyDescriptionForId( $this->getBaseTaxonomy() . '#' . $href, $roles, $lang ); // Swap the labels back parent::swapLabelsFromBackup(); } } } return $result; }
[ "public", "function", "getTaxonomyDescriptionForId", "(", "$", "href", ",", "$", "roles", "=", "null", ",", "$", "lang", "=", "null", ",", "$", "extendedLinkRole", "=", "null", ")", "{", "$", "result", "=", "parent", "::", "getTaxonomyDescriptionForId", "(",...
Returns a description for an element identified by href @param string $href The id of the element for which a description is to be retrieved. If only the fragment is provided, its assumed to be from the current taxonomy. @param null|array[string] (optional) $roles If true include the element text in the result. If the argument is an array it will be an array of preferred labels. @param null|string $lang (optional) a language locale @param string $extendedLinkRole (optional) The ELR to apply when calling the parent getTaxonomyDescriptionForId @return bool|string A description string or false
[ "Returns", "a", "description", "for", "an", "element", "identified", "by", "href" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-US-GAAP-2015.php#L1172-L1204
train
bseddon/XBRL
XBRL-Signer.php
XBRL_Signer.sign_taxonomy
public function sign_taxonomy( $source, $private_key_pem, $signature_alg = "SHA256" ) { $json = $source; $filename = $this->get_source_filename( $source ); if ( $filename ) { $json = $this->get_json( $filename ); } $taxonomy = $this->get_taxonomy( $json ); // Is there a signature? If so remove it and re-generate the string if ( isset( $taxonomy['signature_block'] ) ) { unset( $taxonomy['signature_block'] ); $json = json_encode( $taxonomy ); } $signature = $this->generate_signature( $json, $private_key_pem, $signature_alg ); $taxonomy['signature_block'] = array( 'signature' => $signature, 'algorithm' => 'sha256', ); $json = json_encode( $taxonomy ); if ( $filename ) { $this->save_json( $json, $filename ); return true; } else { return $json; } }
php
public function sign_taxonomy( $source, $private_key_pem, $signature_alg = "SHA256" ) { $json = $source; $filename = $this->get_source_filename( $source ); if ( $filename ) { $json = $this->get_json( $filename ); } $taxonomy = $this->get_taxonomy( $json ); // Is there a signature? If so remove it and re-generate the string if ( isset( $taxonomy['signature_block'] ) ) { unset( $taxonomy['signature_block'] ); $json = json_encode( $taxonomy ); } $signature = $this->generate_signature( $json, $private_key_pem, $signature_alg ); $taxonomy['signature_block'] = array( 'signature' => $signature, 'algorithm' => 'sha256', ); $json = json_encode( $taxonomy ); if ( $filename ) { $this->save_json( $json, $filename ); return true; } else { return $json; } }
[ "public", "function", "sign_taxonomy", "(", "$", "source", ",", "$", "private_key_pem", ",", "$", "signature_alg", "=", "\"SHA256\"", ")", "{", "$", "json", "=", "$", "source", ";", "$", "filename", "=", "$", "this", "->", "get_source_filename", "(", "$", ...
Sign and save the signed taxonomy. @param string $source The source of the JSON @param string $private_key_pem Path to a PEM formatted file containing the private key or a string containing the private key @param string $signature_alg The name the hash algorithm to use (Default: SHA256) @return string
[ "Sign", "and", "save", "the", "signed", "taxonomy", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Signer.php#L37-L73
train
bseddon/XBRL
XBRL-Signer.php
XBRL_Signer.verify_taxonomy
function verify_taxonomy( $source, $public_key_pem ) { $json = $source; $filename = $this->get_source_filename( $source ); if ( $filename ) { // Get the json from $source. It will throw an exception if there's a problem. $json = $this->get_json( $filename ); } // Recreate the object hierarchy. It will throw an exception if there's a problem. $taxonomy = $this->get_taxonomy( $json ); // Is there a signature? If so remove it and re-generate the string if ( ! isset( $taxonomy['signature_block'] ) ) { $message = "The taxonomy does not contain a signature block"; throw new \Exception( $message ); } // There is so grab it and delete it from the $taxonomy $signature_block = $taxonomy['signature_block']; unset( $taxonomy['signature_block'] ); // Check the signature block if ( ! isset( $signature_block['signature'] ) || ! isset( $signature_block['algorithm'] ) ) { $message = "The signature block is not valid"; throw new \Exception( $message ); } // The existing signature is base64 encoded $signature = base64_decode( $signature_block['signature'] ); // Time to re-encode so the signature can be tested. $json = json_encode( $taxonomy ); // The function openssl_pkey_get_public always works with URLs so if necessary convert // the $public_key_pem variable to a URL using a 'file' scheme. If there is no scheme // or the scheme is a letter A-Z then a local path is being used and needs converting. $parts = parse_url( $public_key_pem ); if ( ( ! isset( $parts['scheme'] ) || preg_match( "/^[A-Z]$/", $parts['scheme'] ) ) && ! isset( $parts['host'] ) ) { $public_key_pem = "file://"; if ( isset( $parts['scheme'] ) ) $public_key_pem .= $parts['scheme'] . ":"; $public_key_pem .= $parts['path']; } // Check its possible to create a public key id $public_key = openssl_pkey_get_public( $public_key_pem ); if ( $public_key === false ) { $message = "Unable to create a key id from the public key resource $pem\n" . openssl_error_string(); throw new \Exception( $message ); } $result = openssl_verify( $json, $signature, $public_key, $signature_block['algorithm'] ); if ( $result == -1 ) { $message = "Error verifying: " . openssl_error_string(); } openssl_free_key( $public_key ); return $result; }
php
function verify_taxonomy( $source, $public_key_pem ) { $json = $source; $filename = $this->get_source_filename( $source ); if ( $filename ) { // Get the json from $source. It will throw an exception if there's a problem. $json = $this->get_json( $filename ); } // Recreate the object hierarchy. It will throw an exception if there's a problem. $taxonomy = $this->get_taxonomy( $json ); // Is there a signature? If so remove it and re-generate the string if ( ! isset( $taxonomy['signature_block'] ) ) { $message = "The taxonomy does not contain a signature block"; throw new \Exception( $message ); } // There is so grab it and delete it from the $taxonomy $signature_block = $taxonomy['signature_block']; unset( $taxonomy['signature_block'] ); // Check the signature block if ( ! isset( $signature_block['signature'] ) || ! isset( $signature_block['algorithm'] ) ) { $message = "The signature block is not valid"; throw new \Exception( $message ); } // The existing signature is base64 encoded $signature = base64_decode( $signature_block['signature'] ); // Time to re-encode so the signature can be tested. $json = json_encode( $taxonomy ); // The function openssl_pkey_get_public always works with URLs so if necessary convert // the $public_key_pem variable to a URL using a 'file' scheme. If there is no scheme // or the scheme is a letter A-Z then a local path is being used and needs converting. $parts = parse_url( $public_key_pem ); if ( ( ! isset( $parts['scheme'] ) || preg_match( "/^[A-Z]$/", $parts['scheme'] ) ) && ! isset( $parts['host'] ) ) { $public_key_pem = "file://"; if ( isset( $parts['scheme'] ) ) $public_key_pem .= $parts['scheme'] . ":"; $public_key_pem .= $parts['path']; } // Check its possible to create a public key id $public_key = openssl_pkey_get_public( $public_key_pem ); if ( $public_key === false ) { $message = "Unable to create a key id from the public key resource $pem\n" . openssl_error_string(); throw new \Exception( $message ); } $result = openssl_verify( $json, $signature, $public_key, $signature_block['algorithm'] ); if ( $result == -1 ) { $message = "Error verifying: " . openssl_error_string(); } openssl_free_key( $public_key ); return $result; }
[ "function", "verify_taxonomy", "(", "$", "source", ",", "$", "public_key_pem", ")", "{", "$", "json", "=", "$", "source", ";", "$", "filename", "=", "$", "this", "->", "get_source_filename", "(", "$", "source", ")", ";", "if", "(", "$", "filename", ")"...
Verify the taxonomy using a public key @param string $source The source of the JSON @param string $public_key_pem Path to a PEM formatted file containing a certificate or the public key or a string containing the public key for the private key used to generate the signature. @throws \Exception Throws an exception if the taxonomy cannot be created or if the taxonomy is not signed or if there is a problem verifying. @return boolean True if the verification succeed. False if something changed.
[ "Verify", "the", "taxonomy", "using", "a", "public", "key" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Signer.php#L85-L151
train
bseddon/XBRL
XBRL-Signer.php
XBRL_Signer.generate_signature
private function generate_signature( $content, $private_key_pem, $signature_alg = "SHA256" ) { // The function openssl_pkey_get_private always works with URLs so if necessary convert // the $private_key_pem variable to a URL using a 'file' scheme. If there is no scheme // or the scheme is a letter A-Z then a local path is being used and needs converting. $parts = parse_url( $private_key_pem ); if ( ( ! isset( $parts['scheme'] ) || preg_match( "/^[A-Z]$/", $parts['scheme'] ) ) && ! isset( $parts['host'] ) ) { $private_key_pem = "file://"; if ( isset( $parts['scheme'] ) ) $private_key_pem .= $parts['scheme'] . ":"; $private_key_pem .= $parts['path']; } $private_key = openssl_pkey_get_private( $private_key_pem ); if ( $private_key === false ) { $message = "Unable to create a key id from the private key resource $pem\n" . openssl_error_string(); throw new \Exception( $message ); } $signature = null; $result = openssl_sign( $content, $signature, $private_key, $signature_alg ); if ( ! $result ) { $message = "Error to signing: " . openssl_error_string(); } openssl_free_key( $private_key ); if ( ! $result ) throw new \Exception( $message ); return base64_encode( $signature ); }
php
private function generate_signature( $content, $private_key_pem, $signature_alg = "SHA256" ) { // The function openssl_pkey_get_private always works with URLs so if necessary convert // the $private_key_pem variable to a URL using a 'file' scheme. If there is no scheme // or the scheme is a letter A-Z then a local path is being used and needs converting. $parts = parse_url( $private_key_pem ); if ( ( ! isset( $parts['scheme'] ) || preg_match( "/^[A-Z]$/", $parts['scheme'] ) ) && ! isset( $parts['host'] ) ) { $private_key_pem = "file://"; if ( isset( $parts['scheme'] ) ) $private_key_pem .= $parts['scheme'] . ":"; $private_key_pem .= $parts['path']; } $private_key = openssl_pkey_get_private( $private_key_pem ); if ( $private_key === false ) { $message = "Unable to create a key id from the private key resource $pem\n" . openssl_error_string(); throw new \Exception( $message ); } $signature = null; $result = openssl_sign( $content, $signature, $private_key, $signature_alg ); if ( ! $result ) { $message = "Error to signing: " . openssl_error_string(); } openssl_free_key( $private_key ); if ( ! $result ) throw new \Exception( $message ); return base64_encode( $signature ); }
[ "private", "function", "generate_signature", "(", "$", "content", ",", "$", "private_key_pem", ",", "$", "signature_alg", "=", "\"SHA256\"", ")", "{", "// The function openssl_pkey_get_private always works with URLs so if necessary convert\r", "// the $private_key_pem variable to a...
Sign content to produce a signature using a private key @param string $content The content to be signed @param string $private_key_pem The private key in PEM format. Can be a string containing the key or a path to a file containing the key. @param string $signature_alg The name the hash algorithm to use (Default: SHA256) @throws \Exception An exception will be thrown if the private key cannnot be opened or used or if there is a problem signing. @return string The signature
[ "Sign", "content", "to", "produce", "a", "signature", "using", "a", "private", "key" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Signer.php#L165-L200
train
bseddon/XBRL
XBRL-Signer.php
XBRL_Signer.get_taxonomy
private function get_taxonomy( $json ) { $taxonomy = json_decode( $json, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { $error = "Error accessing the taxonomy" . XBRL::json_last_error_msg(); throw new \Exception( "$error" ); } return $taxonomy; }
php
private function get_taxonomy( $json ) { $taxonomy = json_decode( $json, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { $error = "Error accessing the taxonomy" . XBRL::json_last_error_msg(); throw new \Exception( "$error" ); } return $taxonomy; }
[ "private", "function", "get_taxonomy", "(", "$", "json", ")", "{", "$", "taxonomy", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "$", "error", "=", "\"Error acces...
Create a taxonomy array structure @param string $json The raw JSON @throws \Exception An exception will be thrown if there is a problem parsing the JSON @return array
[ "Create", "a", "taxonomy", "array", "structure" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Signer.php#L264-L275
train
bseddon/XBRL
XBRL-Signer.php
XBRL_Signer.save_json
private function save_json( $json, $filename) { $extension = pathinfo( $filename, PATHINFO_EXTENSION ); $output_basename = pathinfo( $filename, PATHINFO_FILENAME ); if ( $extension == 'zip' ) { /** * @var ZipArchive $zip */ $zip = new ZipArchive(); $zip->open( $filename, ZipArchive::CREATE ); $zip->addFromString( "$output_basename.json", $json ); if ( $zip->close() === false ) { $message = "Error closing zip file: " . $zip->getStatusString(); throw new \Exception( $message ); } } else if ( $extension != 'json' ) { $message = "Only files with .zip or .json extension are supported"; throw new \Exception( $message ); } else { if ( file_put_contents( $filename, $json ) === false ) { $message = "Failed to write "; throw new \Exception( $message ); } } }
php
private function save_json( $json, $filename) { $extension = pathinfo( $filename, PATHINFO_EXTENSION ); $output_basename = pathinfo( $filename, PATHINFO_FILENAME ); if ( $extension == 'zip' ) { /** * @var ZipArchive $zip */ $zip = new ZipArchive(); $zip->open( $filename, ZipArchive::CREATE ); $zip->addFromString( "$output_basename.json", $json ); if ( $zip->close() === false ) { $message = "Error closing zip file: " . $zip->getStatusString(); throw new \Exception( $message ); } } else if ( $extension != 'json' ) { $message = "Only files with .zip or .json extension are supported"; throw new \Exception( $message ); } else { if ( file_put_contents( $filename, $json ) === false ) { $message = "Failed to write "; throw new \Exception( $message ); } } }
[ "private", "function", "save_json", "(", "$", "json", ",", "$", "filename", ")", "{", "$", "extension", "=", "pathinfo", "(", "$", "filename", ",", "PATHINFO_EXTENSION", ")", ";", "$", "output_basename", "=", "pathinfo", "(", "$", "filename", ",", "PATHINF...
Save the JSON to file. If the filename ends in .zip the file will be stored in a zip archive. @param string $json The raw JSON @param string $filename The name to use for the saved file @throws \Exception Throws an exception if the zip file cannot be created, if the JSOn file cannot be written or if the extension is invalid
[ "Save", "the", "JSON", "to", "file", ".", "If", "the", "filename", "ends", "in", ".", "zip", "the", "file", "will", "be", "stored", "in", "a", "zip", "archive", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Signer.php#L283-L316
train
bseddon/XBRL
XBRL-TaxonomyPackageException.php
XBRL_TaxonomyPackageException.withError
public static function withError( $error, $message ) { $ex = new XBRL_TaxonomyPackageException( $message ); $ex->error = $error; return $ex; }
php
public static function withError( $error, $message ) { $ex = new XBRL_TaxonomyPackageException( $message ); $ex->error = $error; return $ex; }
[ "public", "static", "function", "withError", "(", "$", "error", ",", "$", "message", ")", "{", "$", "ex", "=", "new", "XBRL_TaxonomyPackageException", "(", "$", "message", ")", ";", "$", "ex", "->", "error", "=", "$", "error", ";", "return", "$", "ex",...
Create an exception type with a taxonomy package error @param string QName of the error code being reported @param string $message @return \XBRL\Formulas\Resources\FormulasException
[ "Create", "an", "exception", "type", "with", "a", "taxonomy", "package", "error" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-TaxonomyPackageException.php#L48-L54
train
bseddon/XBRL
Formulas/Resources/Filters/Boolean.php
Boolean.toQuery
public function toQuery( $variableSet, $factVariableBinding ) { $result = array(); if ( count( $this->filters ) == 0 ) { return array( "false()" ); } foreach ( $this->filters as $filter ) { $filter->inBoolean = true; $query = $filter->toQuery( $variableSet, $factVariableBinding ); if ( $filter->complement ) { $query = "not($query)"; } $result[] = $query; } return $result; }
php
public function toQuery( $variableSet, $factVariableBinding ) { $result = array(); if ( count( $this->filters ) == 0 ) { return array( "false()" ); } foreach ( $this->filters as $filter ) { $filter->inBoolean = true; $query = $filter->toQuery( $variableSet, $factVariableBinding ); if ( $filter->complement ) { $query = "not($query)"; } $result[] = $query; } return $result; }
[ "public", "function", "toQuery", "(", "$", "variableSet", ",", "$", "factVariableBinding", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "filters", ")", "==", "0", ")", "{", "return", "array", "(", ...
Converts the filters to a collection of XPath queries @param VariableSet $variableSet @param FactVariableBinding $factVariableBinding @return string
[ "Converts", "the", "filters", "to", "a", "collection", "of", "XPath", "queries" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Filters/Boolean.php#L57-L79
train
bseddon/XBRL
Formulas/Resources/Filters/Boolean.php
Boolean.validate
public function validate( $variableSet, $nsMgr ) { $arcs = $variableSet->xbrlTaxonomy->getGenericArc( \XBRL_Constants::$arcRoleBooleanFilter, $this->linkRoleUri, $this->label, $this->path ); /** * @var array[Filter] $filters */ $filters = array(); foreach ( $arcs as $arc ) { // BMS 2019-02-11 if ( $this->path != $arc['frompath'] ) continue; $variableSet->xbrlTaxonomy->getGenericResource( 'filter', null, function( $roleUri, $linkbase, $variableSetName, $index, $resource ) use( &$filters, $arc ) { // if ( $resource['label'] != $arc['to'] ) return true; if ( $resource['path'] != $arc['topath'] /* || $linkbase != $arc['linkbase'] */ ) return true; if ( $arc['attributes'] ) { foreach ( $arc['attributes'] as $name => $attribute ) { $value = $attribute['type'] == "xs:boolean" ? (bool)$attribute['value'] : $attribute['value']; $resource[ $name ] = $value; } } $filterResources[] = $resource; $className = __NAMESPACE__ . '\\' . ucfirst( $resource['filterType'] ); $filters[] = $className::fromArray( $resource ); return true; }, $arc['toRoleUri'], $arc['to'], $arc['tolinkbase'] ); } foreach ( $filters as $filter ) { if ( ! $filter->validate( $variableSet, $nsMgr ) ) { return false; } } $this->filters = $filters; return true; }
php
public function validate( $variableSet, $nsMgr ) { $arcs = $variableSet->xbrlTaxonomy->getGenericArc( \XBRL_Constants::$arcRoleBooleanFilter, $this->linkRoleUri, $this->label, $this->path ); /** * @var array[Filter] $filters */ $filters = array(); foreach ( $arcs as $arc ) { // BMS 2019-02-11 if ( $this->path != $arc['frompath'] ) continue; $variableSet->xbrlTaxonomy->getGenericResource( 'filter', null, function( $roleUri, $linkbase, $variableSetName, $index, $resource ) use( &$filters, $arc ) { // if ( $resource['label'] != $arc['to'] ) return true; if ( $resource['path'] != $arc['topath'] /* || $linkbase != $arc['linkbase'] */ ) return true; if ( $arc['attributes'] ) { foreach ( $arc['attributes'] as $name => $attribute ) { $value = $attribute['type'] == "xs:boolean" ? (bool)$attribute['value'] : $attribute['value']; $resource[ $name ] = $value; } } $filterResources[] = $resource; $className = __NAMESPACE__ . '\\' . ucfirst( $resource['filterType'] ); $filters[] = $className::fromArray( $resource ); return true; }, $arc['toRoleUri'], $arc['to'], $arc['tolinkbase'] ); } foreach ( $filters as $filter ) { if ( ! $filter->validate( $variableSet, $nsMgr ) ) { return false; } } $this->filters = $filters; return true; }
[ "public", "function", "validate", "(", "$", "variableSet", ",", "$", "nsMgr", ")", "{", "$", "arcs", "=", "$", "variableSet", "->", "xbrlTaxonomy", "->", "getGenericArc", "(", "\\", "XBRL_Constants", "::", "$", "arcRoleBooleanFilter", ",", "$", "this", "->",...
Validate that there are filters for this boolean @param VariableSet $variableSet @param XmlNamespaceManager $nsMgr @return bool
[ "Validate", "that", "there", "are", "filters", "for", "this", "boolean" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Filters/Boolean.php#L87-L136
train
bseddon/XBRL
Formulas/VariableBinding.php
VariableBinding.resourceElementName
public function resourceElementName() { if ( $this->isFactVar ) return "Fact Variable"; else if ( $this->isGeneralVar ) return "General Variable"; else if ( $this->isParameter ) return "Parameter"; else if ( $this->var instanceof Tuple ) return "Tuple"; else if ( $this->var instanceof Formula ) return "Formula"; else if ( $this->var instanceof ValueAssertion ) return "ValueAssertion"; else if ( $this->var instanceof ExistenceAssertion ) return "ExistenceAssertion"; return false; }
php
public function resourceElementName() { if ( $this->isFactVar ) return "Fact Variable"; else if ( $this->isGeneralVar ) return "General Variable"; else if ( $this->isParameter ) return "Parameter"; else if ( $this->var instanceof Tuple ) return "Tuple"; else if ( $this->var instanceof Formula ) return "Formula"; else if ( $this->var instanceof ValueAssertion ) return "ValueAssertion"; else if ( $this->var instanceof ExistenceAssertion ) return "ExistenceAssertion"; return false; }
[ "public", "function", "resourceElementName", "(", ")", "{", "if", "(", "$", "this", "->", "isFactVar", ")", "return", "\"Fact Variable\"", ";", "else", "if", "(", "$", "this", "->", "isGeneralVar", ")", "return", "\"General Variable\"", ";", "else", "if", "(...
Return the name of the variable @return string|boolean
[ "Return", "the", "name", "of", "the", "variable" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/VariableBinding.php#L168-L178
train
bseddon/XBRL
Formulas/VariableBinding.php
VariableBinding.rewind
public function rewind() { if ( is_null( $this->facts ) ) { return false; } $result = $this->facts->rewind(); $this->yieldedFact = null; return $result; }
php
public function rewind() { if ( is_null( $this->facts ) ) { return false; } $result = $this->facts->rewind(); $this->yieldedFact = null; return $result; }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "facts", ")", ")", "{", "return", "false", ";", "}", "$", "result", "=", "$", "this", "->", "facts", "->", "rewind", "(", ")", ";", "$", "this", "->", ...
Implements the iterator rewind method
[ "Implements", "the", "iterator", "rewind", "method" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/VariableBinding.php#L210-L222
train
bseddon/XBRL
Formulas/VariableBinding.php
VariableBinding.current
public function current() { if ( is_null( $this->facts ) ) { return null; } $fact = $this->facts->current(); $this->yieldedFact = $fact; return $fact; }
php
public function current() { if ( is_null( $this->facts ) ) { return null; } $fact = $this->facts->current(); $this->yieldedFact = $fact; return $fact; }
[ "public", "function", "current", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "facts", ")", ")", "{", "return", "null", ";", "}", "$", "fact", "=", "$", "this", "->", "facts", "->", "current", "(", ")", ";", "$", "this", "->", "...
Implements the iterator current method
[ "Implements", "the", "iterator", "current", "method" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/VariableBinding.php#L227-L238
train
bseddon/XBRL
XPathFunctions/lyquidity/iterators/InstanceFactsIterator.php
InstanceFactsIterator.__static
public static function __static() { InstanceFactsIterator::$itemSubstitutionGroup = array( \XBRL_Constants::$xbrliItem ); InstanceFactsIterator::$tupleSubstitutionGroup = array( \XBRL_Constants::$xbrliTuple ); InstanceFactsIterator::$nodeTest = XmlQualifiedNameTest::create( "substitutionGroup" ); }
php
public static function __static() { InstanceFactsIterator::$itemSubstitutionGroup = array( \XBRL_Constants::$xbrliItem ); InstanceFactsIterator::$tupleSubstitutionGroup = array( \XBRL_Constants::$xbrliTuple ); InstanceFactsIterator::$nodeTest = XmlQualifiedNameTest::create( "substitutionGroup" ); }
[ "public", "static", "function", "__static", "(", ")", "{", "InstanceFactsIterator", "::", "$", "itemSubstitutionGroup", "=", "array", "(", "\\", "XBRL_Constants", "::", "$", "xbrliItem", ")", ";", "InstanceFactsIterator", "::", "$", "tupleSubstitutionGroup", "=", ...
Function to initialize the static variables
[ "Function", "to", "initialize", "the", "static", "variables" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XPathFunctions/lyquidity/iterators/InstanceFactsIterator.php#L106-L111
train
bseddon/XBRL
XPathFunctions/lyquidity/iterators/InstanceFactsIterator.php
InstanceFactsIterator.fromIterator
public static function fromIterator( $context, $sourceIterator, $mode, $nonNilOnly = false ) { if ( ! $sourceIterator instanceof XPath2NodeIterator ) { return EmptyIterator::$Shared; } $test = new NodeTest( SequenceTypes::$Element ); $iterator = $mode == XFI_TUPLE_ITEMS || $mode == XFI_TUPLE_TUPLES ? ChildNodeIterator::fromNodeTest($context, $test, $sourceIterator ) : ChildOverDescendantsNodeIterator::fromParts( $context, array( $test ), $sourceIterator ); $result = new InstanceFactsIterator( $context ); $result->nonNilOnly = $nonNilOnly; $result->iterator = $iterator; if ( $mode == XFI_INSTANCE_ALL_FACTS ) { $result->substitutionGroups = array_merge( InstanceFactsIterator::$itemSubstitutionGroup, InstanceFactsIterator::$tupleSubstitutionGroup ); } else if ( $mode == XFI_INSTANCE_ITEMS || $mode == XFI_TUPLE_ITEMS ) { $result->substitutionGroups = InstanceFactsIterator::$itemSubstitutionGroup; } else if ( $mode == XFI_INSTANCE_TUPLES || $mode == XFI_TUPLE_TUPLES ) { $result->substitutionGroups = InstanceFactsIterator::$tupleSubstitutionGroup; } return $result; }
php
public static function fromIterator( $context, $sourceIterator, $mode, $nonNilOnly = false ) { if ( ! $sourceIterator instanceof XPath2NodeIterator ) { return EmptyIterator::$Shared; } $test = new NodeTest( SequenceTypes::$Element ); $iterator = $mode == XFI_TUPLE_ITEMS || $mode == XFI_TUPLE_TUPLES ? ChildNodeIterator::fromNodeTest($context, $test, $sourceIterator ) : ChildOverDescendantsNodeIterator::fromParts( $context, array( $test ), $sourceIterator ); $result = new InstanceFactsIterator( $context ); $result->nonNilOnly = $nonNilOnly; $result->iterator = $iterator; if ( $mode == XFI_INSTANCE_ALL_FACTS ) { $result->substitutionGroups = array_merge( InstanceFactsIterator::$itemSubstitutionGroup, InstanceFactsIterator::$tupleSubstitutionGroup ); } else if ( $mode == XFI_INSTANCE_ITEMS || $mode == XFI_TUPLE_ITEMS ) { $result->substitutionGroups = InstanceFactsIterator::$itemSubstitutionGroup; } else if ( $mode == XFI_INSTANCE_TUPLES || $mode == XFI_TUPLE_TUPLES ) { $result->substitutionGroups = InstanceFactsIterator::$tupleSubstitutionGroup; } return $result; }
[ "public", "static", "function", "fromIterator", "(", "$", "context", ",", "$", "sourceIterator", ",", "$", "mode", ",", "$", "nonNilOnly", "=", "false", ")", "{", "if", "(", "!", "$", "sourceIterator", "instanceof", "XPath2NodeIterator", ")", "{", "return", ...
Static Constructor creates an instance from an iterator created by the caller @param XPath2Context $context @param XPath2NodeIterator $sourceIterator @param int One of XFI_INSTANCE_ALL_FACTS, XFI_INSTANCE_ITEMS, XFI_INSTANCE_TUPLES, XFI_TUPLE_ITEMS @param bool $nonNilOnly (optional) Default is false @return InstanceFactsIterator
[ "Static", "Constructor", "creates", "an", "instance", "from", "an", "iterator", "created", "by", "the", "caller" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XPathFunctions/lyquidity/iterators/InstanceFactsIterator.php#L131-L161
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.findCachedFile
public function findCachedFile( $url ) { if ( ! $this->useCache ) return false; $path = str_replace( '//', '/', XBRL_Global::createPathFromUrl( $url, $this->cacheLocation ) ); return file_exists( $path ) ? $path : false; }
php
public function findCachedFile( $url ) { if ( ! $this->useCache ) return false; $path = str_replace( '//', '/', XBRL_Global::createPathFromUrl( $url, $this->cacheLocation ) ); return file_exists( $path ) ? $path : false; }
[ "public", "function", "findCachedFile", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "useCache", ")", "return", "false", ";", "$", "path", "=", "str_replace", "(", "'//'", ",", "'/'", ",", "XBRL_Global", "::", "createPathFromUrl", "(", ...
Find a file in the cache if it exists. If it exists return the path or return false. @param string $url @return false|string
[ "Find", "a", "file", "in", "the", "cache", "if", "it", "exists", ".", "If", "it", "exists", "return", "the", "path", "or", "return", "false", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L266-L275
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.getTaxonomyWithPrefix
public function getTaxonomyWithPrefix( $prefix ) { if ( ! $prefix ) return false; foreach ( $this->importedSchemas as $taxonomy ) { if ( $taxonomy->getPrefix() == $prefix ) { return $taxonomy; } } return false; }
php
public function getTaxonomyWithPrefix( $prefix ) { if ( ! $prefix ) return false; foreach ( $this->importedSchemas as $taxonomy ) { if ( $taxonomy->getPrefix() == $prefix ) { return $taxonomy; } } return false; }
[ "public", "function", "getTaxonomyWithPrefix", "(", "$", "prefix", ")", "{", "if", "(", "!", "$", "prefix", ")", "return", "false", ";", "foreach", "(", "$", "this", "->", "importedSchemas", "as", "$", "taxonomy", ")", "{", "if", "(", "$", "taxonomy", ...
Return a taxonomy that is associated with a prefix @param string $prefix @return boolean|XBRL
[ "Return", "a", "taxonomy", "that", "is", "associated", "with", "a", "prefix" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L313-L326
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.getTaxonomiesWithArcRoleTypeId
public function getTaxonomiesWithArcRoleTypeId( $id ) { return array_filter( $this->importedSchemas, function( /** @var XBRL $taxonomy */ $taxonomy ) use( $id ) { return $taxonomy->hasArcRoleTypeId( $id ); } ); }
php
public function getTaxonomiesWithArcRoleTypeId( $id ) { return array_filter( $this->importedSchemas, function( /** @var XBRL $taxonomy */ $taxonomy ) use( $id ) { return $taxonomy->hasArcRoleTypeId( $id ); } ); }
[ "public", "function", "getTaxonomiesWithArcRoleTypeId", "(", "$", "id", ")", "{", "return", "array_filter", "(", "$", "this", "->", "importedSchemas", ",", "function", "(", "/** @var XBRL $taxonomy */", "$", "taxonomy", ")", "use", "(", "$", "id", ")", "{", "r...
Returns an array of any taxonomies where the id is one for an arcrole type @param string $id @return XBRL[]
[ "Returns", "an", "array", "of", "any", "taxonomies", "where", "the", "id", "is", "one", "for", "an", "arcrole", "type" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L333-L339
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.createPathFromUrl
public static function createPathFromUrl( $url, $cacheLocation ) { $parts = parse_url( $url ); $path = str_replace( '\\', '/', rtrim( $cacheLocation, '\\/' ) ); if ( isset( $parts['scheme'] ) ) $path .= "/{$parts['scheme']}"; if ( isset( $parts['host'] ) ) $path .= "/{$parts['host']}"; if ( isset( $parts['path'] ) ) $path .= "/{$parts['path']}"; return $path; }
php
public static function createPathFromUrl( $url, $cacheLocation ) { $parts = parse_url( $url ); $path = str_replace( '\\', '/', rtrim( $cacheLocation, '\\/' ) ); if ( isset( $parts['scheme'] ) ) $path .= "/{$parts['scheme']}"; if ( isset( $parts['host'] ) ) $path .= "/{$parts['host']}"; if ( isset( $parts['path'] ) ) $path .= "/{$parts['path']}"; return $path; }
[ "public", "static", "function", "createPathFromUrl", "(", "$", "url", ",", "$", "cacheLocation", ")", "{", "$", "parts", "=", "parse_url", "(", "$", "url", ")", ";", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "rtrim", "(", "$", ...
Create a path to the parallel folder for a url @param string $url @param string $cacheLocation @return string
[ "Create", "a", "path", "to", "the", "parallel", "folder", "for", "a", "url" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L347-L358
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.initializeCache
public function initializeCache() { if ( $this->cacheLocation === null ) { $this->cacheLocation = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'xbrl_taxonomy_cache' . DIRECTORY_SEPARATOR; } $this->cacheLocation = rtrim( $this->cacheLocation, '/' ) . '/'; // $this->log()->info( " Taxonomy cache location: " . $this->cacheLocation ); // The cache location must exist or be creatable if ( ! file_exists( $this->cacheLocation ) ) { // Attempt to create the directory if ( mkdir( $this->cacheLocation ) === false ) { $this->useCache = false; $this->log()->err( "Failed to create the XBRL taxonomy cache. Caching will be disabled." ); return; } } }
php
public function initializeCache() { if ( $this->cacheLocation === null ) { $this->cacheLocation = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'xbrl_taxonomy_cache' . DIRECTORY_SEPARATOR; } $this->cacheLocation = rtrim( $this->cacheLocation, '/' ) . '/'; // $this->log()->info( " Taxonomy cache location: " . $this->cacheLocation ); // The cache location must exist or be creatable if ( ! file_exists( $this->cacheLocation ) ) { // Attempt to create the directory if ( mkdir( $this->cacheLocation ) === false ) { $this->useCache = false; $this->log()->err( "Failed to create the XBRL taxonomy cache. Caching will be disabled." ); return; } } }
[ "public", "function", "initializeCache", "(", ")", "{", "if", "(", "$", "this", "->", "cacheLocation", "===", "null", ")", "{", "$", "this", "->", "cacheLocation", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'xbrl_taxonomy_cache'", "."...
Initializes the cache. Reads the cache if available or creates one. If there are problems, such as the cache location not being writeable the cache is disabled. @return void
[ "Initializes", "the", "cache", ".", "Reads", "the", "cache", "if", "available", "or", "creates", "one", ".", "If", "there", "are", "problems", "such", "as", "the", "cache", "location", "not", "being", "writeable", "the", "cache", "is", "disabled", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L407-L429
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.removeCache
public function removeCache() { if ( ! $this->useCache || ! $this->cacheLocation ) return false; if ( ! is_dir( $this->cacheLocation ) ) return false; $rmrf = function ($dir) use ( &$rmrf ) { foreach ( glob( $dir ) as $file ) { if ( is_dir( $file ) ) { $rmrf( "$file/*" ); rmdir( $file ); } else { unlink( $file ); } } }; $rmrf( $this->cacheLocation ); return true; }
php
public function removeCache() { if ( ! $this->useCache || ! $this->cacheLocation ) return false; if ( ! is_dir( $this->cacheLocation ) ) return false; $rmrf = function ($dir) use ( &$rmrf ) { foreach ( glob( $dir ) as $file ) { if ( is_dir( $file ) ) { $rmrf( "$file/*" ); rmdir( $file ); } else { unlink( $file ); } } }; $rmrf( $this->cacheLocation ); return true; }
[ "public", "function", "removeCache", "(", ")", "{", "if", "(", "!", "$", "this", "->", "useCache", "||", "!", "$", "this", "->", "cacheLocation", ")", "return", "false", ";", "if", "(", "!", "is_dir", "(", "$", "this", "->", "cacheLocation", ")", ")"...
Removes any cached file and directories @return boolean True if the directory exists and has been deleted
[ "Removes", "any", "cached", "file", "and", "directories" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L435-L460
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.addLabels
public function addLabels( $locators, $arcs, $labels, $labelsByHref, $extendedLinkRole = null ) { if ( is_null( $extendedLinkRole ) ) $extendedLinkRole = XBRL_Constants::$defaultLinkRole; $link = &$this->labels[ $extendedLinkRole ]; $link['locators'] = isset( $link['locators'] ) && count( $link['locators'] ) ? array_merge( $link['locators'], $locators ) : $locators; if ( isset( $link['arcs'] ) && count( $link['arcs'] ) ) { $link['arcs'] = array_merge_recursive( $link['arcs'], $arcs ); /* // Remove duplicates generated by the recursive merge function foreach ( $link['arcs'] as $label => &$labelLabels ) { foreach ( $labelLabels as $labelLabel => $items ) { if ( count( $items ) < 2 ) continue; $keep = array( $items[0] ); for ( $i = 1; $i < Count( $items ); $i++ ) { if ( $items[0]['label'] === $items[ $i ]['label'] && $items[0]['priority'] === $items[ $i ]['priority'] && $items[0]['use'] === $items[ $i ]['use'] ) { continue; } $keep[] = $items[ $i ]; } $labelLabels[ $labelLabel ] = $keep; } } unset( $labelLabels ); */ } else { $link['arcs'] = $arcs; } $link['labels'] = isset( $link['labels'] ) && count( $link['labels'] ) ? array_merge_recursive( $link['labels'], $labels ) : $labels; $link['labelshref'] = isset( $link['labelshref'] ) && count( $link['labelshref'] ) ? array_merge_recursive( $link['labelshref'], $labelsByHref ) : $labelsByHref; unset( $link ); }
php
public function addLabels( $locators, $arcs, $labels, $labelsByHref, $extendedLinkRole = null ) { if ( is_null( $extendedLinkRole ) ) $extendedLinkRole = XBRL_Constants::$defaultLinkRole; $link = &$this->labels[ $extendedLinkRole ]; $link['locators'] = isset( $link['locators'] ) && count( $link['locators'] ) ? array_merge( $link['locators'], $locators ) : $locators; if ( isset( $link['arcs'] ) && count( $link['arcs'] ) ) { $link['arcs'] = array_merge_recursive( $link['arcs'], $arcs ); /* // Remove duplicates generated by the recursive merge function foreach ( $link['arcs'] as $label => &$labelLabels ) { foreach ( $labelLabels as $labelLabel => $items ) { if ( count( $items ) < 2 ) continue; $keep = array( $items[0] ); for ( $i = 1; $i < Count( $items ); $i++ ) { if ( $items[0]['label'] === $items[ $i ]['label'] && $items[0]['priority'] === $items[ $i ]['priority'] && $items[0]['use'] === $items[ $i ]['use'] ) { continue; } $keep[] = $items[ $i ]; } $labelLabels[ $labelLabel ] = $keep; } } unset( $labelLabels ); */ } else { $link['arcs'] = $arcs; } $link['labels'] = isset( $link['labels'] ) && count( $link['labels'] ) ? array_merge_recursive( $link['labels'], $labels ) : $labels; $link['labelshref'] = isset( $link['labelshref'] ) && count( $link['labelshref'] ) ? array_merge_recursive( $link['labelshref'], $labelsByHref ) : $labelsByHref; unset( $link ); }
[ "public", "function", "addLabels", "(", "$", "locators", ",", "$", "arcs", ",", "$", "labels", ",", "$", "labelsByHref", ",", "$", "extendedLinkRole", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "extendedLinkRole", ")", ")", "$", "extendedLink...
Adds locators, arcs, labels and labelsByHref collections to the respective collections in XBRL_Global. This is called by the processLabelLinkbase and fromExtensionTaxonomy functions @param array $locators @param array $arcs @param array $labels @param array $labelsByHref @param string $extendedLinkRole (optional)
[ "Adds", "locators", "arcs", "labels", "and", "labelsByHref", "collections", "to", "the", "respective", "collections", "in", "XBRL_Global", ".", "This", "is", "called", "by", "the", "processLabelLinkbase", "and", "fromExtensionTaxonomy", "functions" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L508-L563
train
bseddon/XBRL
XBRL-Global.php
XBRL_Global.setEntityLoader
public function setEntityLoader( $schemaRoot ) { $this->schemaRoot = $schemaRoot; $useEntityLoader = true; // For debug convenience if ( version_compare( PHP_VERSION, "5.4", ">=" ) && $useEntityLoader ) { libxml_set_external_entity_loader( array( $this, 'entity_loader' ) ); } }
php
public function setEntityLoader( $schemaRoot ) { $this->schemaRoot = $schemaRoot; $useEntityLoader = true; // For debug convenience if ( version_compare( PHP_VERSION, "5.4", ">=" ) && $useEntityLoader ) { libxml_set_external_entity_loader( array( $this, 'entity_loader' ) ); } }
[ "public", "function", "setEntityLoader", "(", "$", "schemaRoot", ")", "{", "$", "this", "->", "schemaRoot", "=", "$", "schemaRoot", ";", "$", "useEntityLoader", "=", "true", ";", "// For debug convenience\r", "if", "(", "version_compare", "(", "PHP_VERSION", ","...
Enable the entity loader and pass a root as the basis for the discovery of non-http files @param string $schemaRoot The root path to the taxonomy files
[ "Enable", "the", "entity", "loader", "and", "pass", "a", "root", "as", "the", "basis", "for", "the", "discovery", "of", "non", "-", "http", "files" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Global.php#L586-L595
train
bseddon/XBRL
Formulas/ContextComparer.php
ContextComparer.ItemEqual
public function ItemEqual( $item1, $item2 ) { if ( $item1 instanceof DOMXPathNavigator && $item1->getNamespaceURI() == \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] && ( $item1->getLocalName() == 'instant' || $item1->getLocalName() == 'endDate' ) ) { // Parent MUST be period $parent = $item1->CloneInstance(); if ( $parent->MoveToParent() ) { if ( $parent->getLocalName() == 'period' ) { // OK, got two dates. If one has the format <date>T<time> and the other does not then compare them carefully. $item1Value = trim( $item1->getValue() ); $item2Value = trim( $item2->getValue() ); if ( ( strpos( $item1Value, "T" ) !== false && strpos( $item2Value, "T" ) === false ) || ( strpos( $item2Value, "T" ) !== false && strpos( $item1Value, "T" ) === false ) ) { $item1 = $item1->getTypedValue(); $item2 = $item2->getTypedValue(); // One of the values has a 'T' format. If one of them has 00:00:00 then create a revised date if ( strpos( $item1Value, "00:00:00" ) !== false ) { $item1 = DateTimeValue::AddDayTimeDuration( $item1, DayTimeDurationValue::Parse("-P1D") ); $item1 = DateValue::fromDate( $item1->S, $item1->getValue(), ! $item1->IsLocal ); } else if ( strpos( $item2Value, "00:00:00" ) !== false ) { $item2 = DateTimeValue::AddDayTimeDuration( $item2, DayTimeDurationValue::Parse("-P1D") ); $item2 = DateValue::fromDate( $item2->S, $item2->getValue(), ! $item2->IsLocal ); } $item1 = XPath2Item::fromValue( $item1 ); $item2 = XPath2Item::fromValue( $item2 ); } } } } return parent::ItemEqual( $item1, $item2 ); }
php
public function ItemEqual( $item1, $item2 ) { if ( $item1 instanceof DOMXPathNavigator && $item1->getNamespaceURI() == \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] && ( $item1->getLocalName() == 'instant' || $item1->getLocalName() == 'endDate' ) ) { // Parent MUST be period $parent = $item1->CloneInstance(); if ( $parent->MoveToParent() ) { if ( $parent->getLocalName() == 'period' ) { // OK, got two dates. If one has the format <date>T<time> and the other does not then compare them carefully. $item1Value = trim( $item1->getValue() ); $item2Value = trim( $item2->getValue() ); if ( ( strpos( $item1Value, "T" ) !== false && strpos( $item2Value, "T" ) === false ) || ( strpos( $item2Value, "T" ) !== false && strpos( $item1Value, "T" ) === false ) ) { $item1 = $item1->getTypedValue(); $item2 = $item2->getTypedValue(); // One of the values has a 'T' format. If one of them has 00:00:00 then create a revised date if ( strpos( $item1Value, "00:00:00" ) !== false ) { $item1 = DateTimeValue::AddDayTimeDuration( $item1, DayTimeDurationValue::Parse("-P1D") ); $item1 = DateValue::fromDate( $item1->S, $item1->getValue(), ! $item1->IsLocal ); } else if ( strpos( $item2Value, "00:00:00" ) !== false ) { $item2 = DateTimeValue::AddDayTimeDuration( $item2, DayTimeDurationValue::Parse("-P1D") ); $item2 = DateValue::fromDate( $item2->S, $item2->getValue(), ! $item2->IsLocal ); } $item1 = XPath2Item::fromValue( $item1 ); $item2 = XPath2Item::fromValue( $item2 ); } } } } return parent::ItemEqual( $item1, $item2 ); }
[ "public", "function", "ItemEqual", "(", "$", "item1", ",", "$", "item2", ")", "{", "if", "(", "$", "item1", "instanceof", "DOMXPathNavigator", "&&", "$", "item1", "->", "getNamespaceURI", "(", ")", "==", "\\", "XBRL_Constants", "::", "$", "standardPrefixes",...
Test if two items are equal Overridden so dates can be compared taking into account there relationship with the period end @param XPathItem $item1 @param XPathItem $item2 @return bool
[ "Test", "if", "two", "items", "are", "equal", "Overridden", "so", "dates", "can", "be", "compared", "taking", "into", "account", "there", "relationship", "with", "the", "period", "end" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/ContextComparer.php#L133-L175
train
bseddon/XBRL
XBRL-Report-Compare.php
XBRL_Report_Compare.preparePresentation
public function preparePresentation( $prune = true ) { $docs = $this->getInstanceDocuments(); $existingYears = null; foreach ( $docs as $instanceKey => $instance ) { $instanceYears = array(); foreach ( $instance->usedContexts as $key => $context ) { $instanceYears[ $context['year'] ] = $context['year']; } // Eliminate any years that are not in the valid years list if ( $this->validYears ) { $diffYears = array_diff( $instanceYears, $this->validYears ); if ( $diffYears ) { sort( $diffYears ); $omittedYears = implode( ",", $diffYears ); $this->log()->info( "Data in the instance document {$instance->getDocumentName()} for $omittedYears will not be included in the generated report." ); } $instanceYears = array_intersect( $instanceYears, $this->validYears ); } if ( $existingYears === null ) { $existingYears = $instanceYears; continue; } // Check the instances have overlaps. Order the arrays this way so the $instanceYears are checked $diffYears = array_diff( $instanceYears, $existingYears ) + array_diff( $existingYears, $instanceYears ); if ( ! $diffYears ) continue; if ( ! array_intersect( $diffYears, $instanceYears ) ) { $this->log()->info( "None of the years in instance {$instance->getDefaultCurrency()} overlap with other documents included in this report" ); } if ( count( array_intersect( $diffYears, $instanceYears ) ) !== count( $instanceYears ) ) { $omittedYears = implode( ",", $diffYears ); $this->log()->info( "Some of the years ($omittedYears) in instance {$instance->getDefaultCurrency()} do not overlap with other documents included in this report" ); } $existingYears = array_intersect_key( $existingYears, $instanceYears ); } if ( ! $existingYears ) { $message = $this->validYears ? "There are no years in the instance documents selected that match the valid years you have chosen" : "The instance documents you have selected contain no data."; throw new Exception( $message ); } // Make sure only $existingYears exist in $this->years $this->years = array_intersect_key( $this->years, $existingYears ); parent::preparePresentation( $prune ); }
php
public function preparePresentation( $prune = true ) { $docs = $this->getInstanceDocuments(); $existingYears = null; foreach ( $docs as $instanceKey => $instance ) { $instanceYears = array(); foreach ( $instance->usedContexts as $key => $context ) { $instanceYears[ $context['year'] ] = $context['year']; } // Eliminate any years that are not in the valid years list if ( $this->validYears ) { $diffYears = array_diff( $instanceYears, $this->validYears ); if ( $diffYears ) { sort( $diffYears ); $omittedYears = implode( ",", $diffYears ); $this->log()->info( "Data in the instance document {$instance->getDocumentName()} for $omittedYears will not be included in the generated report." ); } $instanceYears = array_intersect( $instanceYears, $this->validYears ); } if ( $existingYears === null ) { $existingYears = $instanceYears; continue; } // Check the instances have overlaps. Order the arrays this way so the $instanceYears are checked $diffYears = array_diff( $instanceYears, $existingYears ) + array_diff( $existingYears, $instanceYears ); if ( ! $diffYears ) continue; if ( ! array_intersect( $diffYears, $instanceYears ) ) { $this->log()->info( "None of the years in instance {$instance->getDefaultCurrency()} overlap with other documents included in this report" ); } if ( count( array_intersect( $diffYears, $instanceYears ) ) !== count( $instanceYears ) ) { $omittedYears = implode( ",", $diffYears ); $this->log()->info( "Some of the years ($omittedYears) in instance {$instance->getDefaultCurrency()} do not overlap with other documents included in this report" ); } $existingYears = array_intersect_key( $existingYears, $instanceYears ); } if ( ! $existingYears ) { $message = $this->validYears ? "There are no years in the instance documents selected that match the valid years you have chosen" : "The instance documents you have selected contain no data."; throw new Exception( $message ); } // Make sure only $existingYears exist in $this->years $this->years = array_intersect_key( $this->years, $existingYears ); parent::preparePresentation( $prune ); }
[ "public", "function", "preparePresentation", "(", "$", "prune", "=", "true", ")", "{", "$", "docs", "=", "$", "this", "->", "getInstanceDocuments", "(", ")", ";", "$", "existingYears", "=", "null", ";", "foreach", "(", "$", "docs", "as", "$", "instanceKe...
This function is overridden to check the validity of the instance documents included @param bool $prune True if the presentation hierarchies should be pruned to keep only items with elements assigned @return void
[ "This", "function", "is", "overridden", "to", "check", "the", "validity", "of", "the", "instance", "documents", "included" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Compare.php#L48-L112
train
bseddon/XBRL
Formulas/Resources/Assertions/VariableSetAssertion.php
VariableSetAssertion.getMessages
private function getMessages( $arcRole, $lang = null ) { $arcs = $this->xbrlTaxonomy->getGenericArc( $arcRole, $this->extendedLinkRoleUri, $this->label, $this->path, null, $this->linkbase ); $messages = array(); foreach ( $arcs as $arc ) { if ( $arc['frompath'] != $this->path ) continue; $this->xbrlTaxonomy->getGenericResource( 'message', 'message', function( $roleUri, $linkbase, $variableSetName, $index, $resource ) use( &$messages, $arc, $lang ) { // BMS 2019-02-11 // if ( $resource['label'] != $arc['to'] ) return true; if ( $resource['path'] != $arc['topath'] /* || $linkbase != $arc['linkbase'] */ ) return true; if ( ! is_null( $lang ) ) { if ( $resource['lang'] != $lang && $resource['lang'] != strstr( $lang, "-", true ) ) { return true; } } $messages[ $arc['to'] ] = $resource['message']; return true; }, $arc['toRoleUri'], $arc['to'], $arc['tolinkbase'] ); } return $messages; }
php
private function getMessages( $arcRole, $lang = null ) { $arcs = $this->xbrlTaxonomy->getGenericArc( $arcRole, $this->extendedLinkRoleUri, $this->label, $this->path, null, $this->linkbase ); $messages = array(); foreach ( $arcs as $arc ) { if ( $arc['frompath'] != $this->path ) continue; $this->xbrlTaxonomy->getGenericResource( 'message', 'message', function( $roleUri, $linkbase, $variableSetName, $index, $resource ) use( &$messages, $arc, $lang ) { // BMS 2019-02-11 // if ( $resource['label'] != $arc['to'] ) return true; if ( $resource['path'] != $arc['topath'] /* || $linkbase != $arc['linkbase'] */ ) return true; if ( ! is_null( $lang ) ) { if ( $resource['lang'] != $lang && $resource['lang'] != strstr( $lang, "-", true ) ) { return true; } } $messages[ $arc['to'] ] = $resource['message']; return true; }, $arc['toRoleUri'], $arc['to'], $arc['tolinkbase'] ); } return $messages; }
[ "private", "function", "getMessages", "(", "$", "arcRole", ",", "$", "lang", "=", "null", ")", "{", "$", "arcs", "=", "$", "this", "->", "xbrlTaxonomy", "->", "getGenericArc", "(", "$", "arcRole", ",", "$", "this", "->", "extendedLinkRoleUri", ",", "$", ...
Get any messages defined for the assertion @param string $arcRole @param string $lang @return array
[ "Get", "any", "messages", "defined", "for", "the", "assertion" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Assertions/VariableSetAssertion.php#L129-L160
train
bseddon/XBRL
Formulas/Evaluation.php
Evaluation.Evaluate
public static function Evaluate( $variableSet, $orderedVariableQNames, $notBindings, $uncoveredAspectFacts = null ) { return ( new Evaluation( $variableSet, $orderedVariableQNames, $notBindings ) )->processVariables( $uncoveredAspectFacts ); }
php
public static function Evaluate( $variableSet, $orderedVariableQNames, $notBindings, $uncoveredAspectFacts = null ) { return ( new Evaluation( $variableSet, $orderedVariableQNames, $notBindings ) )->processVariables( $uncoveredAspectFacts ); }
[ "public", "static", "function", "Evaluate", "(", "$", "variableSet", ",", "$", "orderedVariableQNames", ",", "$", "notBindings", ",", "$", "uncoveredAspectFacts", "=", "null", ")", "{", "return", "(", "new", "Evaluation", "(", "$", "variableSet", ",", "$", "...
Evaluate the variable @param VariableSet $variableSet @param array $orderedVariableQNames @param array $notBindings @param array $uncoveredAspectFacts
[ "Evaluate", "the", "variable" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Evaluation.php#L70-L73
train
bseddon/XBRL
Formulas/Evaluation.php
Evaluation.updateUncoveredAspectFacts
private function updateUncoveredAspectFacts( $uncoveredAspectFacts, $binding ) { if ( ! $uncoveredAspectFacts || $binding instanceof ScopeVariableBinding ) return; // Get the current fact so the uncovered aspects array $fact = $binding->current(); // Fill any null values in the parent binding with facts from $binding // NOTE: Arelle does it this way (see implicitFilter() on line 618 of FormulaEvaluator.py) but it is // necessary that the facts in the parent binding take precedence. The formula spec say that // any of the facts can be used. Still, for testing purposes, making this process as close to // the way Arelle operates means it is easier to identify implementation problems. foreach ( $binding->uncoveredAspectFacts as $aspect => $fact ) { // Don't change non-null aspects if ( ! is_null( $fact ) ) continue; // Otherwise, if the corresponding aspect in the existing uncovered aspect facts list is not null apply it. if ( ! isset( $uncoveredAspectFacts[ $aspect ] ) || is_null( $uncoveredAspectFacts[ $aspect ] ) ) continue; $binding->uncoveredAspectFacts[ $aspect ] = $uncoveredAspectFacts[ $aspect ]; } }
php
private function updateUncoveredAspectFacts( $uncoveredAspectFacts, $binding ) { if ( ! $uncoveredAspectFacts || $binding instanceof ScopeVariableBinding ) return; // Get the current fact so the uncovered aspects array $fact = $binding->current(); // Fill any null values in the parent binding with facts from $binding // NOTE: Arelle does it this way (see implicitFilter() on line 618 of FormulaEvaluator.py) but it is // necessary that the facts in the parent binding take precedence. The formula spec say that // any of the facts can be used. Still, for testing purposes, making this process as close to // the way Arelle operates means it is easier to identify implementation problems. foreach ( $binding->uncoveredAspectFacts as $aspect => $fact ) { // Don't change non-null aspects if ( ! is_null( $fact ) ) continue; // Otherwise, if the corresponding aspect in the existing uncovered aspect facts list is not null apply it. if ( ! isset( $uncoveredAspectFacts[ $aspect ] ) || is_null( $uncoveredAspectFacts[ $aspect ] ) ) continue; $binding->uncoveredAspectFacts[ $aspect ] = $uncoveredAspectFacts[ $aspect ]; } }
[ "private", "function", "updateUncoveredAspectFacts", "(", "$", "uncoveredAspectFacts", ",", "$", "binding", ")", "{", "if", "(", "!", "$", "uncoveredAspectFacts", "||", "$", "binding", "instanceof", "ScopeVariableBinding", ")", "return", ";", "// Get the current fact ...
Update the uncover aspect facts list in the bindings @param array $uncoveredAspectFacts @param VariableBinding $binding
[ "Update", "the", "uncover", "aspect", "facts", "list", "in", "the", "bindings" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Evaluation.php#L324-L346
train
bseddon/XBRL
XBRL-Constants.php
XBRL_Constants.isNumericRole
public static function isNumericRole( $role ) { return in_array( $role, array( self::$labelRoleTotalLabel, self::$labelRolePositiveLabel, self::$labelRoleNegativeLabel, self::$labelRoleZeroLabel, self::$labelRolePositiveTerseLabel, self::$labelRoleNegativeTerseLabel, self::$labelRoleZeroTerseLabel, self::$labelRolePositiveVerboseLabel, self::$labelRoleNegativeVerboseLabel, self::$labelRoleZeroVerboseLabel, "http://www.xbrl.org/2009/role/negatedLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedPeriodEndLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedPeriodStartLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedTotalLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedNetLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedTerseLabel", /* LRR */ ) ); }
php
public static function isNumericRole( $role ) { return in_array( $role, array( self::$labelRoleTotalLabel, self::$labelRolePositiveLabel, self::$labelRoleNegativeLabel, self::$labelRoleZeroLabel, self::$labelRolePositiveTerseLabel, self::$labelRoleNegativeTerseLabel, self::$labelRoleZeroTerseLabel, self::$labelRolePositiveVerboseLabel, self::$labelRoleNegativeVerboseLabel, self::$labelRoleZeroVerboseLabel, "http://www.xbrl.org/2009/role/negatedLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedPeriodEndLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedPeriodStartLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedTotalLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedNetLabel", /* LRR */ "http://www.xbrl.org/2009/role/negatedTerseLabel", /* LRR */ ) ); }
[ "public", "static", "function", "isNumericRole", "(", "$", "role", ")", "{", "return", "in_array", "(", "$", "role", ",", "array", "(", "self", "::", "$", "labelRoleTotalLabel", ",", "self", "::", "$", "labelRolePositiveLabel", ",", "self", "::", "$", "lab...
One of the label roles indicating a numeric role or on the othe 'negated' roles from the LRR @param string $role @return boolean
[ "One", "of", "the", "label", "roles", "indicating", "a", "numeric", "role", "or", "on", "the", "othe", "negated", "roles", "from", "the", "LRR" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Constants.php#L1890-L1910
train
bseddon/XBRL
XBRL-Constants.php
XBRL_Constants.isStandardArcrole
public static function isStandardArcrole( $role ) { return in_array( $role, array( "http://www.w3.org/1999/xlink/properties/linkbase", self::$arcRoleConceptLabel, self::$arcRoleConceptReference, self::$arcRoleFactFootnote, self::$arcRoleParentChild, self::$arcRoleSummationItem, self::$arcRoleGeneralSpecial, self::$arcRoleEssenceAlias, self::$arcRoleSimilarTuples, self::$arcRoleRequiresElement, ) ); }
php
public static function isStandardArcrole( $role ) { return in_array( $role, array( "http://www.w3.org/1999/xlink/properties/linkbase", self::$arcRoleConceptLabel, self::$arcRoleConceptReference, self::$arcRoleFactFootnote, self::$arcRoleParentChild, self::$arcRoleSummationItem, self::$arcRoleGeneralSpecial, self::$arcRoleEssenceAlias, self::$arcRoleSimilarTuples, self::$arcRoleRequiresElement, ) ); }
[ "public", "static", "function", "isStandardArcrole", "(", "$", "role", ")", "{", "return", "in_array", "(", "$", "role", ",", "array", "(", "\"http://www.w3.org/1999/xlink/properties/linkbase\"", ",", "self", "::", "$", "arcRoleConceptLabel", ",", "self", "::", "$...
One of the standard arc roles such as parent-child, summation-item @param string $role @return boolean
[ "One", "of", "the", "standard", "arc", "roles", "such", "as", "parent", "-", "child", "summation", "-", "item" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Constants.php#L1917-L1931
train
bseddon/XBRL
Formulas/Resources/Filters/Filter.php
Filter.getVariableQName
public function getVariableQName() { // Use the cached name if there is one. if ( ! $this->qname ) { if ( ! property_exists( $this, 'variable' ) ) return null; $this->qname = $qname = new QName( $this->variable['originalPrefix'], $this->variable['namespace'], $this->variable['name'] ); } return $this->qname; }
php
public function getVariableQName() { // Use the cached name if there is one. if ( ! $this->qname ) { if ( ! property_exists( $this, 'variable' ) ) return null; $this->qname = $qname = new QName( $this->variable['originalPrefix'], $this->variable['namespace'], $this->variable['name'] ); } return $this->qname; }
[ "public", "function", "getVariableQName", "(", ")", "{", "// Use the cached name if there is one.\r", "if", "(", "!", "$", "this", "->", "qname", ")", "{", "if", "(", "!", "property_exists", "(", "$", "this", ",", "'variable'", ")", ")", "return", "null", ";...
Return the QName of the 'variable' property if any @return NULL|QName
[ "Return", "the", "QName", "of", "the", "variable", "property", "if", "any" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Filters/Filter.php#L191-L201
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getAspectSources
protected function getAspectSources() { $sources = array(); foreach ( Formula::$ruleNames as $ruleName ) { $rule = $this->$ruleName; if ( ! isset( $rule['source'] ) ) continue; $sources[ $ruleName ] = $rule['source']; } return $sources; }
php
protected function getAspectSources() { $sources = array(); foreach ( Formula::$ruleNames as $ruleName ) { $rule = $this->$ruleName; if ( ! isset( $rule['source'] ) ) continue; $sources[ $ruleName ] = $rule['source']; } return $sources; }
[ "protected", "function", "getAspectSources", "(", ")", "{", "$", "sources", "=", "array", "(", ")", ";", "foreach", "(", "Formula", "::", "$", "ruleNames", "as", "$", "ruleName", ")", "{", "$", "rule", "=", "$", "this", "->", "$", "ruleName", ";", "i...
Return a list of the sources for all of the declared rules @return array
[ "Return", "a", "list", "of", "the", "sources", "for", "all", "of", "the", "declared", "rules" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L747-L759
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getVariableRefs
public function getVariableRefs() { // It is helpful for this function to return references in the 'value' statment and any filter expressions // because the check in XBRL-Formulas that detects xbrlve:unresolvedDependency needs them $result = array(); foreach ( $this->variablesByQName as $qname => $variable ) { $result = array_merge( $result, $variable->getVariableRefs() ); } if ( $this->valueXPath2expression instanceof XPath2Expression ) { $result = array_merge( $result, $this->valueXPath2expression->getParameterQNames() ); } $result = array_unique( $result ); return $result; }
php
public function getVariableRefs() { // It is helpful for this function to return references in the 'value' statment and any filter expressions // because the check in XBRL-Formulas that detects xbrlve:unresolvedDependency needs them $result = array(); foreach ( $this->variablesByQName as $qname => $variable ) { $result = array_merge( $result, $variable->getVariableRefs() ); } if ( $this->valueXPath2expression instanceof XPath2Expression ) { $result = array_merge( $result, $this->valueXPath2expression->getParameterQNames() ); } $result = array_unique( $result ); return $result; }
[ "public", "function", "getVariableRefs", "(", ")", "{", "// It is helpful for this function to return references in the 'value' statment and any filter expressions\r", "// because the check in XBRL-Formulas that detects xbrlve:unresolvedDependency needs them\r", "$", "result", "=", "array", ...
Allows a resource to return a list of the qnames of any variable references they contain @return array[\QName]
[ "Allows", "a", "resource", "to", "return", "a", "list", "of", "the", "qnames", "of", "any", "variable", "references", "they", "contain" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L1262-L1280
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getConceptAspectQName
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; } }
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\r", "if", "(", "is_null", "(", "$", "this", "->", "conceptRule", ")", ")", "{", "if", "(", ...
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" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2222-L2278
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getEntityIdentifierAspectValue
private function getEntityIdentifierAspectValue( $source, $evaluationResult, $log ) { // Get the entity identifier from the source if ( is_null( $this->entityIdentifierRule ) ) { $context = $this->getContextForSource( $source, $evaluationResult, ASPECT_ENTITY_IDENTIFIER, $log, $contextRef ); if ( ! $context || is_null( $context['entity']['identifier'] ) ) return null; // TODO What is in the $context array return $context['entity']['identifier']; } else { /** * @var EntityIdentifier $identifier */ $identifier = EntityIdentifier::fromArray( $this->entityIdentifierRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $identifier->source, ASPECT_ENTITY_IDENTIFIER, $evaluationResult, $log ); return $identifier->getValue( $this, $evaluationResult, $log ); } }
php
private function getEntityIdentifierAspectValue( $source, $evaluationResult, $log ) { // Get the entity identifier from the source if ( is_null( $this->entityIdentifierRule ) ) { $context = $this->getContextForSource( $source, $evaluationResult, ASPECT_ENTITY_IDENTIFIER, $log, $contextRef ); if ( ! $context || is_null( $context['entity']['identifier'] ) ) return null; // TODO What is in the $context array return $context['entity']['identifier']; } else { /** * @var EntityIdentifier $identifier */ $identifier = EntityIdentifier::fromArray( $this->entityIdentifierRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $identifier->source, ASPECT_ENTITY_IDENTIFIER, $evaluationResult, $log ); return $identifier->getValue( $this, $evaluationResult, $log ); } }
[ "private", "function", "getEntityIdentifierAspectValue", "(", "$", "source", ",", "$", "evaluationResult", ",", "$", "log", ")", "{", "// Get the entity identifier from the source\r", "if", "(", "is_null", "(", "$", "this", "->", "entityIdentifierRule", ")", ")", "{...
Get the entity identifier to be used for this fact. If an entity identifier rule does not exist, use the formula source value @param array $source @param array $evaluationResult @param \XBRL_Log $log @return array|NULL
[ "Get", "the", "entity", "identifier", "to", "be", "used", "for", "this", "fact", ".", "If", "an", "entity", "identifier", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2287-L2310
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getPeriodAspectValue
private function getPeriodAspectValue( $source, $evaluationResult, $log ) { // Get the period name from the source if ( is_null( $this->periodRule ) ) { $context = $this->getContextForSource( $source, $evaluationResult, ASPECT_PERIOD, $log, $contextRef ); if ( ! $context || ! isset( $context['period'] ) ) return null; // TODO What is in the $context array return $context['period']; } else { /** * * @var Period $period */ $period = Period::fromArray( $this->periodRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $period->source, ASPECT_PERIOD, $evaluationResult, $log ); return $period->getValue( $this, $evaluationResult, $log ); } }
php
private function getPeriodAspectValue( $source, $evaluationResult, $log ) { // Get the period name from the source if ( is_null( $this->periodRule ) ) { $context = $this->getContextForSource( $source, $evaluationResult, ASPECT_PERIOD, $log, $contextRef ); if ( ! $context || ! isset( $context['period'] ) ) return null; // TODO What is in the $context array return $context['period']; } else { /** * * @var Period $period */ $period = Period::fromArray( $this->periodRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $period->source, ASPECT_PERIOD, $evaluationResult, $log ); return $period->getValue( $this, $evaluationResult, $log ); } }
[ "private", "function", "getPeriodAspectValue", "(", "$", "source", ",", "$", "evaluationResult", ",", "$", "log", ")", "{", "// Get the period name from the source\r", "if", "(", "is_null", "(", "$", "this", "->", "periodRule", ")", ")", "{", "$", "context", "...
Get the period to be used for this fact. If a period rule does not exist, use the formula source value @param array $source @param array $evaluationResult @param \XBRL_Log $log @return array|NULL
[ "Get", "the", "period", "to", "be", "used", "for", "this", "fact", ".", "If", "a", "period", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2342-L2364
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getExplicitDimensionAspectValue
private function getExplicitDimensionAspectValue( $source, $componentPath, $evaluationResult, $explicitDimension, $log ) { $result = $this->getComponentForPath( $source, $componentPath, 'explicitMember', $evaluationResult, $explicitDimension, $log, $contextRef ); $context = Dimension::contextToIndex( $result, true, $this, $explicitDimension ); if ( ! $this->explicitDimensionRule ) { return $context; } $this->context = $context; $this->contextRef = $contextRef; foreach ( $this->explicitDimensionRule as $explicitDimensionRule ) { /** * @var ExplicitDimension $explicit */ $explicit = ExplicitDimension::fromArray( $explicitDimensionRule ); $dimensionClark = "{{$explicit->dimension['namespace']}}{$explicit->dimension['name']}"; if ( ! empty( $explicitDimension ) ) if ( $dimensionClark != $explicitDimension ) continue; $explicit->aspectDimension = $explicitDimension; $this->context = $explicit->getValue( $this, $evaluationResult, $log ); } $explicitDimensions = $this->context; unset( $this->context ); unset( $this->contextRef ); return $explicitDimensions; }
php
private function getExplicitDimensionAspectValue( $source, $componentPath, $evaluationResult, $explicitDimension, $log ) { $result = $this->getComponentForPath( $source, $componentPath, 'explicitMember', $evaluationResult, $explicitDimension, $log, $contextRef ); $context = Dimension::contextToIndex( $result, true, $this, $explicitDimension ); if ( ! $this->explicitDimensionRule ) { return $context; } $this->context = $context; $this->contextRef = $contextRef; foreach ( $this->explicitDimensionRule as $explicitDimensionRule ) { /** * @var ExplicitDimension $explicit */ $explicit = ExplicitDimension::fromArray( $explicitDimensionRule ); $dimensionClark = "{{$explicit->dimension['namespace']}}{$explicit->dimension['name']}"; if ( ! empty( $explicitDimension ) ) if ( $dimensionClark != $explicitDimension ) continue; $explicit->aspectDimension = $explicitDimension; $this->context = $explicit->getValue( $this, $evaluationResult, $log ); } $explicitDimensions = $this->context; unset( $this->context ); unset( $this->contextRef ); return $explicitDimensions; }
[ "private", "function", "getExplicitDimensionAspectValue", "(", "$", "source", ",", "$", "componentPath", ",", "$", "evaluationResult", ",", "$", "explicitDimension", ",", "$", "log", ")", "{", "$", "result", "=", "$", "this", "->", "getComponentForPath", "(", ...
Get the explicit diemsion to be used for this fact. If an explicit dimension rule does not exist, use the formula source value @param string $source The formula source @param array $componentPath @param array $evaluationResult @param array $explicitDimension @param \XBRL_Log $log @return array|null
[ "Get", "the", "explicit", "diemsion", "to", "be", "used", "for", "this", "fact", ".", "If", "an", "explicit", "dimension", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2375-L2406
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getTypedDimensionAspectValue
private function getTypedDimensionAspectValue( $source, $componentPath, $evaluationResult, $typedDimension, $log ) { $result = $this->getComponentForPath( $source, $componentPath, 'typedMember', $evaluationResult, $typedDimension, $log, $contextRef ); $context = Dimension::contextToIndex( $result, false, $this, $typedDimension ); if ( ! $this->typedDimensionRule ) { return $context; } $this->context = $context; $this->contextRef = $contextRef; foreach ( $this->typedDimensionRule as $typedDimensionRule ) { /** * @var TypedDimension $typed */ $typed = TypedDimension::fromArray( $typedDimensionRule ); $dimensionClark = "{{$typed->dimension['namespace']}}{$typed->dimension['name']}"; if ( ! empty( $typedDimension ) ) if ( $dimensionClark != $typedDimension ) continue; $typed->aspectDimension = $typedDimension; $this->context = $typed->getValue( $this, $evaluationResult, $log ); } $typedDimensions = $this->context; unset( $this->context ); unset( $this->contextRef ); return $typedDimensions; }
php
private function getTypedDimensionAspectValue( $source, $componentPath, $evaluationResult, $typedDimension, $log ) { $result = $this->getComponentForPath( $source, $componentPath, 'typedMember', $evaluationResult, $typedDimension, $log, $contextRef ); $context = Dimension::contextToIndex( $result, false, $this, $typedDimension ); if ( ! $this->typedDimensionRule ) { return $context; } $this->context = $context; $this->contextRef = $contextRef; foreach ( $this->typedDimensionRule as $typedDimensionRule ) { /** * @var TypedDimension $typed */ $typed = TypedDimension::fromArray( $typedDimensionRule ); $dimensionClark = "{{$typed->dimension['namespace']}}{$typed->dimension['name']}"; if ( ! empty( $typedDimension ) ) if ( $dimensionClark != $typedDimension ) continue; $typed->aspectDimension = $typedDimension; $this->context = $typed->getValue( $this, $evaluationResult, $log ); } $typedDimensions = $this->context; unset( $this->context ); unset( $this->contextRef ); return $typedDimensions; }
[ "private", "function", "getTypedDimensionAspectValue", "(", "$", "source", ",", "$", "componentPath", ",", "$", "evaluationResult", ",", "$", "typedDimension", ",", "$", "log", ")", "{", "$", "result", "=", "$", "this", "->", "getComponentForPath", "(", "$", ...
Get the typed diemsion to be used for this fact. If an typed dimension rule does not exist, use the formula source value @param array $source @param string $componentPath @param array $evaluationResult @param string $typedDimension @param \XBRL_Log $log @return array|null
[ "Get", "the", "typed", "diemsion", "to", "be", "used", "for", "this", "fact", ".", "If", "an", "typed", "dimension", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2417-L2448
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getComponentAspectValue
private function getComponentAspectValue( $source, $aspect, $componentType, $evaluationResult, $log ) { // Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules. // They must be processed in order to produce a final list of scenarios $rules = $componentType == 'segment' ? $this->segmentRule : $this->scenarioRule; if ( ! $rules ) { $extra = in_array( $aspect, array( ASPECT_COMPLETE_SCENARIO, ASPECT_COMPLETE_SEGMENT ) ) ? '' : ''; return $this->getComponentForPath( $source, ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), $extra, $evaluationResult, $aspect, $log, $contextRef ); } $contextRef = null; $ruleContextRef = null; $context = array(); foreach ( $rules as $rule ) { // The context has to be rule source specific but cannot be replaced by the context for every rule $ruleContext = $this->getComponentForPath( $rule['source'], ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), 'member', $evaluationResult, $aspect, $log, $ruleContextRef ); $context = is_null( $contextRef ) || $contextRef != $ruleContextRef ? array_merge( $context, $ruleContext ) : $context; if ( $contextRef != $ruleContextRef ) $contextRef = $ruleContextRef; if ( $rule['aspectType'] == 'occEmpty' ) // occEmtpy { $context = array(); } else if ( $rule['aspectType'] == 'occFragments' ) // occFragments { /** * @var OCCFragments $fragments */ $fragments = OCCFragments::fromArray( $rule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $fragments->source, $aspect, $evaluationResult, $log ); $members = $fragments->getValue( $this, $evaluationResult, $log ); $context = array_merge( $context, $members ); } else if ( $rule['aspectType'] == 'occXpath' ) // occXpath { /** * @var OCCXPath $xpath */ $xpath = OCCXPath::fromArray( $rule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $xpath->source, $aspect, $evaluationResult, $log ); $members = $xpath->getValue( $this, $evaluationResult, $log ); $context = array_merge( $context, $members ); } } // BMS 2018-03-22 The call to getComponentForPath() above 'pops' the containing 'member' // element so if there are any elements in the context array wrap them // in a member element. if ( $context ) { $context = array( 'member' => $context ); } return $context; }
php
private function getComponentAspectValue( $source, $aspect, $componentType, $evaluationResult, $log ) { // Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules. // They must be processed in order to produce a final list of scenarios $rules = $componentType == 'segment' ? $this->segmentRule : $this->scenarioRule; if ( ! $rules ) { $extra = in_array( $aspect, array( ASPECT_COMPLETE_SCENARIO, ASPECT_COMPLETE_SEGMENT ) ) ? '' : ''; return $this->getComponentForPath( $source, ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), $extra, $evaluationResult, $aspect, $log, $contextRef ); } $contextRef = null; $ruleContextRef = null; $context = array(); foreach ( $rules as $rule ) { // The context has to be rule source specific but cannot be replaced by the context for every rule $ruleContext = $this->getComponentForPath( $rule['source'], ( $componentType == 'segment' ? $this->segmentsComponentPath : $this->scenariosComponentPath ), 'member', $evaluationResult, $aspect, $log, $ruleContextRef ); $context = is_null( $contextRef ) || $contextRef != $ruleContextRef ? array_merge( $context, $ruleContext ) : $context; if ( $contextRef != $ruleContextRef ) $contextRef = $ruleContextRef; if ( $rule['aspectType'] == 'occEmpty' ) // occEmtpy { $context = array(); } else if ( $rule['aspectType'] == 'occFragments' ) // occFragments { /** * @var OCCFragments $fragments */ $fragments = OCCFragments::fromArray( $rule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $fragments->source, $aspect, $evaluationResult, $log ); $members = $fragments->getValue( $this, $evaluationResult, $log ); $context = array_merge( $context, $members ); } else if ( $rule['aspectType'] == 'occXpath' ) // occXpath { /** * @var OCCXPath $xpath */ $xpath = OCCXPath::fromArray( $rule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $xpath->source, $aspect, $evaluationResult, $log ); $members = $xpath->getValue( $this, $evaluationResult, $log ); $context = array_merge( $context, $members ); } } // BMS 2018-03-22 The call to getComponentForPath() above 'pops' the containing 'member' // element so if there are any elements in the context array wrap them // in a member element. if ( $context ) { $context = array( 'member' => $context ); } return $context; }
[ "private", "function", "getComponentAspectValue", "(", "$", "source", ",", "$", "aspect", ",", "$", "componentType", ",", "$", "evaluationResult", ",", "$", "log", ")", "{", "// Unlike other rules there is no one scenario rule. Instead is it made up of a collection of rules.\...
Get the scenario to be used for this fact. If a scenario rule does not exist, use the formula source value @param array $source @param string $aspect @param string $componentType @param array $evaluationResult @param \XBRL_Log $log @return array|NULL
[ "Get", "the", "scenario", "to", "be", "used", "for", "this", "fact", ".", "If", "a", "scenario", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2459-L2523
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getContextForSource
private function getContextForSource( $source, $evaluationResult, $aspect, $log, &$contextRef = null ) { $sourceFact = $this->getSourceFact( $source, $evaluationResult, $aspect, $log ); if ( ! $sourceFact ) return array(); // Get the context ref from the source $contextRef = FactValues::getContextRef( $sourceFact ); $context = $this->xbrlInstance->getContext( $contextRef ); return $context; }
php
private function getContextForSource( $source, $evaluationResult, $aspect, $log, &$contextRef = null ) { $sourceFact = $this->getSourceFact( $source, $evaluationResult, $aspect, $log ); if ( ! $sourceFact ) return array(); // Get the context ref from the source $contextRef = FactValues::getContextRef( $sourceFact ); $context = $this->xbrlInstance->getContext( $contextRef ); return $context; }
[ "private", "function", "getContextForSource", "(", "$", "source", ",", "$", "evaluationResult", ",", "$", "aspect", ",", "$", "log", ",", "&", "$", "contextRef", "=", "null", ")", "{", "$", "sourceFact", "=", "$", "this", "->", "getSourceFact", "(", "$",...
Return the context for a source. if there is a problem accessing the source fact then an exception will be thrown. @param string $source The source variable to use @param array $evaluationResult @param string $aspect The aspect identifier to use @param \XBRL_Log $log @param string $contextRef (reference) @return array the resulting context
[ "Return", "the", "context", "for", "a", "source", ".", "if", "there", "is", "a", "problem", "accessing", "the", "source", "fact", "then", "an", "exception", "will", "be", "thrown", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2534-L2545
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.getUnitAspectValue
private function getUnitAspectValue( $source, $evaluationResult, $log ) { // Get the unit from the source if ( is_null( $this->unitRule ) ) { if ( ! $this->source ) { return false; } $sourceFact = $this->getSourceFactWithErrorLogging( $source, $evaluationResult, ASPECT_UNIT, $log ); $unitRef = FactValues::getUnitRef( $sourceFact ); if ( ! $unitRef ) return null; // TODO What is in the $unit array $unit = $this->xbrlInstance->getUnit( $unitRef ); return array( $unitRef => $unit ); } else { /** * @var Unit $unit */ $unit = Unit::fromArray( $this->unitRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $unit->source, ASPECT_UNIT, $evaluationResult, $log ); return $unit->getValue( $this, $evaluationResult, $log ); } }
php
private function getUnitAspectValue( $source, $evaluationResult, $log ) { // Get the unit from the source if ( is_null( $this->unitRule ) ) { if ( ! $this->source ) { return false; } $sourceFact = $this->getSourceFactWithErrorLogging( $source, $evaluationResult, ASPECT_UNIT, $log ); $unitRef = FactValues::getUnitRef( $sourceFact ); if ( ! $unitRef ) return null; // TODO What is in the $unit array $unit = $this->xbrlInstance->getUnit( $unitRef ); return array( $unitRef => $unit ); } else { /** * @var Unit $unit */ $unit = Unit::fromArray( $this->unitRule ); // This function will throw an exception if there is a problem so there is no return value to check $this->checkSAVConflicts( $unit->source, ASPECT_UNIT, $evaluationResult, $log ); return $unit->getValue( $this, $evaluationResult, $log ); } }
[ "private", "function", "getUnitAspectValue", "(", "$", "source", ",", "$", "evaluationResult", ",", "$", "log", ")", "{", "// Get the unit from the source\r", "if", "(", "is_null", "(", "$", "this", "->", "unitRule", ")", ")", "{", "if", "(", "!", "$", "th...
Get the unit to be used for this fact. If a unit rule does not exist, use the formula source value @param string $source @param array $evaluationResult @param \XBRL_Log $log @return array|null
[ "Get", "the", "unit", "to", "be", "used", "for", "this", "fact", ".", "If", "a", "unit", "rule", "does", "not", "exist", "use", "the", "formula", "source", "value" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2593-L2623
train
bseddon/XBRL
Formulas/Resources/Formulas/Formula.php
Formula.hashArray
private function hashArray( $elements ) { $hashes = array(); if ( is_array( $elements ) ) { foreach ( $elements as $key => $element ) { if ( is_object( $element ) ) { $hash = spl_object_hash( $element ) . $key; $hashes[ $hash ] = $element; } else if ( is_array( $element ) ) { extract( $this->hashArray( $element ) ) . $key; $hashes[ $hash ] = $element; } else { $hash = hash( 'sha256', $element . $key ); $hashes[ $hash ] = $element; } } } else { $hash = hash( 'sha256', $elements ); $hashes[ $hash ] = $elements; } return array( 'hash' => hash( 'sha256', serialize( array_keys( $hashes ) ) ), 'element_hashes' => $hashes ); }
php
private function hashArray( $elements ) { $hashes = array(); if ( is_array( $elements ) ) { foreach ( $elements as $key => $element ) { if ( is_object( $element ) ) { $hash = spl_object_hash( $element ) . $key; $hashes[ $hash ] = $element; } else if ( is_array( $element ) ) { extract( $this->hashArray( $element ) ) . $key; $hashes[ $hash ] = $element; } else { $hash = hash( 'sha256', $element . $key ); $hashes[ $hash ] = $element; } } } else { $hash = hash( 'sha256', $elements ); $hashes[ $hash ] = $elements; } return array( 'hash' => hash( 'sha256', serialize( array_keys( $hashes ) ) ), 'element_hashes' => $hashes ); }
[ "private", "function", "hashArray", "(", "$", "elements", ")", "{", "$", "hashes", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "elements", ")", ")", "{", "foreach", "(", "$", "elements", "as", "$", "key", "=>", "$", "element", ")"...
Generates hashes for all the elements of the key @param $elements An array of key elements for which to create the hashes @return array An array of the elements indexed by their hashes and the overall hash
[ "Generates", "hashes", "for", "all", "the", "elements", "of", "the", "key" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/Formula.php#L2630-L2662
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.addValidYear
public function addValidYear( $year ) { if ( is_array( $year ) ) { $this->validYears += $year; } elseif ( $year !== null ) { $this->validYears[] = $year; } }
php
public function addValidYear( $year ) { if ( is_array( $year ) ) { $this->validYears += $year; } elseif ( $year !== null ) { $this->validYears[] = $year; } }
[ "public", "function", "addValidYear", "(", "$", "year", ")", "{", "if", "(", "is_array", "(", "$", "year", ")", ")", "{", "$", "this", "->", "validYears", "+=", "$", "year", ";", "}", "elseif", "(", "$", "year", "!==", "null", ")", "{", "$", "thi...
Adds a valid year. If none are added, all are valid. @param array[int]|int $year
[ "Adds", "a", "valid", "year", ".", "If", "none", "are", "added", "all", "are", "valid", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L189-L199
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.initTaxonomy
private function initTaxonomy() { // Sanity check if ( count( $this->instanceDocuments ) === 0 ) { $this->log()->err( "There are no instance documents" ); return false; } if ( $this->taxonomy === null ) return false; $xsd = pathinfo( $this->schemaFilename, PATHINFO_BASENAME ); $this->taxonomy = $this->taxonomy->getTaxonomyForXSD( $xsd ); return true; }
php
private function initTaxonomy() { // Sanity check if ( count( $this->instanceDocuments ) === 0 ) { $this->log()->err( "There are no instance documents" ); return false; } if ( $this->taxonomy === null ) return false; $xsd = pathinfo( $this->schemaFilename, PATHINFO_BASENAME ); $this->taxonomy = $this->taxonomy->getTaxonomyForXSD( $xsd ); return true; }
[ "private", "function", "initTaxonomy", "(", ")", "{", "// Sanity check\r", "if", "(", "count", "(", "$", "this", "->", "instanceDocuments", ")", "===", "0", ")", "{", "$", "this", "->", "log", "(", ")", "->", "err", "(", "\"There are no instance documents\""...
Initialize the taxonomy based on the loaded instance documents The taxonomy will have been loaded but the text may not have been assgined to concepts and the presentation hierarchy @return True if initialized successfully
[ "Initialize", "the", "taxonomy", "based", "on", "the", "loaded", "instance", "documents", "The", "taxonomy", "will", "have", "been", "loaded", "but", "the", "text", "may", "not", "have", "been", "assgined", "to", "concepts", "and", "the", "presentation", "hier...
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L242-L256
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.analyzeContexts
protected function analyzeContexts( $instance ) { $contexts = $instance->getContexts()->getContexts(); $elements = $instance->getElements()->getElements(); foreach ( $elements as $elementKey => $element ) { foreach ( $element as $entryKey => $entry ) { if ( ! isset( $entry['contextRef'] ) ) continue; if ( isset( $instance->usedContexts[ $entry['contextRef'] ] ) ) continue; $instance->usedContexts[ $entry['contextRef'] ] = $contexts[ $entry['contextRef'] ]; $instance->usedContexts[ $entry['contextRef'] ]['year'] = substr( $contexts[ $entry['contextRef'] ]['period']['endDate'], 0, 4 ); } } if ( ! is_array( $this->years ) ) $this->years = array(); foreach ( $instance->usedContexts as $key => $context ) { $year = $context['year']; $entity = $context['entity']['identifier']['value']; if ( ! isset( $this->years[ $year ] ) ) $this->years[ $year ] = array(); if ( ! isset( $this->years[ $year ][ $entity ] ) ) $this->years[ $year ][ $entity ] = array(); $this->years[ $year ][ $entity ][ $key ] = $context; } // ksort( $this->years ); // print_r( array_keys( $this->years ) ); if ( ! is_array( $this->entities ) ) $this->entities = array(); foreach ( $instance->usedContexts as $key => $context ) { $entity = $context['entity']['identifier']['value']; $this->entityInstanceMap[ $entity ] = $instance->getDocumentName(); if ( ! isset( $this->entities[ $entity ] ) ) $this->entities[ $entity ] = array(); $this->entities[ $entity ][ $key ] = $context; } }
php
protected function analyzeContexts( $instance ) { $contexts = $instance->getContexts()->getContexts(); $elements = $instance->getElements()->getElements(); foreach ( $elements as $elementKey => $element ) { foreach ( $element as $entryKey => $entry ) { if ( ! isset( $entry['contextRef'] ) ) continue; if ( isset( $instance->usedContexts[ $entry['contextRef'] ] ) ) continue; $instance->usedContexts[ $entry['contextRef'] ] = $contexts[ $entry['contextRef'] ]; $instance->usedContexts[ $entry['contextRef'] ]['year'] = substr( $contexts[ $entry['contextRef'] ]['period']['endDate'], 0, 4 ); } } if ( ! is_array( $this->years ) ) $this->years = array(); foreach ( $instance->usedContexts as $key => $context ) { $year = $context['year']; $entity = $context['entity']['identifier']['value']; if ( ! isset( $this->years[ $year ] ) ) $this->years[ $year ] = array(); if ( ! isset( $this->years[ $year ][ $entity ] ) ) $this->years[ $year ][ $entity ] = array(); $this->years[ $year ][ $entity ][ $key ] = $context; } // ksort( $this->years ); // print_r( array_keys( $this->years ) ); if ( ! is_array( $this->entities ) ) $this->entities = array(); foreach ( $instance->usedContexts as $key => $context ) { $entity = $context['entity']['identifier']['value']; $this->entityInstanceMap[ $entity ] = $instance->getDocumentName(); if ( ! isset( $this->entities[ $entity ] ) ) $this->entities[ $entity ] = array(); $this->entities[ $entity ][ $key ] = $context; } }
[ "protected", "function", "analyzeContexts", "(", "$", "instance", ")", "{", "$", "contexts", "=", "$", "instance", "->", "getContexts", "(", ")", "->", "getContexts", "(", ")", ";", "$", "elements", "=", "$", "instance", "->", "getElements", "(", ")", "-...
Generate an alternative list of contexts by year Can be overridden descendant concrete implementations @param XBRL_Instance $instance The instance containing the contexts to analyze
[ "Generate", "an", "alternative", "list", "of", "contexts", "by", "year", "Can", "be", "overridden", "descendant", "concrete", "implementations" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L263-L307
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.&
private function &findNodeFromPath( &$nodes, $path ) { $pathsParts = explode( '/', $path ); $node = null; for ( $i = 0; $i < count( $pathsParts ); $i++ ) { if ( ! isset( $nodes[ $pathsParts[ $i ] ] ) ) { $node = false; break; } $node =& $nodes[ $pathsParts[ $i ] ]; if ( isset( $node['children'] ) ) { $nodes =& $node['children']; continue; } } return $node; }
php
private function &findNodeFromPath( &$nodes, $path ) { $pathsParts = explode( '/', $path ); $node = null; for ( $i = 0; $i < count( $pathsParts ); $i++ ) { if ( ! isset( $nodes[ $pathsParts[ $i ] ] ) ) { $node = false; break; } $node =& $nodes[ $pathsParts[ $i ] ]; if ( isset( $node['children'] ) ) { $nodes =& $node['children']; continue; } } return $node; }
[ "private", "function", "&", "findNodeFromPath", "(", "&", "$", "nodes", ",", "$", "path", ")", "{", "$", "pathsParts", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "$", "node", "=", "null", ";", "for", "(", "$", "i", "=", "0", ";", "...
Get the node for a path @param array $nodes An array of nodes @param string $path The path representing a node. A path is a set of labels concatenated by '/' @return boolean|array False if the node is not found or a reference to the node represented by the $path
[ "Get", "the", "node", "for", "a", "path" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L326-L349
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.countDepth
private function countDepth( &$nodes, $depth = 0 ) { if ( $depth > $this->maxDepth ) $this->maxDepth = $depth; foreach ( $nodes as $nodeKey => &$node ) { $node['depth'] = $depth; if ( ! isset( $node['children'] ) || count( $node['children'] ) === 0 ) continue; $this->countDepth( $node['children'], $depth + 1 ); } }
php
private function countDepth( &$nodes, $depth = 0 ) { if ( $depth > $this->maxDepth ) $this->maxDepth = $depth; foreach ( $nodes as $nodeKey => &$node ) { $node['depth'] = $depth; if ( ! isset( $node['children'] ) || count( $node['children'] ) === 0 ) continue; $this->countDepth( $node['children'], $depth + 1 ); } }
[ "private", "function", "countDepth", "(", "&", "$", "nodes", ",", "$", "depth", "=", "0", ")", "{", "if", "(", "$", "depth", ">", "$", "this", "->", "maxDepth", ")", "$", "this", "->", "maxDepth", "=", "$", "depth", ";", "foreach", "(", "$", "nod...
Set the max depth @param array $nodes The current hierarchy nodes @param int $depth The current depth
[ "Set", "the", "max", "depth" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L1199-L1210
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.saveGeneratedHierarchy
public function saveGeneratedHierarchy( $filename, $zip = false ) { $result = true; if ( ! property_exists( $this, 'hierarchies' ) ) return "The hierarchies have not been generated"; $json = json_encode( $this->hierarchies ); if ( json_last_error() !== JSON_ERROR_NONE ) { $result = "An error occurred generating the JSON for the hierarchies: " . XBRL::json_last_error_msg(); } elseif ( $zip ) { $zip = new ZipArchive(); $zip->open( $filename, ZipArchive::CREATE ); if ( ! $zip->addFromString( 'hierarchies.json', $json ) ) { $result = "Failed to add JSON to zip file"; } if ( $zip->close() === false ) { $result = "Error closing zip file: " . $zip->getStatusString(); } } else { if ( file_put_contents( $filename, $json ) === false ) { $result = "Writing to the file failed"; } } return $result; }
php
public function saveGeneratedHierarchy( $filename, $zip = false ) { $result = true; if ( ! property_exists( $this, 'hierarchies' ) ) return "The hierarchies have not been generated"; $json = json_encode( $this->hierarchies ); if ( json_last_error() !== JSON_ERROR_NONE ) { $result = "An error occurred generating the JSON for the hierarchies: " . XBRL::json_last_error_msg(); } elseif ( $zip ) { $zip = new ZipArchive(); $zip->open( $filename, ZipArchive::CREATE ); if ( ! $zip->addFromString( 'hierarchies.json', $json ) ) { $result = "Failed to add JSON to zip file"; } if ( $zip->close() === false ) { $result = "Error closing zip file: " . $zip->getStatusString(); } } else { if ( file_put_contents( $filename, $json ) === false ) { $result = "Writing to the file failed"; } } return $result; }
[ "public", "function", "saveGeneratedHierarchy", "(", "$", "filename", ",", "$", "zip", "=", "false", ")", "{", "$", "result", "=", "true", ";", "if", "(", "!", "property_exists", "(", "$", "this", ",", "'hierarchies'", ")", ")", "return", "\"The hierarchie...
Export the hierarchy to a file in JSON format @param string $filename @param bool $zip (Optional) Indicates whether the file should be zipped (Default: false) @return bool|string True if successful or a string reporting the issue
[ "Export", "the", "hierarchy", "to", "a", "file", "in", "JSON", "format" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L1218-L1251
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.loadGeneratedHierarchy
public function loadGeneratedHierarchy( $filename ) { $result = true; $extension = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ); if ( $extension === 'zip' ) { $zip = new ZipArchive(); if ( $zip->open( $filename ) === true ) { $json = $zip->getFromName( 'hierarchies.json' ); $zip->close(); } else { $result = 'Failed to open zip file $filename'; } } else { $json = file_get_contents( $filename ); } if ( $result ) { $this->hierarchies = json_decode( $json, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { $result = "An error occurred generating the JSON for the hierarchies: " . XBRL::json_last_error_msg(); } $this->alignWithValidYears(); foreach ( $this->hierarchies as $roleKey => $role ) { $this->countDepth( $role['hierarchy'] ); } } return $result; }
php
public function loadGeneratedHierarchy( $filename ) { $result = true; $extension = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ); if ( $extension === 'zip' ) { $zip = new ZipArchive(); if ( $zip->open( $filename ) === true ) { $json = $zip->getFromName( 'hierarchies.json' ); $zip->close(); } else { $result = 'Failed to open zip file $filename'; } } else { $json = file_get_contents( $filename ); } if ( $result ) { $this->hierarchies = json_decode( $json, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { $result = "An error occurred generating the JSON for the hierarchies: " . XBRL::json_last_error_msg(); } $this->alignWithValidYears(); foreach ( $this->hierarchies as $roleKey => $role ) { $this->countDepth( $role['hierarchy'] ); } } return $result; }
[ "public", "function", "loadGeneratedHierarchy", "(", "$", "filename", ")", "{", "$", "result", "=", "true", ";", "$", "extension", "=", "strtolower", "(", "pathinfo", "(", "$", "filename", ",", "PATHINFO_EXTENSION", ")", ")", ";", "if", "(", "$", "extensio...
Load the hierachies from a JSON store @param string $filename @return bool|string True if successful or a string reporting the issue
[ "Load", "the", "hierachies", "from", "a", "JSON", "store" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L1258-L1299
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.pruneNodes
private function pruneNodes( &$roles ) { $this->log()->info( "Prune" ); foreach ( $roles as $roleKey => &$role ) { if ( isset( $role['locators'] ) ) unset( $role['locators'] ); if ( isset( $role['paths'] ) ) unset( $role['paths'] ); foreach ( $role['hierarchy'] as $headingKey => &$heading ) { // If not used, prune if ( ! isset( $heading['used'] ) ) { // $this->log()->info( "Prune $headingKey" ); unset( $role['hierarchy'][ $headingKey ] ); continue; } if ( ! isset( $role['hierarchy'][ $headingKey ]['taxonomy_element'] ) ) { $taxonomy = $this->getTaxonomy()->getTaxonomyForXSD( $heading['label'] ); $role['hierarchy'][ $headingKey ]['taxonomy_element'] = $taxonomy->getElementById( $heading['label'] ); } $me = $this; $pruneNodes = function( &$nodes ) use( &$pruneNodes, &$role, $me ) { foreach ( $nodes as $nodeKey => &$node ) { // If not used, prune if ( ! isset( $node['used'] ) ) { unset( $nodes[ $nodeKey ] ); continue; } else if ( isset( $node['children'] ) ) { $pruneNodes( $node['children'] ); } if ( ! isset( $node['taxonomy_element'] ) ) { $taxonomy = $me->getTaxonomy()->getTaxonomyForXSD( $node['label'] ); $node['taxonomy_element'] = $taxonomy->getElementById( $node['label'] ); } } }; $pruneNodes( $heading['children'] ); unset( $me ); } if ( count( $role['hierarchy'] ) === 0 ) { unset( $roles[ $roleKey ] ); } } }
php
private function pruneNodes( &$roles ) { $this->log()->info( "Prune" ); foreach ( $roles as $roleKey => &$role ) { if ( isset( $role['locators'] ) ) unset( $role['locators'] ); if ( isset( $role['paths'] ) ) unset( $role['paths'] ); foreach ( $role['hierarchy'] as $headingKey => &$heading ) { // If not used, prune if ( ! isset( $heading['used'] ) ) { // $this->log()->info( "Prune $headingKey" ); unset( $role['hierarchy'][ $headingKey ] ); continue; } if ( ! isset( $role['hierarchy'][ $headingKey ]['taxonomy_element'] ) ) { $taxonomy = $this->getTaxonomy()->getTaxonomyForXSD( $heading['label'] ); $role['hierarchy'][ $headingKey ]['taxonomy_element'] = $taxonomy->getElementById( $heading['label'] ); } $me = $this; $pruneNodes = function( &$nodes ) use( &$pruneNodes, &$role, $me ) { foreach ( $nodes as $nodeKey => &$node ) { // If not used, prune if ( ! isset( $node['used'] ) ) { unset( $nodes[ $nodeKey ] ); continue; } else if ( isset( $node['children'] ) ) { $pruneNodes( $node['children'] ); } if ( ! isset( $node['taxonomy_element'] ) ) { $taxonomy = $me->getTaxonomy()->getTaxonomyForXSD( $node['label'] ); $node['taxonomy_element'] = $taxonomy->getElementById( $node['label'] ); } } }; $pruneNodes( $heading['children'] ); unset( $me ); } if ( count( $role['hierarchy'] ) === 0 ) { unset( $roles[ $roleKey ] ); } } }
[ "private", "function", "pruneNodes", "(", "&", "$", "roles", ")", "{", "$", "this", "->", "log", "(", ")", "->", "info", "(", "\"Prune\"", ")", ";", "foreach", "(", "$", "roles", "as", "$", "roleKey", "=>", "&", "$", "role", ")", "{", "if", "(", ...
Prune the unused nodes. These do not have a 'used' element. @param array $roles @return void
[ "Prune", "the", "unused", "nodes", ".", "These", "do", "not", "have", "a", "used", "element", "." ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L1560-L1617
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.toJson
public function toJson() { if ( $this->hierarchies === null ) throw new Exception( "Hierarchies have not been generated. Run preparePresentation() first." ); $roles =& $this->taxonomy->getPresentationRoleRefs(); foreach ( $this->hierarchies as $roleKey => &$role ) { } }
php
public function toJson() { if ( $this->hierarchies === null ) throw new Exception( "Hierarchies have not been generated. Run preparePresentation() first." ); $roles =& $this->taxonomy->getPresentationRoleRefs(); foreach ( $this->hierarchies as $roleKey => &$role ) { } }
[ "public", "function", "toJson", "(", ")", "{", "if", "(", "$", "this", "->", "hierarchies", "===", "null", ")", "throw", "new", "Exception", "(", "\"Hierarchies have not been generated. Run preparePresentation() first.\"", ")", ";", "$", "roles", "=", "&", "$", ...
Create JSON for one instance @return void
[ "Create", "JSON", "for", "one", "instance" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L2811-L2822
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.validElements
private function validElements( $node ) { // The node must be an array if ( ! isset( $node ) ) return false; // The node may represent a tuple if ( XBRL::isTuple( $node['taxonomy_element'] ) ) return true; // There must be an element called 'elements' if ( ! isset( $node['elements'] ) ) return false; // The elements must have some members if ( count( $node['elements'] ) === 0 ) return false; foreach ( $node['elements'] as $elementKey => $element ) if ( ! empty( $element['value'] ) /* || is_numeric( $element['value'] ) */ ) return true; return false; }
php
private function validElements( $node ) { // The node must be an array if ( ! isset( $node ) ) return false; // The node may represent a tuple if ( XBRL::isTuple( $node['taxonomy_element'] ) ) return true; // There must be an element called 'elements' if ( ! isset( $node['elements'] ) ) return false; // The elements must have some members if ( count( $node['elements'] ) === 0 ) return false; foreach ( $node['elements'] as $elementKey => $element ) if ( ! empty( $element['value'] ) /* || is_numeric( $element['value'] ) */ ) return true; return false; }
[ "private", "function", "validElements", "(", "$", "node", ")", "{", "// The node must be an array\r", "if", "(", "!", "isset", "(", "$", "node", ")", ")", "return", "false", ";", "// The node may represent a tuple\r", "if", "(", "XBRL", "::", "isTuple", "(", "...
Called by ProcessNodes to assess whether there is something useful in the node @param array $node The node to assess @return boolean True if the element is valid for processing
[ "Called", "by", "ProcessNodes", "to", "assess", "whether", "there", "is", "something", "useful", "in", "the", "node" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L3347-L3363
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.flatten
private function flatten( $input, $depth = 0, $startIndex = 0 ) { $result = array(); if ( ! is_array( $input ) ) return $result; foreach ( $input as $key => $item ) { if ( is_array( $item ) ) { $x = $this->flatten( $item, $depth + 1, $startIndex ); $result = $result + $x; $startIndex += count( $x ); } else { $result[ $startIndex ] = str_repeat( "\t", $depth ) . $item; $startIndex++; } } return $result; }
php
private function flatten( $input, $depth = 0, $startIndex = 0 ) { $result = array(); if ( ! is_array( $input ) ) return $result; foreach ( $input as $key => $item ) { if ( is_array( $item ) ) { $x = $this->flatten( $item, $depth + 1, $startIndex ); $result = $result + $x; $startIndex += count( $x ); } else { $result[ $startIndex ] = str_repeat( "\t", $depth ) . $item; $startIndex++; } } return $result; }
[ "private", "function", "flatten", "(", "$", "input", ",", "$", "depth", "=", "0", ",", "$", "startIndex", "=", "0", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "input", ")", ")", "return", "$", "r...
Flatten an array of mixed values and arrays @param array $input An array containing text and arrays to be flattened with indentation @param number $depth The depth of the recursion. Used to determine the number of tabs to add. @param number $startIndex Value of the first index to use when adding strings to the flattened array to prevent keys overlapping so they can be joined. @return array A flat array of values.
[ "Flatten", "an", "array", "of", "mixed", "values", "and", "arrays" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L3375-L3397
train
bseddon/XBRL
XBRL-Report-Base.php
XBRL_Report_Base.elapsedTime
private function elapsedTime( $index = 'utime') { if ( version_compare( PHP_VERSION, "7.0", "<" ) ) return; $rus = $this->rustart; $ru = getrusage(); return ( $ru[ "ru_$index.tv_sec" ] * 1000 + intval( $ru[ "ru_$index.tv_usec" ] / 1000 ) ) - ( $rus[ "ru_$index.tv_sec" ] * 1000 + intval( $rus[ "ru_$index.tv_usec" ] / 1000 ) ); }
php
private function elapsedTime( $index = 'utime') { if ( version_compare( PHP_VERSION, "7.0", "<" ) ) return; $rus = $this->rustart; $ru = getrusage(); return ( $ru[ "ru_$index.tv_sec" ] * 1000 + intval( $ru[ "ru_$index.tv_usec" ] / 1000 ) ) - ( $rus[ "ru_$index.tv_sec" ] * 1000 + intval( $rus[ "ru_$index.tv_usec" ] / 1000 ) ); }
[ "private", "function", "elapsedTime", "(", "$", "index", "=", "'utime'", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "\"7.0\"", ",", "\"<\"", ")", ")", "return", ";", "$", "rus", "=", "$", "this", "->", "rustart", ";", "$", "ru", ...
Generate a progress value in milliseconds @param string $index An index such as 'utime' or 'stime' @return void|number
[ "Generate", "a", "progress", "value", "in", "milliseconds" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/XBRL-Report-Base.php#L3413-L3420
train
bseddon/XBRL
Formulas/Resources/Formulas/GeneratedFacts.php
GeneratedFacts.generateInstanceDocument
public function generateInstanceDocument( $xbrlInstance, $nsMgr ) { // Get the namespaces from the input documment // $namespaces = $xbrlInstance->getInstanceXml()->getDocNamespaces(); // Get the taxonomy document uri from the input document $taxonomyUri = $xbrlInstance->getInstanceTaxonomy()->getTaxonomyXSD(); $document[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $document[] = "<!-- Generated by XBRLQuery formula processor -->"; // Add the root element and namespaces // First make sure there is a default xbrli prefix if ( ! isset( $this->namespaces[''] ) ) { $this->namespaces[''] = \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ]; } $document[] ="<xbrl"; foreach ( $this->namespaces as $prefix => $namespace ) { $document[] = " " . ( $prefix ? "xmlns:$prefix=\"$namespace\"" : "xmlns=\"$namespace\"" ); } if ( ! isset( $this->namespaces['xsi'] ) && array_filter( $this->facts, function( $facts ) { return array_filter( $facts, function( $fact ) { return is_null( $fact['value'] ); } ); } ) ) { $document[] = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; } if ( ! isset( $this->namespaces['link'] ) ) { $document[] = " xmlns:link=\"http://www.xbrl.org/2003/linkbase\""; } $document[] =">"; // Add the schema ref $document[] = ""; $document[] = " <link:schemaRef xlink:type=\"simple\" xlink:href=\"$taxonomyUri\"/>"; $document[] = ""; foreach ( $this->linkbases as $linkbase ) { $document[] = " <link:linkbaseRef"; $document[] = " xlink:type=\"{$linkbase['xlink:type']}\""; $document[] = " xlink:arcrole=\"{$linkbase['xlink:arcrole']}\""; $document[] = " xlink:href=\"{$linkbase['xlink:href']}\""; $document[] = " />"; $document[] = ""; } // Add the contexts // $this->addContexts( $document, $xbrlInstance->getPrefixForNamespace( \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDI ] ) ); $this->addContexts( $document, STANDARD_PREFIX_XBRLDI ); // Add the units $this->addUnits( $document ); // Add the facts $this->addFacts2( $document ); // Close the document $document[] ="</xbrl>"; // Run validation on the generated document return implode( "\n", $document) ; }
php
public function generateInstanceDocument( $xbrlInstance, $nsMgr ) { // Get the namespaces from the input documment // $namespaces = $xbrlInstance->getInstanceXml()->getDocNamespaces(); // Get the taxonomy document uri from the input document $taxonomyUri = $xbrlInstance->getInstanceTaxonomy()->getTaxonomyXSD(); $document[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $document[] = "<!-- Generated by XBRLQuery formula processor -->"; // Add the root element and namespaces // First make sure there is a default xbrli prefix if ( ! isset( $this->namespaces[''] ) ) { $this->namespaces[''] = \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ]; } $document[] ="<xbrl"; foreach ( $this->namespaces as $prefix => $namespace ) { $document[] = " " . ( $prefix ? "xmlns:$prefix=\"$namespace\"" : "xmlns=\"$namespace\"" ); } if ( ! isset( $this->namespaces['xsi'] ) && array_filter( $this->facts, function( $facts ) { return array_filter( $facts, function( $fact ) { return is_null( $fact['value'] ); } ); } ) ) { $document[] = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; } if ( ! isset( $this->namespaces['link'] ) ) { $document[] = " xmlns:link=\"http://www.xbrl.org/2003/linkbase\""; } $document[] =">"; // Add the schema ref $document[] = ""; $document[] = " <link:schemaRef xlink:type=\"simple\" xlink:href=\"$taxonomyUri\"/>"; $document[] = ""; foreach ( $this->linkbases as $linkbase ) { $document[] = " <link:linkbaseRef"; $document[] = " xlink:type=\"{$linkbase['xlink:type']}\""; $document[] = " xlink:arcrole=\"{$linkbase['xlink:arcrole']}\""; $document[] = " xlink:href=\"{$linkbase['xlink:href']}\""; $document[] = " />"; $document[] = ""; } // Add the contexts // $this->addContexts( $document, $xbrlInstance->getPrefixForNamespace( \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDI ] ) ); $this->addContexts( $document, STANDARD_PREFIX_XBRLDI ); // Add the units $this->addUnits( $document ); // Add the facts $this->addFacts2( $document ); // Close the document $document[] ="</xbrl>"; // Run validation on the generated document return implode( "\n", $document) ; }
[ "public", "function", "generateInstanceDocument", "(", "$", "xbrlInstance", ",", "$", "nsMgr", ")", "{", "// Get the namespaces from the input documment\r", "// $namespaces = $xbrlInstance->getInstanceXml()->getDocNamespaces();\r", "// Get the taxonomy document uri from the input document\...
Generate an XML instance document @param \XBRL_Instance $xbrlInstance The source instance from which the facts have been generated @param XmlNamespaceManager $nsMgr @return string
[ "Generate", "an", "XML", "instance", "document" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/GeneratedFacts.php#L128-L198
train
bseddon/XBRL
Formulas/Resources/Formulas/GeneratedFacts.php
GeneratedFacts.indexConcepts
private function indexConcepts( $nav, $xbrlInstance, &$index = array(), $path = "" ) { // $index = array(); $flag = true; $first = $nav->getLineNo(); $taxonomy = $xbrlInstance->getInstanceTaxonomy(); do { $name = "{$nav->getNamespaceURI()}:{$nav->getLocalName()}"; if ( $path ) $name = "$path,$name"; $num = $nav->getLineNo() - $first + 1; if ( FactValues::isTuple( $nav ) ) { $index[ $name ][ null ][ null ][ $num ][] = $nav->CloneInstance(); $childNav = $nav->CloneInstance(); if ( $childNav->MoveToChild( XPathNodeType::Element ) ) { $result = $this->indexConcepts( $childNav, $xbrlInstance, $index, $name ); // $index = array_merge_recursive( $index, $result ); } } else { $contextRef = $nav->GetAttribute( "contextRef", null ); $unitRef = $nav->GetAttribute( "unitRef", null ); $index[ $name ][ $contextRef ][ $unitRef ][ $num ][] = $nav->CloneInstance(); } $flag = $nav->MoveToNext( XPathNodeType::Element ); } while ( $flag ); return $index; }
php
private function indexConcepts( $nav, $xbrlInstance, &$index = array(), $path = "" ) { // $index = array(); $flag = true; $first = $nav->getLineNo(); $taxonomy = $xbrlInstance->getInstanceTaxonomy(); do { $name = "{$nav->getNamespaceURI()}:{$nav->getLocalName()}"; if ( $path ) $name = "$path,$name"; $num = $nav->getLineNo() - $first + 1; if ( FactValues::isTuple( $nav ) ) { $index[ $name ][ null ][ null ][ $num ][] = $nav->CloneInstance(); $childNav = $nav->CloneInstance(); if ( $childNav->MoveToChild( XPathNodeType::Element ) ) { $result = $this->indexConcepts( $childNav, $xbrlInstance, $index, $name ); // $index = array_merge_recursive( $index, $result ); } } else { $contextRef = $nav->GetAttribute( "contextRef", null ); $unitRef = $nav->GetAttribute( "unitRef", null ); $index[ $name ][ $contextRef ][ $unitRef ][ $num ][] = $nav->CloneInstance(); } $flag = $nav->MoveToNext( XPathNodeType::Element ); } while ( $flag ); return $index; }
[ "private", "function", "indexConcepts", "(", "$", "nav", ",", "$", "xbrlInstance", ",", "&", "$", "index", "=", "array", "(", ")", ",", "$", "path", "=", "\"\"", ")", "{", "// $index = array();\r", "$", "flag", "=", "true", ";", "$", "first", "=", "$...
Creates an indexed array of concepts. The index is concept|contextRef|unitRef => nav The unit maybe empty if there is no unit @param DOMXPathNavigator $nav @param \XBRL_Instance $xbrlInstance @param array $index (by reference) A list of concepts @param string $path (by reference) @return A list of concepts
[ "Creates", "an", "indexed", "array", "of", "concepts", ".", "The", "index", "is", "concept|contextRef|unitRef", "=", ">", "nav", "The", "unit", "maybe", "empty", "if", "there", "is", "no", "unit" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/GeneratedFacts.php#L491-L525
train
bseddon/XBRL
Formulas/Resources/Formulas/GeneratedFacts.php
GeneratedFacts.compareConcepts
private function compareConcepts( $expectedNav, $generatedNav, $expectedContexts, $generatedContexts, $expectedUnits, $generatedUnits, $expectedConceptNavIsTuple, $generatedNavIsTuple ) { // Compare the names if ( $expectedNav->getLocalName() != $generatedNav->getLocalName() || $expectedNav->getNamespaceURI() != $generatedNav->getNamespaceURI() ) { $this->comparisonError = "The concept names and/or namespaces do not match for concept line numbers {$expectedNav->getLineNo()} and {$generatedNav->getLineNo()}"; return false; } if ( $expectedConceptNavIsTuple != $generatedNavIsTuple ) { return false; } if ( $expectedConceptNavIsTuple ) { return true; } // Make sure the elements have the same parent $expectedNavParent = $expectedNav->CloneInstance(); $generatedNavParent = $generatedNav->CloneInstance(); $expectedNavHasParent = $expectedNavParent->MoveToParent(); $generatedNavHasParent = $generatedNavParent->MoveToParent(); if ( $expectedNavHasParent != $generatedNavHasParent ) { return false; } if ( $expectedNavParent->getLocalName() != $generatedNavParent->getLocalName() || $expectedNavParent->getNamespaceURI() != $generatedNavParent->getNamespaceURI() ) { return false; } // Compare the value if it is a simple value $expectedHasChildren = $expectedNav->CloneInstance()->MoveToChild( XPathNodeType::Element ); $generatedHasChildren = $generatedNav->CloneInstance()->MoveToChild( XPathNodeType::Element ); if ( $expectedHasChildren != $generatedHasChildren ) { $this->comparisonError = "There is a mis-match between the number of nested elements in expected concept {$expectedNav->getLineNo()} ({$expectedNav->getName()})"; return false; } if ( ! $generatedHasChildren ) { $expectedValue = trim( $expectedNav->getValue() ); $generatedValue = trim( $generatedNav->getValue() ); if ( $expectedValue != $generatedValue ) { $this->comparisonError = "The values in expected concept {$expectedNav->getLineNo()} ({$expectedNav->getName()}) do not match"; return false; } } // Compare the attributes if ( ! $this->compareAttributes( $expectedNav, $generatedNav, $expectedContexts, $generatedContexts, $expectedUnits, $generatedUnits ) ) { // Any error will be reported by the sub-function return false; } // BMS 2018-03-18 Don't want to do this because the child elements may be in a different order but still equivalent (just not exactly the same). // // Compare any nested elements (tuples) // if ( $generatedHasChildren ) // { // $expectedChildNav = $expectedNav->CloneInstance(); // $result1 = $expectedChildNav->MoveToChild( XPathNodeType::Element ); // // $generatedChildNav = $expectedNav->CloneInstance(); // $result2 = $generatedChildNav->MoveToChild( XPathNodeType::Element ); // // do // { // if ( ! $this->compareConcepts( // $expectedChildNav, // $generatedChildNav, // $expectedContexts, // $generatedContexts, // $expectedUnits, // $generatedUnits // ) // ) // { // // Any error will be reported by the sub-function // return false; // } // // $result1 = $expectedChildNav->MoveToNext( XPathNodeType::Element ); // $result2 = $generatedChildNav->MoveToNext( XPathNodeType::Element ); // } // while( $result1 && $result2 ); // // } return true; }
php
private function compareConcepts( $expectedNav, $generatedNav, $expectedContexts, $generatedContexts, $expectedUnits, $generatedUnits, $expectedConceptNavIsTuple, $generatedNavIsTuple ) { // Compare the names if ( $expectedNav->getLocalName() != $generatedNav->getLocalName() || $expectedNav->getNamespaceURI() != $generatedNav->getNamespaceURI() ) { $this->comparisonError = "The concept names and/or namespaces do not match for concept line numbers {$expectedNav->getLineNo()} and {$generatedNav->getLineNo()}"; return false; } if ( $expectedConceptNavIsTuple != $generatedNavIsTuple ) { return false; } if ( $expectedConceptNavIsTuple ) { return true; } // Make sure the elements have the same parent $expectedNavParent = $expectedNav->CloneInstance(); $generatedNavParent = $generatedNav->CloneInstance(); $expectedNavHasParent = $expectedNavParent->MoveToParent(); $generatedNavHasParent = $generatedNavParent->MoveToParent(); if ( $expectedNavHasParent != $generatedNavHasParent ) { return false; } if ( $expectedNavParent->getLocalName() != $generatedNavParent->getLocalName() || $expectedNavParent->getNamespaceURI() != $generatedNavParent->getNamespaceURI() ) { return false; } // Compare the value if it is a simple value $expectedHasChildren = $expectedNav->CloneInstance()->MoveToChild( XPathNodeType::Element ); $generatedHasChildren = $generatedNav->CloneInstance()->MoveToChild( XPathNodeType::Element ); if ( $expectedHasChildren != $generatedHasChildren ) { $this->comparisonError = "There is a mis-match between the number of nested elements in expected concept {$expectedNav->getLineNo()} ({$expectedNav->getName()})"; return false; } if ( ! $generatedHasChildren ) { $expectedValue = trim( $expectedNav->getValue() ); $generatedValue = trim( $generatedNav->getValue() ); if ( $expectedValue != $generatedValue ) { $this->comparisonError = "The values in expected concept {$expectedNav->getLineNo()} ({$expectedNav->getName()}) do not match"; return false; } } // Compare the attributes if ( ! $this->compareAttributes( $expectedNav, $generatedNav, $expectedContexts, $generatedContexts, $expectedUnits, $generatedUnits ) ) { // Any error will be reported by the sub-function return false; } // BMS 2018-03-18 Don't want to do this because the child elements may be in a different order but still equivalent (just not exactly the same). // // Compare any nested elements (tuples) // if ( $generatedHasChildren ) // { // $expectedChildNav = $expectedNav->CloneInstance(); // $result1 = $expectedChildNav->MoveToChild( XPathNodeType::Element ); // // $generatedChildNav = $expectedNav->CloneInstance(); // $result2 = $generatedChildNav->MoveToChild( XPathNodeType::Element ); // // do // { // if ( ! $this->compareConcepts( // $expectedChildNav, // $generatedChildNav, // $expectedContexts, // $generatedContexts, // $expectedUnits, // $generatedUnits // ) // ) // { // // Any error will be reported by the sub-function // return false; // } // // $result1 = $expectedChildNav->MoveToNext( XPathNodeType::Element ); // $result2 = $generatedChildNav->MoveToNext( XPathNodeType::Element ); // } // while( $result1 && $result2 ); // // } return true; }
[ "private", "function", "compareConcepts", "(", "$", "expectedNav", ",", "$", "generatedNav", ",", "$", "expectedContexts", ",", "$", "generatedContexts", ",", "$", "expectedUnits", ",", "$", "generatedUnits", ",", "$", "expectedConceptNavIsTuple", ",", "$", "gener...
Compare each concept. The name of the concept ref and of the unit refs may be different but the content should be OK @param DOMXPathNavigator $expectedNav @param DOMXPathNavigator $generatedNav @param array[DOMXPathNavigator] $expectedContexts @param array[DOMXPathNavigator] $generatedContexts @param array[DOMXPathNavigator] $expectedUnits @param array[DOMXPathNavigator] $generatedUnits @param bool $expectedConceptNavIsTuple @param bool $generatedNavIsTuple @return bool
[ "Compare", "each", "concept", ".", "The", "name", "of", "the", "concept", "ref", "and", "of", "the", "unit", "refs", "may", "be", "different", "but", "the", "content", "should", "be", "OK" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/GeneratedFacts.php#L586-L685
train
bseddon/XBRL
Formulas/Resources/Formulas/GeneratedFacts.php
GeneratedFacts.compareNodes
private function compareNodes( $expectedNav, $generatedNav ) { if ( is_null( $this->comparer ) ) { // $this->comparer = new TreeComparer( null ); $this->comparer = new ContextComparer( null ); $this->comparer->excludeWhitespace = true; } return $this->comparer->DeepEqualByNavigator( $expectedNav , $generatedNav ); }
php
private function compareNodes( $expectedNav, $generatedNav ) { if ( is_null( $this->comparer ) ) { // $this->comparer = new TreeComparer( null ); $this->comparer = new ContextComparer( null ); $this->comparer->excludeWhitespace = true; } return $this->comparer->DeepEqualByNavigator( $expectedNav , $generatedNav ); }
[ "private", "function", "compareNodes", "(", "$", "expectedNav", ",", "$", "generatedNav", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "comparer", ")", ")", "{", "// $this->comparer = new TreeComparer( null );\r", "$", "this", "->", "comparer", "=", ...
Compare two nodes for equality @param DOMXPathNavigator $expectedNav @param DOMXPathNavigator $generatedNav
[ "Compare", "two", "nodes", "for", "equality" ]
6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94
https://github.com/bseddon/XBRL/blob/6ffdcedd68b0a7957b2358bcec15b22bd4c5dc94/Formulas/Resources/Formulas/GeneratedFacts.php#L819-L829
train