Code Monkey home page Code Monkey logo

http-header-kit's People

Contributors

fenric avatar peter279k avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

http-header-kit's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • cimg/php 7.4
  • cimg/php 8.0
  • cimg/php 8.1
composer
composer.json
  • php >=7.4
  • sunrise/http-header ^3.0
  • phpunit/phpunit ~9.5.0
  • sunrise/coding-standard ~1.0.0
  • sunrise/uri ~1.2.0

  • Check this box to trigger a request for Renovate to run again on this repository

Psalm doesn't understand unpacking

->withHeader(...new HeaderWWWAuthenticate(HeaderWWWAuthenticate::HTTP_AUTHENTICATE_SCHEME_BEARER))
INFO: InvalidArgument - src/Middleware/ErrorHandlingMiddleware.php:111:29 - Method Psr\Http\Message\ResponseInterface::withHeader called with unpacked iterable Sunrise\Http\Header\HeaderWWWAuthenticate with invalid key (must be int|string) (see https://psalm.dev/004)
            ->withHeader(...new HeaderWWWAuthenticate(HeaderWWWAuthenticate::HTTP_AUTHENTICATE_SCHEME_BEARER));

Helper method for many headers

What do you think about a helper method that takes your classes and returns an array of formatted headers suitable for the ServerRequest?

$headers = \Sunrise\Http\Headers::make([
    new HeaderCookie('whatever'),
    new HeaderContentEncoding('multipart/form-data')
    new HeaderSomethingElse('foo')
]);
$request = new ServerRequest('POST', 'https://example.com', $headers, 'Whatever');

type casting and inheritdoc

Hi. Thanks for http-header-kit. Tons of handy tools in here.
A couple of related questions

https://github.com/sunrise-php/http-header-kit/blob/master/src/AbstractHeader.php#L26 has @inheritdoc but it does not inherit from anything.

If I do something like this

$handler = new class implements RequestHandlerInterface {
    public function handle(\Psr\Http\Message\ServerRequestInterface $request): \Psr\Http\Message\ResponseInterface
    {
        $response = new \GuzzleHttp\Psr7\Response(200, [], 'Hello world');
        $response = (new \Sunrise\Http\Header\HeaderContentType('text/plain'))->setToMessage($response);
        return $response;
    }
};

phpstan and phpStorm both complain that $response is a MessageInterface instead of a ResponseInterface

Would you consider changing the return types in AbstractHeader to eg

	/**
	 * @return MessageInterface|RequestInterface|ServerRequestInterface|ResponseInterface
	 */
	public function setToMessage(MessageInterface $message);

to keep these tools happy?

or (alternatively) providing strictly typed variants eg

	/**
	 * @return ServerRequestInterface
	 */
	public function setToServerRequest(ServerRequestInterface $message): ServerRequestInterface;

and similar for MessageInterface, ResponseInterface, RequestInterface etc

Implement new HTTP headers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.