Skip to content

Allow psr/http-message ^2.0 #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- 7.4
- 7.3
- 7.2
- 7.1
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.2 || ^8.0",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"fig/http-message-util": "^1.1",
"psr/http-message": "^1.0",
"psr/http-message": "^2.0",
"react/event-loop": "^1.2",
"react/promise": "^3.2 || ^2.3 || ^1.2.1",
"react/socket": "^1.16",
"react/stream": "^1.4"
},
"require-dev": {
"clue/http-proxy-react": "^1.8",
"clue/reactphp-ssh-proxy": "^1.4",
"clue/socks-react": "^1.4",
"phpunit/phpunit": "^9.6 || ^7.5",
Expand Down
31 changes: 0 additions & 31 deletions examples/11-client-http-proxy.php

This file was deleted.

26 changes: 13 additions & 13 deletions src/Io/AbstractMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,45 @@ protected function __construct($protocolVersion, array $headers, StreamInterface
$this->body = $body;
}

public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->protocolVersion;
}

public function withProtocolVersion($version)
public function withProtocolVersion(string $version): MessageInterface
{
if ((string) $version === $this->protocolVersion) {
if ($version === $this->protocolVersion) {
return $this;
}

$message = clone $this;
$message->protocolVersion = (string) $version;
$message->protocolVersion = $version;

return $message;
}

public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}

public function hasHeader($name)
public function hasHeader(string $name): bool
{
return isset($this->headerNamesLowerCase[\strtolower($name)]);
}

public function getHeader($name)
public function getHeader(string $name): array
{
$lower = \strtolower($name);
return isset($this->headerNamesLowerCase[$lower]) ? $this->headers[$this->headerNamesLowerCase[$lower]] : [];
}

public function getHeaderLine($name)
public function getHeaderLine(string $name): string
{
return \implode(', ', $this->getHeader($name));
}

