Read a FastCGI Packet

@return array
491889
private function readPacket()
    {
        if ($packet = fread($this->_sock, self::HEADER_LEN)) {
            $resp = $this->decodePacketHeader($packet);
            $resp['content'] = '';
            if ($resp['contentLength']) {
                $len  = $resp['contentLength'];
                while ($len && ($buf=fread($this->_sock, $len)) !== false) {
                    $len -= strlen($buf);
                    $resp['content'] .= $buf;
                }
            }
            if ($resp['paddingLength']) {
                $buf = fread($this->_sock, $resp['paddingLength']);
            }
            return $resp;
        } else {
            return false;
        }
    }
675018
private function read()
    {
        $s = null;

        for (; !feof($this->sock);) {
            if (($line = fgets($this->sock, 1e3)) == null) {
                continue;
            }

            $s = explode(' ', $line)[0];

            if (preg_match('#^[0-9]+$#', $s)) {
                break;
            }
        }

        return (int) $s;
    }
35843
public function getETags()
    {
        $result = array();
        if($this->_headers->has('If-None-Match'))
        {
            $result = preg_split('/\s*,\s*/', $this->_headers->get('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);

            //Remove the encoding from the etag
            //
            //RFC-7232 explicitly states that ETags should be content-coding aware
            $result = str_replace('-gzip', '', $result);
        }

        return $result;
    }
454728
public function getReadme(): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/readme',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
    }
606603
public function read()
    {
        $data = @fread($this->stream, 30000);

        if($data === false) return;
        $this->buffer .= $data;

        if(!is_null($this->status)) return;
        if(strlen($this->buffer) < 4) return;
        $end = strpos($this->buffer, "\r\n\r\n", 4);
        if($end === false) return;

        list($request, $headers) = $this->parse_header(substr($this->buffer, 0, $end));
        list($version, $status, $phrase) = explode(' ', $request, 3);
        $this->status = $status;
        $this->response_length = isset($headers['content-length'])? (int)$headers['content-length'][0] : 0;
    }
924530
public function decode($frame)
    {
        $payload = Packet::getPayload($frame->data);

        return [
            'event' => $payload['event'] ?? null,
            'data' => $payload['data'] ?? null,
        ];
    }
301185
private function read()
	{
		// Ignore first byte
		fread($this->fd, 1);

		// There is also masking bit, as MSB, bit it's 0
		$payloadLength = ord(fread($this->fd, 1));

		switch ($payloadLength) {
			case 126:
				$payloadLength = unpack("n", fread($this->fd, 2));
				$payloadLength = $payloadLength[1];
				break;
			case 127:
				//$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!");
				break;
		}

		return fread($this->fd, $payloadLength);
	}
667206
public static function readComposerLock(): array
    {
        if (self::$composerLockCache !== null) {
            return self::$composerLockCache;
        }

        if (!file_exists(FLOW_PATH_ROOT . 'composer.lock')) {
            return [];
        }

        $json = file_get_contents(FLOW_PATH_ROOT . 'composer.lock');
        $composerLock = json_decode($json, true);
        $composerPackageVersions = isset($composerLock['packages']) ? $composerLock['packages'] : [];
        $composerPackageDevVersions = isset($composerLock['packages-dev']) ? $composerLock['packages-dev'] : [];
        self::$composerLockCache = array_merge($composerPackageVersions, $composerPackageDevVersions);

        return self::$composerLockCache;
    }
145403
private function readRoutineMetadata(): array
  {
    $data = file_get_contents($this->metadataFilename);

    $routines = (array)json_decode($data, true);
    if (json_last_error()!=JSON_ERROR_NONE)
    {
      throw new RuntimeException("Error decoding JSON: '%s'.", json_last_error_msg());
    }

    return $routines;
  }
821550
protected function readdmesg()
    {
        if (count($this->_dmesg) === 0) {
            if (CommonFunctions::rfts('/var/log/messages', $buf)) {
                    $blocks = preg_replace("/\s(kernel: MINIX \d+\.\d+\.\d+\.)/", '<BLOCK>$1', $buf);
                    $parts = preg_split("/<BLOCK>/", $blocks, -1, PREG_SPLIT_NO_EMPTY);
                    $this->_dmesg = preg_split("/\n/", $parts[count($parts) - 1], -1, PREG_SPLIT_NO_EMPTY);
            }
        }

        return $this->_dmesg;
    }
109372
protected function read()
    {
        $filename = $this->filename;
        if (!$this->isFileWritable() && file_exists($this->getCacheFilename())) {
            $filename = $this->getCacheFilename();
        }

        if (!file_exists($filename)) {
            return array();
        }

        $ret = Yaml::parse(file_get_contents($filename));
        if (false === $ret || array() === $ret) {
            throw new \InvalidArgumentException(sprintf('The %s file is not valid.', $filename));
        }

        if (isset($ret['parameters']) && is_array($ret['parameters'])) {
            return $ret['parameters'];
        } else {
            return array();
        }
    }
1168028
private function readRecord(): array
    {
        // Not enough data to read header
        if ($this->bufferLength < 8) {
            return [];
        }

        $headerData = substr($this->buffer, 0, 8);

        $headerFormat = 'Cversion/Ctype/nrequestId/ncontentLength/CpaddingLength/x';

        $record = unpack($headerFormat, $headerData);

        // Not enough data to read rest of record
        if ($this->bufferLength - 8 < $record['contentLength'] + $record['paddingLength']) {
            return [];
        }

        $record['contentData'] = substr($this->buffer, 8, $record['contentLength']);

        // Remove the record from the buffer
        $recordSize = 8 + $record['contentLength'] + $record['paddingLength'];

        $this->buffer        = substr($this->buffer, $recordSize);
        $this->bufferLength -= $recordSize;

        return $record;
    }
1314094
public function read(): array
    {
        if ( isset($this->data)) {
            return $this->data;
        }

        $this->data = [];
        foreach ($this->source as &$row) {
            //checking if the source corresponds to the wanted format
            if (array_filter($row, 'is_scalar') == $row) {
                $this->data[] = $row;
            }
        }

        return $this->data;
    }
958252
public function onRead()
    {
        while (($buflen = $this->getInputLength()) >= 2) {
            $hdr = $this->look(10);
            $frametype = ord(mb_orig_substr($hdr, 0, 1));
            if (($frametype & 0x80) === 0x80) {
                $len = 0;
                $i = 0;
                do {
                    if ($buflen < $i + 1) {
                        return;
                    }
                    $b = ord(mb_orig_substr($hdr, ++$i, 1));
                    $n = $b & 0x7F;
                    $len *= 0x80;
                    $len += $n;
                } while ($b > 0x80);

                if ($this->pool->maxAllowedPacket <= $len) {
                    // Too big packet
                    $this->finish();
                    return;
                }

                if ($buflen < $len + $i + 1) {
                    // not enough data yet
                    return;
                }

                $this->drain($i + 1);
                $this->onFrame($this->read($len), $frametype);
            } else {
                if (($p = $this->search("\xFF")) !== false) {
                    if ($this->pool->maxAllowedPacket <= $p - 1) {
                        // Too big packet
                        $this->finish();
                        return;
                    }
                    $this->drain(1);
                    $data = $this->read($p);
                    $this->drain(1);
                    $this->onFrame($data, 'STRING');
                } else {
                    if ($this->pool->maxAllowedPacket < $buflen - 1) {
                        // Too big packet
                        $this->finish();
                        return;
                    }
                }
            }
        }
    }
276214
public function read()
	{
		
		$csvPath = self::buildCsvFilePath($this->prefectureCode);
		
		$buf = mb_convert_encoding(
			file_get_contents($csvPath), 
			mb_internal_encoding(), 
			'sjis-win'
		);
		
		return $buf;
		
	}
617228
public function read() : array
    {
        if (!$this->beta or !$this->gamma) {
            throw new RuntimeException('Layer has not been initilaized.');
        }

        return [
            'beta' => clone $this->beta,
            'gamma' => clone $this->gamma,
        ];
    }
1353819
protected function _read() {
        $code = null;
        $len = -1;
        while ( ! feof($this->_varnishConn)) {
            $response = fgets($this->_varnishConn, self::READ_CHUNK_SIZE);
            if (empty($response)) {
                $streamMeta = stream_get_meta_data($this->_varnishConn);
                if ($streamMeta['timed_out']) {
                    Mage::throwException('Varnish admin socket timeout');
                }
            }
            if (preg_match('~^(\d{3}) (\d+)~', $response, $match)) {
                $code = (int) $match[1];
                $len = (int) $match[2];
                break;
            }
        }

        if (is_null($code)) {
            Mage::throwException('Failed to read response code from Varnish');
        } else {
            $response = array('code' => $code, 'text' => '');
            while ( ! feof($this->_varnishConn) &&
                    strlen($response['text']) < $len) {
                $response['text'] .= fgets($this->_varnishConn,
                    self::READ_CHUNK_SIZE);
            }
            return $response;
        }
    }