@param string|null $snapshotPath

@return array
517949
public static function getSnapshotContents($snapshotPath = null)
    {
        $snapshotPath = $snapshotPath ?: static::getSnapshotPath();

        // If we're in update mode, purge the snapshots to recreate
        // them from scratch if this is the first assertion
        // of this test suite
        $assertions = array_values(static::$assertionsInTest);
        if (static::isUpdate() && $assertions === [0] && file_exists($snapshotPath)) {
            unlink($snapshotPath);
        }

        // If the folder doesn't yet exist, create it
        if (!is_dir(dirname($snapshotPath))) {
            mkdir(dirname($snapshotPath));
        }

        // If the file exists, fetch its contents, else
        // start from a new snapshot
        $contents = file_exists($snapshotPath)
            ? static::unserialize(file_get_contents($snapshotPath))
            : [];

        return $contents;
    }
957897
def load_expected_snapshots( snapshots_path ):
    
    # use snapshots?
    snapshots_path = os.path.expanduser(snapshots_path)
    expected_snapshots = {}

    # legacy chainstate?
    try:
        with open(snapshots_path, "r") as f:
            snapshots_json = f.read()
        
        snapshots_data = json.loads(snapshots_json)
        assert 'snapshots' in snapshots_data.keys(), "Not a valid snapshots file"

        # extract snapshots: map int to consensus hash
        for (block_id_str, consensus_hash) in snapshots_data['snapshots'].items():
            expected_snapshots[ int(block_id_str) ] = str(consensus_hash)
        
        log.debug("Loaded expected snapshots from legacy JSON {}; {} entries".format(snapshots_path, len(expected_snapshots)))
        return expected_snapshots
    
    except ValueError as ve:
        log.debug("Snapshots file {} is not JSON".format(snapshots_path))

    except Exception as e:
        if os.environ.get('BLOCKSTACK_DEBUG') == '1':
            log.exception(e)

        log.debug("Failed to read expected snapshots from '{}'".format(snapshots_path))
        return None

    try:
        # sqlite3 db?
        db_con = virtualchain.StateEngine.db_connect(snapshots_path)
        expected_snapshots = virtualchain.StateEngine.get_consensus_hashes(None, None, db_con=db_con, completeness_check=False)
        log.debug("Loaded expected snapshots from chainstate DB {}, {} entries".format(snapshots_path, len(expected_snapshots)))
        return expected_snapshots

    except:
        log.debug("{} does not appear to be a chainstate DB".format(snapshots_path))

    return None
583920
public function forProperty(string $propertyPath = null): Result
    {
        if ($propertyPath === '' || $propertyPath === null) {
            return $this;
        }
        if (strpos($propertyPath, '.') !== false) {
            return $this->recurseThroughResult(explode('.', $propertyPath));
        }
        if (!isset($this->propertyResults[$propertyPath])) {
            $newResult = new Result();
            $newResult->setParent($this);
            $this->propertyResults[$propertyPath] = $newResult;
        }
        return $this->propertyResults[$propertyPath];
    }
741256
private function snapshotCursorValues(DocumentSnapshot $snapshot, array $orderBy)
    {
        $fieldValues = [];
        foreach ($orderBy as $order) {
            $path = $order['field']['fieldPath'];
            if ($path === self::DOCUMENT_ID) {
                continue;
            }

            $fieldValues[] = $snapshot->get($path);
        }

        $fieldValues[] = $snapshot->reference();
        return $fieldValues;
    }
1210593
public function getSuitePaths(string $path)
    {
        $real = realpath($this->getConfigDir() . $path);

        if ($real !== false) {
            return [$real];
        }

        if ($this->isGlobRequired($path)) {
            $paths = [];
            foreach (glob($this->getConfigDir() . $path, GLOB_ONLYDIR) as $path) {
                if (($path = realpath($path)) !== false) {
                    $paths[] = $path;
                }
            }

            return $paths;
        }

        throw new \RuntimeException("Suite path $path could not be found");
    }
