hakone/untouchable-psr7

PSR-7 message implementation with all method calls restricted

Maintainers

Package info

github.com/hakonephp/untouchable-psr7

pkg:composer/hakone/untouchable-psr7

Transparency log

Statistics

Installs: 10 983

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

1.1.0 2026-08-18 18:34 UTC

This package is auto-updated.

Last update: 2026-08-18 18:34:57 UTC


README

Package version Build Status Downloads this Month

This package provides special HTTP messages referenced by PSR-15 middlewares.

Any method call throws. Use it as the handler response type so a request interceptor cannot inspect or mutate the response.

Install

composer require hakone/untouchable-psr7

Usage

use Hakone\Http\Message\UntouchableResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

final class AddAttributeMiddleware
{
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $request->withAttribute('foo', 'bar');

        // The handler may return UntouchableResponse. Do not call methods on it.
        return $handler->handle($request);
    }
}

Calling any method on UntouchableResponse throws DoNotCallMethodException.

Copyright

Copyright 2023 USAMI Kenta <tadsan@zonu.me>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.