hakone / untouchable-psr7
PSR-7 message implementation with all method calls restricted
1.1.0
2026-08-18 18:34 UTC
Requires
- php: ^8.2
- psr/http-message: ^2.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.9
- nyholm/psr7: ^1.8
- php-http/discovery: ^1.20
This package is auto-updated.
Last update: 2026-08-18 18:34:57 UTC
README
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.