private function resolveReferences($path, $references, $flags = 0)
    {
        $result = array();

        if (!is_array($references)) {
            $references = array($references);
        }

        foreach ($references as $key => $reference) {
            // Keep non-filesystem references as they are
            if (!$this->isFilesystemReference($reference)) {
                $result[] = $reference;

                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }

                continue;
            }

            $absoluteReference = Path::makeAbsolute($reference, $this->baseDirectory);
            $referenceExists = file_exists($absoluteReference);

            if (($flags & self::NO_CHECK_FILE_EXISTS) || $referenceExists) {
                $result[] = $absoluteReference;

                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }
            }

            if (!$referenceExists) {
                $this->logReferenceNotFound($path, $reference, $absoluteReference);
            }
        }

        return $result;
    }