468953
public function items($path) {
		if($this->xpath === null)
			return array();
		$r = array();
		$nodes = $this->xpath->evaluate($path);
		foreach($nodes as $n)
			$r[] = new Node($n);
		return $r;
	}
412039
private function snapshotPosition(DocumentSnapshot $snapshot, array $orderBy)
    {
        $appendName = true;
        foreach ($orderBy as $order) {
            if ($order['field']['fieldPath'] === self::DOCUMENT_ID) {
                $appendName = false;
                break;
            }
        }

        if ($appendName) {
            // If there is inequality filter (anything other than equals),
            // append orderBy(the last inequality filter’s path, ascending).
            if (!$orderBy && $this->queryHas('where')) {
                $filters = $this->query['where']['compositeFilter']['filters'];
                $inequality = array_filter($filters, function ($filter) {
                    $type = array_keys($filter)[0];
                    return !in_array($filter[$type]['op'], [
                        self::OP_EQUAL,
                        self::OP_ARRAY_CONTAINS
                    ]);
                });

                if ($inequality) {
                    $filter = end($inequality);
                    $type = array_keys($filter)[0];
                    $orderBy[] = [
                        'field' => [
                            'fieldPath' => $filter[$type]['field']['fieldPath'],
                        ],
                        'direction' => self::DIR_ASCENDING
                    ];
                }
            }

            // If the query has existing orderBy constraints
            if ($orderBy) {
                // Append orderBy(__name__, direction of last orderBy clause)
                $lastOrderDirection = end($orderBy)['direction'];
                $orderBy[] = [
                    'field' => [
                        'fieldPath' => self::DOCUMENT_ID
                    ],
                    'direction' => $lastOrderDirection
                ];
            } else {
                // no existing orderBy constraints
                // Otherwise append orderBy(__name__, ‘asc’)
                $orderBy[] = [
                    'field' => [
                        'fieldPath' => self::DOCUMENT_ID
                    ],
                    'direction' => self::DIR_ASCENDING
                ];
            }
        }

        $fieldValues = $this->snapshotCursorValues($snapshot, $orderBy);

        return [
            $fieldValues,
            $orderBy
        ];
    }
113587
public function parse($docPath)
    {
        if ( ! is_dir($docPath)) {
            throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $docPath));
        }

        $sorter = function(\SplFileInfo $a, \SplFileInfo $b) {
            $aIsDir = $a->isDir();
            $bIsDir = $b->isDir();

            if ($aIsDir !== $bIsDir) {
                return $aIsDir ? -1 : 1;
            }

            return -1 * strcmp($a->getRealPath(), $b->getRealPath());
        };

        $this->classes = $this->functions = $this->constants = $this->aliasedFunctions = array();
        foreach (Finder::create()->in($docPath)->name('*.xml')->sort($sorter) as $file) {
            assert($file instanceof \SplFileInfo);
            $this->file = $file;

            $content = file_get_contents($file->getRealPath());
            $content = preg_replace('#<refsect1 role="(?:examples|notes|seealso)">.*?</refsect1>#s', '', $content);
            $content = preg_replace(self::$undefinedEntities, '', $content);
            $content = preg_replace(array_keys(self::$entitySubstitutes), array_values(self::$entitySubstitutes), $content);

            if ('' === trim($content)) {
                continue;
            }

            $doc = simplexml_load_string($content);
            $doc->registerXPathNamespace('search', 'http://docbook.org/ns/docbook');
            if (isset($doc->refnamediv)) {
                // Ignore methods, we will parse them as part of the class.
                if (false !== strpos((string) $doc->refnamediv->refname, '::')) {
                    $this->parseMethod($doc);

                    continue;
                }

                $this->parseFunction($doc);

                continue;
            }

            $this->tryParsingClass($doc);
            $this->tryParsingConstant($doc);
        }

        if ( ! empty($this->aliasedFunctions)) {
            foreach ($this->functions as $function) {
                $aliasedNames = array_keys($this->aliasedFunctions, $function->getName(), true);

                if (empty($aliasedNames)) {
                    continue;
                }

                foreach ($aliasedNames as $name) {
                    $newFunction = clone $function;
                    $newFunction->setName($name);
                    $newFunction->setAttribute('alias_of', $function->getName());
                    $this->functions[] = $newFunction;
                }
            }
        }

        foreach ($this->classes as $class) {
            $this->typeRefiner->refineClass($class);
        }

        $rs = array('classes' => $this->classes, 'functions' => $this->functions, 'constants' => $this->constants);
        $this->classes = $this->functions = $this->constants = $this->aliasedFunctions = null;

        return $rs;
    }
