Skip to content

Add return types to fixtures #99

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

Merged
merged 1 commit into from
Oct 6, 2021
Merged
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: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
deprecations: max[self]=0
- php: '8.0'
deps: highest
deprecations: max[indirect]=5

steps:
- name: Checkout code
Expand Down
39 changes: 32 additions & 7 deletions Tests/Fixtures/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,63 +29,88 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
{
$this->version = $version;
$this->headers = $headers;
$this->body = null === $body ? new Stream() : $body;
$this->body = $body ?? new Stream();
}

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

/**
* {@inheritdoc}
*
* @return static
*/
public function withProtocolVersion($version)
{
throw new \BadMethodCallException('Not implemented.');
}

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

public function hasHeader($name)
public function hasHeader($name): bool
{
return isset($this->headers[$name]);
}

public function getHeader($name)
public function getHeader($name): array
{
return $this->hasHeader($name) ? $this->headers[$name] : [];
}

public function getHeaderLine($name)
public function getHeaderLine($name): string
{
return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withHeader($name, $value)
{
$this->headers[$name] = (array) $value;

return $this;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withAddedHeader($name, $value)
{
throw new \BadMethodCallException('Not implemented.');
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withoutHeader($name)
{
unset($this->headers[$name]);

return $this;
}

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

/**
* {@inheritdoc}
*
* @return static
*/
public function withBody(StreamInterface $body)
{
throw new \BadMethodCallException('Not implemented.');
Expand Down
7 changes: 5 additions & 2 deletions Tests/Fixtures/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
$this->statusCode = $statusCode;
}

public function getStatusCode()
public function getStatusCode(): int
{
return $this->statusCode;
}

/**
* @return static
*/
public function withStatus($code, $reasonPhrase = '')
{
throw new \BadMethodCallException('Not implemented.');
}

public function getReasonPhrase()
public function getReasonPhrase(): string
{
throw new \BadMethodCallException('Not implemented.');
}
Expand Down
77 changes: 69 additions & 8 deletions Tests/Fixtures/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,95 +45,156 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
$this->attributes = $attributes;
}

public function getRequestTarget()
public function getRequestTarget(): string
{
return $this->requestTarget;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withRequestTarget($requestTarget)
{
throw new \BadMethodCallException('Not implemented.');
}

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

/**
* {@inheritdoc}
*
* @return static
*/
public function withMethod($method)
{
throw new \BadMethodCallException('Not implemented.');
}

/**
* {@inheritdoc}
*
* @return UriInterface
*/
public function getUri()
{
return $this->uri;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withUri(UriInterface $uri, $preserveHost = false)
{
throw new \BadMethodCallException('Not implemented.');
}

public function getServerParams()
public function getServerParams(): array
{
return $this->server;
}

public function getCookieParams()
public function getCookieParams(): array
{
return $this->cookies;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withCookieParams(array $cookies)
{
throw new \BadMethodCallException('Not implemented.');
}

public function getQueryParams()
public function getQueryParams(): array
{
return $this->query;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withQueryParams(array $query)
{
throw new \BadMethodCallException('Not implemented.');
}

public function getUploadedFiles()
public function getUploadedFiles(): array
{
return $this->uploadedFiles;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withUploadedFiles(array $uploadedFiles)
{
throw new \BadMethodCallException('Not implemented.');
}

/**
* {@inheritdoc}
*
* @return array|object|null
*/
public function getParsedBody()
{
return $this->data;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withParsedBody($data)
{
throw new \BadMethodCallException('Not implemented.');
}

public function getAttributes()
public function getAttributes(): array
{
return $this->attributes;
}

/**
* {@inheritdoc}
*
* @return mixed
*/
public function getAttribute($name, $default = null)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
return $this->attributes[$name] ?? $default;
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withAttribute($name, $value)
{
throw new \BadMethodCallException('Not implemented.');
}

/**
* {@inheritdoc}
*
* @return static
*/
public function withoutAttribute($name)
{
throw new \BadMethodCallException('Not implemented.');
Expand Down
34 changes: 21 additions & 13 deletions Tests/Fixtures/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public function __construct($stringContent = '')
$this->stringContent = $stringContent;
}

public function __toString()
public function __toString(): string
{
return $this->stringContent;
}

public function close()
public function close(): void
{
}

Expand All @@ -40,61 +40,69 @@ public function detach()
return fopen('data://text/plain,'.$this->stringContent, 'r');
}

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

public function tell()
public function tell(): int
{
return 0;
}

public function eof()
public function eof(): bool
{
return $this->eof;
}

public function isSeekable()
public function isSeekable(): bool
{
return true;
}

public function seek($offset, $whence = \SEEK_SET)
public function seek($offset, $whence = \SEEK_SET): void
{
}

public function rewind()
public function rewind(): void
{
$this->eof = false;
}

public function isWritable()
public function isWritable(): bool
{
return false;
}

public function write($string)
public function write($string): int
{
return \strlen($string);
}

public function isReadable()
public function isReadable(): bool
{
return true;
}

public function read($length)
public function read($length): string
{
$this->eof = true;

return $this->stringContent;
}

public function getContents()
public function getContents(): string
{
return $this->stringContent;
}

/**
* {@inheritdoc}
*
* @return mixed
*/
public function getMetadata($key = null)
{
return null;
}
}
Loading