Skip to content

Commit

Permalink
Refactor: PHP8 and grizz-it/services support
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankruijter committed Apr 3, 2021
1 parent f9955ee commit 2ee6d94
Show file tree
Hide file tree
Showing 27 changed files with 119 additions and 86 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: php
php:
- '7.3'
- '7.4'
- '8.0'

before_script:
- yes '' | pecl install yaml
- composer install

script:
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.1.0 - 2021-04-03

### Added
- Support for PHP8

### Changed
- Support from `ulrack/services` to `grizz-it/services`.

## 3.0.1 - 2021-01-17

### Fixed
Expand Down Expand Up @@ -43,7 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The initial implementation of the package.

# Versions
- [3.0.1 > Unreleased](https://github.com/ulrack/web/compare/3.0.1...HEAD)
- [3.1.0 > Unreleased](https://github.com/ulrack/web/compare/3.1.0...HEAD)
- [3.0.1 > 3.1.0](https://github.com/ulrack/web/compare/3.0.1...3.1.0)
- [3.0.0 > 3.0.1](https://github.com/ulrack/web/compare/3.0.0...3.0.1)
- [2.0.0 > 3.0.0](https://github.com/ulrack/web/compare/2.0.0...3.0.0)
- [1.0.1 > 2.0.0](https://github.com/ulrack/web/compare/1.0.1...2.0.0)
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"prefer-stable": true,
"minimum-stability": "stable",
"require": {
"php": "^7.3",
"grizz-it/codec": "^1.0",
"grizz-it/configuration": "^1.1",
"grizz-it/enum": "^1.0",
"grizz-it/http": "^1.0",
"grizz-it/translator": "^1.1",
"ulrack/services": "^3.0"
"php": "^8.0",
"grizz-it/codec": "^1.1",
"grizz-it/configuration": "^1.3",
"grizz-it/enum": "^1.1",
"grizz-it/http": "^1.1",
"grizz-it/services": "^1.0",
"grizz-it/translator": "^1.2"
},
"authors": [
{
Expand Down Expand Up @@ -55,7 +55,7 @@
]
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5"
}
}
12 changes: 7 additions & 5 deletions docs/usage/error.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ services. These are
A definition for an error looks like the following:
```json
{
"web.errors.default.api.400": {
"class": "\\Ulrack\\Web\\Component\\Error\\ConfigurableApiError",
"parameters": {
"errorStatusCode": 400,
"errorMessage": "Bad Request"
"services": {
"web.errors.default.api.400": {
"class": "\\Ulrack\\Web\\Component\\Error\\ConfigurableApiError",
"parameters": {
"errorStatusCode": 400,
"errorMessage": "Bad Request"
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Endpoint/InputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function hasParameter(string $key): bool;
*
* @return mixed
*/
public function getParameter(string $key);
public function getParameter(string $key): mixed;

/**
* Retrieves all parameters.
Expand All @@ -51,7 +51,7 @@ public function getParameters(): array;
*
* @return void
*/
public function setParameter(string $key, $value): void;
public function setParameter(string $key, mixed $value): void;

/**
* Retrieves a list of keys of available parameters.
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Endpoint/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface OutputInterface
*
* @return mixed
*/
public function getOutput();
public function getOutput(): mixed;

/**
* Sets the value of the output.
Expand All @@ -23,7 +23,7 @@ public function getOutput();
*
* @return void
*/
public function setOutput($output): void;
public function setOutput(mixed $output): void;

/**
* Sets the serving protocol.
Expand Down
8 changes: 4 additions & 4 deletions src/Component/Endpoint/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class Input implements InputInterface
*
* @var RequestInterface
*/
private $request;
private RequestInterface $request;

/**
* Contains the parameters for the input.
*
* @var array
*/
private $parameters = [];
private array $parameters = [];

/**
* Constructor.
Expand Down Expand Up @@ -65,7 +65,7 @@ public function hasParameter(string $key): bool
*
* @return mixed
*/
public function getParameter(string $key)
public function getParameter(string $key): mixed
{
return $this->parameters[$key];
}
Expand All @@ -88,7 +88,7 @@ public function getParameters(): array
*
* @return void
*/
public function setParameter(string $key, $value): void
public function setParameter(string $key, mixed $value): void
{
$this->parameters[$key] = $value;
}
Expand Down
22 changes: 11 additions & 11 deletions src/Component/Endpoint/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,49 @@ class Output implements OutputInterface
*
* @var string
*/
private $protocol;
private string $protocol;

/**
* Contains the status code for the response.
*
* @var int
*/
private $statusCode = 200;
private int $statusCode = 200;

/**
* Contains the headers for the response.
*
* @var string[]
*/
private $headers = [];
private array $headers = [];

/**
* Contains the parameters.
*
* @var array
*/
private $parameters = [];
private array $parameters = [];

/**
* Contains the chosen content type.
*
* @var string
*/
private $contentType = '';
private string $contentType = '';

/**
* Contains the output of the response.
*
* @var mixed
*/
private $output;
private mixed $output;

/**
* Contains the accepted content types.
*
* @var string[]
*/
private $acceptedContentTypes;
private array $acceptedContentTypes;

/**
* Constructor.
Expand All @@ -78,7 +78,7 @@ public function __construct(string ...$acceptedContentTypes)
*
* @return mixed
*/
public function getOutput()
public function getOutput(): mixed
{
return $this->output;
}
Expand All @@ -90,7 +90,7 @@ public function getOutput()
*
* @return void
*/
public function setOutput($output): void
public function setOutput(mixed $output): void
{
$this->output = $output;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ public function hasParameter(string $key): bool
*
* @return mixed
*/
public function getParameter(string $key)
public function getParameter(string $key): mixed
{
return $this->parameters[$key];
}
Expand All @@ -250,7 +250,7 @@ public function getParameter(string $key)
*
* @return void
*/
public function setParameter(string $key, $value): void
public function setParameter(string $key, mixed $value): void
{
$this->parameters[$key] = $value;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Component/Error/ConfigurableApiError.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ class ConfigurableApiError implements ErrorInterface
*
* @var int
*/
private $errorStatusCode;
private int $errorStatusCode;

/**
* Contains the error code.
*
* @var int
* @var int|null
*/
private $errorCode;
private ?int $errorCode;

/**
* Contains the error message.
*
* @var string
* @var string|null
*/
private $errorMessage;
private ?string $errorMessage;

/**
* Contains the default content type.
*
* @var string
*/
private $defaultContentType;
private string $defaultContentType;

/**
* Constructor.
*
* @param int $errorStatusCode
* @param int $errorCode
* @param string $errorMessage
* @param int|null $errorCode
* @param string|null $errorMessage
* @param string $defaultContentType
*/
public function __construct(
Expand Down
15 changes: 7 additions & 8 deletions src/Component/Error/ConfigurablePlainError.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,28 @@ class ConfigurablePlainError implements ErrorInterface
*
* @var int
*/
private $errorStatusCode;
private int $errorStatusCode;

/**
* Contains the error code.
*
* @var int
* @var int|null
*/
private $errorCode;
private ?int $errorCode;

/**
* Contains the error message.
*
* @var string
* @var string|null
*/
private $errorMessage;
private ?string $errorMessage;

/**
* Constructor.
*
* @param int $errorStatusCode
* @param int $errorCode
* @param string $errorMessage
* @param string $defaultContentType
* @param int|null $errorCode
* @param string|null $errorMessage
*/
public function __construct(
int $errorStatusCode,
Expand Down
8 changes: 4 additions & 4 deletions src/Component/Error/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ class ErrorHandler implements ErrorHandlerInterface
*
* @var InputInterface
*/
private $input;
private InputInterface $input;

/**
* Contains a reference to the output.
*
* @var OutputInterface
*/
private $output;
private OutputInterface $output;

/**
* Contains the output handler.
*
* @var OutputHandlerInterface
*/
private $outputHandler;
private OutputHandlerInterface $outputHandler;

/**
* Contains the error registry.
*
* @var ErrorRegistryInterface
*/
private $errorRegistry;
private ErrorRegistryInterface $errorRegistry;

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Error/ErrorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ErrorRegistry implements ErrorRegistryInterface
*
* @var ErrorInterface[]
*/
private $errors;
private array $errors;

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Middleware/HostMatchingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HostMatchingMiddleware implements MiddlewareInterface
*
* @var string[]
*/
private $hosts;
private array $hosts;

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Middleware/MethodMatchingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MethodMatchingMiddleware implements MiddlewareInterface
*
* @var string[]
*/
private $methods;
private array $methods;

/**
* Constructor.
Expand Down
Loading

0 comments on commit 2ee6d94

Please sign in to comment.