private function processRecord(array $record): ?int
    {
        $requestId = $record['requestId'];

        $content = 0 === $record['contentLength'] ? null : $record['contentData'];

        if (DaemonInterface::FCGI_BEGIN_REQUEST === $record['type']) {
            $this->processBeginRequestRecord($requestId, $content);
        } elseif (!isset($this->requests[$requestId])) {
            throw new ProtocolException('Invalid request id for record of type: '.$record['type']);
        } elseif (DaemonInterface::FCGI_PARAMS === $record['type']) {
            while (null !== $content && strlen($content) > 0) {
                $this->readNameValuePair($requestId, $content);
            }
        } elseif (DaemonInterface::FCGI_STDIN === $record['type']) {
            if (null !== $content) {
                fwrite($this->requests[$requestId]['stdin'], $content);
            } else {
                // Returns the status code
                return $this->dispatchRequest($requestId);
            }
        } elseif (DaemonInterface::FCGI_ABORT_REQUEST === $record['type']) {
            $this->endRequest($requestId);
        } else {
            throw new ProtocolException('Unexpected packet of type: '.$record['type']);
        }

        return null; // No status code to return
    }
private function processRecord(array $record): ?int
    {
        $requestId = $record['requestId'];

        $content = 0 === $record['contentLength'] ? null : $record['contentData'];

        if (DaemonInterface::FCGI_BEGIN_REQUEST === $record['type']) {
            $this->processBeginRequestRecord($requestId, $content);
        } elseif (!isset($this->requests[$requestId])) {
            throw new ProtocolException('Invalid request id for record of type: '.$record['type']);
        } elseif (DaemonInterface::FCGI_PARAMS === $record['type']) {
            while (null !== $content && strlen($content) > 0) {
                $this->readNameValuePair($requestId, $content);
            }
        } elseif (DaemonInterface::FCGI_STDIN === $record['type']) {
            if (null !== $content) {
                fwrite($this->requests[$requestId]['stdin'], $content);
            } else {
                // Returns the status code
                return $this->dispatchRequest($requestId);
            }
        } elseif (DaemonInterface::FCGI_ABORT_REQUEST === $record['type']) {
            $this->endRequest($requestId);
        } else {
            throw new ProtocolException('Unexpected packet of type: '.$record['type']);
        }

        return null; // No status code to return
    }
private function processRecord ( array $ record ) : ? int { $ requestId = $ record [ 'requestId' ] ; $ content = 0 === $ record [ 'contentLength' ] ? null : $ record [ 'contentData' ] ; if ( DaemonInterface :: FCGI_BEGIN_REQUEST === $ record [ 'type' ] ) { $ this -> processBeginRequestRecord ( $ requestId , $ content ) ; } elseif ( ! isset ( $ this -> requests [ $ requestId ] ) ) { throw new ProtocolException ( 'Invalid request id for record of type: ' . $ record [ 'type' ] ) ; } elseif ( DaemonInterface :: FCGI_PARAMS === $ record [ 'type' ] ) { while ( null !== $ content && strlen ( $ content ) > 0 ) { $ this -> readNameValuePair ( $ requestId , $ content ) ; } } elseif ( DaemonInterface :: FCGI_STDIN === $ record [ 'type' ] ) { if ( null !== $ content ) { fwrite ( $ this -> requests [ $ requestId ] [ 'stdin' ] , $ content ) ; } else { // Returns the status code return $ this -> dispatchRequest ( $ requestId ) ; } } elseif ( DaemonInterface :: FCGI_ABORT_REQUEST === $ record [ 'type' ] ) { $ this -> endRequest ( $ requestId ) ; } else { throw new ProtocolException ( 'Unexpected packet of type: ' . $ record [ 'type' ] ) ; } return null ; // No status code to return }
Process a record.

@param array $record The record that has been read

@return null|int Number of dispatched requests

@throws ProtocolException If the client sends an unexpected record.
Process a record .