570770
protected function parseFile(string $filePath)
    {
        $lexer = new Lexer([
            'usedAttributes' => [
                'comments', 'startLine', 'endLine',
            ],
        ]);

        $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7, $lexer);

        try {
            $statements = $parser->parse(file_get_contents($filePath));
        } catch (Error $e) {
            return null;
        }

        return $statements;
    }
858
private Map<String, Snapshot> getSnapshots() {
        /*
         * Use the individual snapshot directories instead of voltroot, because
         * they can be set individually
         */
        Map<String, SnapshotPathType> paths = new HashMap<String, SnapshotPathType>();
        if (VoltDB.instance().getConfig().m_isEnterprise) {
            if (m_clSnapshotPath != null) {
                paths.put(m_clSnapshotPath, SnapshotPathType.SNAP_CL);
            }
        }
        if (m_snapshotPath != null) {
            paths.put(m_snapshotPath, SnapshotPathType.SNAP_AUTO);
        }
        HashMap<String, Snapshot> snapshots = new HashMap<String, Snapshot>();
        FileFilter filter = new SnapshotUtil.SnapshotFilter();

        for (String path : paths.keySet()) {
            SnapshotUtil.retrieveSnapshotFiles(new File(path), snapshots, filter, false, paths.get(path), LOG);
        }

        return snapshots;
    }
381485
public static function load( $filePath, $asArray = NULL )
	{
		$reader	= new FS_File_JSON_Reader( $filePath );
		return $reader->read( $asArray );
	}
1148536
public function getColumnTypes(NodePath $nodePath)
    {
        $values = $this->getNodeChildrenProperties($nodePath, 'nodeType');
        $result = [];
        foreach ($values as $key => $value) {
            if ($key === self::ARRAY_NAME) {
                $result[self::DATA_COLUMN] = $value;
            } else {
                $result[$key] = $value;
            }
        }
        return $result;
    }
1132179
public function getSnapshot(): Snapshot
    {
        try {
            $value = $this->apiClient->get($this->getUri());
        } catch (ApiException $e) {
            throw QueryException::fromApiException($e, $this);
        }

        if ($this->sorter) {
            $value = $this->sorter->modifyValue($value);
        }

        foreach ($this->filters as $filter) {
            $value = $filter->modifyValue($value);
        }

        return new Snapshot($this->reference, $value);
    }
1355794
public function parse($filepath)
    {
        $metadata = array();

        $reflectedClass = $this->getReflection($filepath);
        $metadata['class'] = $reflectedClass->getName();

        $propertiesMetadata = $this->processPropertiesParsing($reflectedClass);
        $metadata = array_merge($metadata, $propertiesMetadata);

        return $metadata;
    }
761251
private function loadTags(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
    {
        $result = [];

        /** @var \DOMElement $node */
        foreach ($xpath->query('x:tag', $context) as $node) {
            $tag = $this->loadTag($xpath, $node);
            $this->validateTag($tag, $tags);

            $result[] = $tag;
        }

        return $result;
    }
530184
public function getChildKeys(): array
    {
        $snapshot = $this->shallow()->getSnapshot();

        if (\is_array($value = $snapshot->getValue())) {
            return array_keys($value);
        }

        throw new OutOfRangeException(sprintf('%s has no children with keys', $this));
    }
66766
public function readFile($filePath = null, array $options = [])
    {
        $items = parse_ini_file(
            $filePath,
            (empty($options)
                ? true
                : $options[ 'sections' ])
        );

        $this->merge($items);

        return $items;
    }