public function withHeader($name, $value)
public function withHeader(string $name, $value): MessageInterface
{
if ($value === []) {
return $this->withoutHeader($name);
Expand Down Expand Up @@ -131,7 +131,7 @@ public function withHeader($name, $value)
return $message;
}

public function withAddedHeader($name, $value)
public function withAddedHeader(string $name, $value): MessageInterface
{
if ($value === []) {
return $this;
Expand All @@ -140,7 +140,7 @@ public function withAddedHeader($name, $value)
return $this->withHeader($name, \array_merge($this->getHeader($name), \is_array($value) ? $value : [$value]));
}

public function withoutHeader($name)
public function withoutHeader(string $name): MessageInterface
{
$lower = \strtolower($name);
if (!isset($this->headerNamesLowerCase[$lower])) {
Expand All @@ -153,12 +153,12 @@ public function withoutHeader($name)
return $message;
}

public function getBody()
public function getBody(): StreamInterface
{
return $this->body;
}

public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): MessageInterface
{
if ($body === $this->body) {
return $this;
Expand Down
14 changes: 7 additions & 7 deletions src/Io/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function __construct(
$this->uri = $uri;
}

public function getRequestTarget()
public function getRequestTarget(): string
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
Expand All @@ -88,9 +88,9 @@ public function getRequestTarget()
return $target;
}

public function withRequestTarget($requestTarget)
public function withRequestTarget(string $requestTarget): RequestInterface
{
if ((string) $requestTarget === $this->requestTarget) {
if ($requestTarget === $this->requestTarget) {
return $this;
}

Expand All @@ -100,12 +100,12 @@ public function withRequestTarget($requestTarget)
return $request;
}

public function getMethod()
public function getMethod(): string
{
return $this->method;
}

public function withMethod($method)
public function withMethod(string $method): RequestInterface
{
if ((string) $method === $this->method) {
return $this;
Expand All @@ -117,12 +117,12 @@ public function withMethod($method)
return $request;
}

public function getUri()
public function getUri(): UriInterface
{
return $this->uri;
}

public function withUri(UriInterface $uri, $preserveHost = false)
public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface
{
if ($uri === $this->uri) {
return $this;
Expand Down
26 changes: 13 additions & 13 deletions src/Io/BufferedBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($buffer)
$this->buffer = $buffer;
}

public function __toString()
public function __toString(): string
{
if ($this->closed) {
return '';
Expand All @@ -34,7 +34,7 @@ public function __toString()
return $this->getContents();
}

public function close()
public function close(): void
{
$this->buffer = '';
$this->position = 0;
Expand All @@ -48,12 +48,12 @@ public function detach()
return null;
}

public function getSize()
public function getSize(): ?int
{
return $this->closed ? null : \strlen($this->buffer);
}

public function tell()
public function tell(): int
{
if ($this->closed) {
throw new \RuntimeException('Unable to tell position of closed stream');
Expand All @@ -62,17 +62,17 @@ public function tell()
return $this->position;
}

public function eof()
public function eof(): bool
{
return $this->position >= \strlen($this->buffer);
}

public function isSeekable()
public function isSeekable(): bool
{
return !$this->closed;
}

public function seek($offset, $whence = \SEEK_SET)
public function seek($offset, $whence = \SEEK_SET): void
{
if ($this->closed) {
throw new \RuntimeException('Unable to seek on closed stream');
Expand All @@ -96,17 +96,17 @@ public function seek($offset, $whence = \SEEK_SET)
}
}

public function rewind()
public function rewind(): void
{
$this->seek(0);
}

public function isWritable()
public function isWritable(): bool
{
return !$this->closed;
}

public function write($string)
public function write(string $string): int
{
if ($this->closed) {
throw new \RuntimeException('Unable to write to closed stream');
Expand All @@ -127,12 +127,12 @@ public function write($string)
return $len;
}

public function isReadable()
public function isReadable(): bool
{
return !$this->closed;
}

public function read($length)
public function read(int $length): string
{
if ($this->closed) {
throw new \RuntimeException('Unable to read from closed stream');
Expand All @@ -156,7 +156,7 @@ public function read($length)
return \substr($this->buffer, $pos, $length);
}

public function getContents()
public function getContents(): string
{
if ($this->closed) {
throw new \RuntimeException('Unable to read from closed stream');
Expand Down
26 changes: 13 additions & 13 deletions src/Io/EmptyBodyStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EmptyBodyStream extends EventEmitter implements StreamInterface, ReadableS
{
private $closed = false;

public function isReadable()
public function isReadable(): bool
{
return !$this->closed;
}
Expand All @@ -51,7 +51,7 @@ public function pipe(WritableStreamInterface $dest, array $options = [])
return $dest;
}

public function close()
public function close(): void
{
if ($this->closed) {
return;
Expand All @@ -63,13 +63,13 @@ public function close()
$this->removeAllListeners();
}

public function getSize()
public function getSize(): ?int
{
return 0;
}

/** @ignore */
public function __toString()
public function __toString(): string
{
return '';
}
Expand All @@ -81,55 +81,55 @@ public function detach()
}

/** @ignore */
public function tell()
public function tell(): int
{
throw new \BadMethodCallException();
}

/** @ignore */
public function eof()
public function eof(): bool
{
throw new \BadMethodCallException();
}

/** @ignore */
public function isSeekable()
public function isSeekable(): bool
{
return false;
}

/** @ignore */
public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = SEEK_SET): void
{
throw new \BadMethodCallException();
}

/** @ignore */
public function rewind()
public function rewind(): void
{
throw new \BadMethodCallException();
}

/** @ignore */
public function isWritable()
public function isWritable(): bool
{
return false;
}

/** @ignore */
public function write($string)
public function write($string): int
{
throw new \BadMethodCallException();
}

/** @ignore */
public function read($length)
public function read($length): string
{
throw new \BadMethodCallException();
}

/** @ignore */
public function getContents()
public function getContents(): string
{
return '';
}
Expand Down
Loading