Skip to content

Commit

Permalink
php 7.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Zogg committed Apr 28, 2019
1 parent 8363b95 commit e510fe5
Show file tree
Hide file tree
Showing 68 changed files with 262 additions and 255 deletions.
4 changes: 2 additions & 2 deletions src/ApiProblem/AbstractApiProblem.php
Expand Up @@ -79,15 +79,15 @@ public function getTitle(): string
/**
* @return string|null
*/
public function getDetail()
public function getDetail(): ?string
{
return $this->detail;
}

/**
* @return string|null
*/
public function getInstance()
public function getInstance(): ?string
{
return $this->instance;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ApiProblem/ApiProblemInterface.php
Expand Up @@ -24,12 +24,12 @@ public function getTitle(): string;
/**
* @return string|null
*/
public function getDetail();
public function getDetail(): ?string;

/**
* @return string|null
*/
public function getInstance();
public function getInstance(): ?string;

/**
* @return array
Expand Down
15 changes: 9 additions & 6 deletions src/Manager/RequestManager.php
Expand Up @@ -6,7 +6,7 @@

use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextInterface;
use Chubbyphp\Deserialization\DeserializerInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ServerRequestInterface;

final class RequestManager implements RequestManagerInterface
{
Expand All @@ -24,27 +24,30 @@ public function __construct(DeserializerInterface $deserializer)
}

/**
* @param Request $request
* @param ServerRequestInterface $request
* @param object|string $object
* @param DenormalizerContextInterface|null $context
*
* @return object
*/
public function getDataFromRequestQuery(Request $request, $object, DenormalizerContextInterface $context = null)
{
public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
DenormalizerContextInterface $context = null
) {
return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
}

/**
* @param Request $request
* @param ServerRequestInterface $request
* @param object|string $object
* @param string $contentType
* @param DenormalizerContextInterface|null $context
*
* @return object
*/
public function getDataFromRequestBody(
Request $request,
ServerRequestInterface $request,
$object,
string $contentType,
DenormalizerContextInterface $context = null
Expand Down
20 changes: 12 additions & 8 deletions src/Manager/RequestManagerInterface.php
Expand Up @@ -5,28 +5,32 @@
namespace Chubbyphp\ApiHttp\Manager;

use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ServerRequestInterface;

interface RequestManagerInterface
{
/**
* @param Request $request
* @param ServerRequestInterface $request
* @param object|string $object
* @param DenormalizerContextInterface|null $context
*
* @return object
*/
public function getDataFromRequestQuery(Request $request, $object, DenormalizerContextInterface $context = null);
public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
DenormalizerContextInterface $context = null
);

/**
* @param Request $request
* @param object|string $object
* @param string $contentType
* @param ServerRequestInterface $request
* @param object|string $object
* @param string $contentType
*
* @return object|null
* @return object
*/
public function getDataFromRequestBody(
Request $request,
ServerRequestInterface $request,
$object,
string $contentType,
DenormalizerContextInterface $context = null
Expand Down
22 changes: 11 additions & 11 deletions src/Manager/ResponseManager.php
Expand Up @@ -4,12 +4,12 @@

namespace Chubbyphp\ApiHttp\Manager;

use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
use Chubbyphp\Deserialization\DeserializerInterface;
use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
use Chubbyphp\Serialization\SerializerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
use Psr\Http\Message\ResponseInterface;

final class ResponseManager implements ResponseManagerInterface
{
Expand Down Expand Up @@ -49,14 +49,14 @@ public function __construct(
* @param int $status
* @param NormalizerContextInterface|null $context
*
* @return Response
* @return ResponseInterface
*/
public function create(
$object,
$object,
string $accept,
int $status = 200,
NormalizerContextInterface $context = null
): Response {
): ResponseInterface {
$body = $this->serializer->serialize($object, $accept, $context);

$response = $this->responseFactory->createResponse($status)->withHeader('Content-Type', $accept);
Expand All @@ -69,9 +69,9 @@ public function create(
* @param string $accept
* @param int $status
*
* @return Response
* @return ResponseInterface
*/
public function createEmpty(string $accept, int $status = 204): Response
public function createEmpty(string $accept, int $status = 204): ResponseInterface
{
return $this->responseFactory->createResponse($status)->withHeader('Content-Type', $accept);
}
Expand All @@ -80,9 +80,9 @@ public function createEmpty(string $accept, int $status = 204): Response
* @param string $location
* @param int $status
*
* @return Response
* @return ResponseInterface
*/
public function createRedirect(string $location, int $status = 307): Response
public function createRedirect(string $location, int $status = 307): ResponseInterface
{
return $this->responseFactory->createResponse($status)->withHeader('Location', $location);
}
Expand All @@ -92,13 +92,13 @@ public function createRedirect(string $location, int $status = 307): Response
* @param string $accept
* @param NormalizerContextInterface $context
*
* @return Response
* @return ResponseInterface
*/
public function createFromApiProblem(
ApiProblemInterface $apiProblem,
string $accept,
NormalizerContextInterface $context = null
): Response {
): ResponseInterface {
$status = $apiProblem->getStatus();

$response = $this->responseFactory->createResponse($status)->withHeader('Content-Type', $accept);
Expand Down
22 changes: 11 additions & 11 deletions src/Manager/ResponseManagerInterface.php
Expand Up @@ -4,9 +4,9 @@

namespace Chubbyphp\ApiHttp\Manager;

use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
use Psr\Http\Message\ResponseInterface;

interface ResponseManagerInterface
{
Expand All @@ -16,41 +16,41 @@ interface ResponseManagerInterface
* @param int $status
* @param NormalizerContextInterface|null $context
*
* @return Response
* @return ResponseInterface
*/
public function create(
$object,
object $object,
string $accept,
int $status = 200,
NormalizerContextInterface $context = null
): Response;
): ResponseInterface;

/**
* @param string $accept
* @param int $status
*
* @return Response
* @return ResponseInterface
*/
public function createEmpty(string $accept, int $status = 204): Response;
public function createEmpty(string $accept, int $status = 204): ResponseInterface;

/**
* @param string $location
* @param int $status
*
* @return Response
* @return ResponseInterface
*/
public function createRedirect(string $location, int $status = 307): Response;
public function createRedirect(string $location, int $status = 307): ResponseInterface;

/**
* @param ApiProblemInterface $apiProblem
* @param string $accept
* @param NormalizerContextInterface $context
*
* @return Response
* @return ResponseInterface
*/
public function createFromApiProblem(
ApiProblemInterface $apiProblem,
string $accept,
NormalizerContextInterface $context = null
): Response;
): ResponseInterface;
}
2 changes: 1 addition & 1 deletion src/Provider/ApiHttpProvider.php
Expand Up @@ -14,7 +14,7 @@ final class ApiHttpProvider implements ServiceProviderInterface
/**
* @param Container $container
*/
public function register(Container $container)
public function register(Container $container): void
{
$container['api-http.request.manager'] = function () use ($container) {
return new RequestManager($container['deserializer']);
Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ApiProblemTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class ConflictTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new class() extends AbstractApiProblem {
public function __construct(string $detail = null, string $instance = null)
Expand All @@ -27,7 +27,7 @@ public function __construct(string $detail = null, string $instance = null)
self::assertNull($apiProblem->getInstance());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new class('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0') extends AbstractApiProblem {
public function __construct(string $detail = null, string $instance = null)
Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/BadRequestTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class BadRequestTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new BadRequest([]);

Expand All @@ -23,7 +23,7 @@ public function testMinimal()
self::assertSame([], $apiProblem->getInvalidParameters());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new BadRequest([
[
Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/ConflictTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class ConflictTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new Conflict();

Expand All @@ -22,7 +22,7 @@ public function testMinimal()
self::assertNull($apiProblem->getInstance());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new Conflict('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0');

Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/ExpectationFailedTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class ExpectationFailedTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new ExpectationFailed([]);

Expand All @@ -23,7 +23,7 @@ public function testMinimal()
self::assertSame([], $apiProblem->getFailedExpectations());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new ExpectationFailed(['Expectation Failed'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0');

Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/FailedDependencyTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class FailedDependencyTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new FailedDependency();

Expand All @@ -22,7 +22,7 @@ public function testMinimal()
self::assertNull($apiProblem->getInstance());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new FailedDependency('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0');

Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/ForbiddenTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class ForbiddenTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new Forbidden();

Expand All @@ -22,7 +22,7 @@ public function testMinimal()
self::assertNull($apiProblem->getInstance());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new Forbidden('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0');

Expand Down
4 changes: 2 additions & 2 deletions tests/ApiProblem/ClientError/GoneTest.php
Expand Up @@ -10,7 +10,7 @@
*/
final class GoneTest extends TestCase
{
public function testMinimal()
public function testMinimal(): void
{
$apiProblem = new Gone();

Expand All @@ -22,7 +22,7 @@ public function testMinimal()
self::assertNull($apiProblem->getInstance());
}

public function testMaximal()
public function testMaximal(): void
{
$apiProblem = new Gone('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0');

Expand Down

0 comments on commit e510fe5

Please sign in to comment.