Skip to content

Commit

Permalink
Merge pull request #1 from Lansoweb/php8
Browse files Browse the repository at this point in the history
Php8
  • Loading branch information
Lansoweb authored May 7, 2021
2 parents 171d64d + 4eb2929 commit 5f6f258
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 64 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 3.4.1 - 2020-03-06

### Added

- Remove unecessary laminas dependency

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 3.4.0 - 2020-01-08

### Added
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
"name": "los/api-server",
"description": "PHP api server middleware",
"require": {
"php": "^7.2",
"psr/container": "^1.0",
"php": "^7.4 | ^8.0",
"ext-json": "*",
"psr/container": "^1.0 | ^2.0",
"psr/http-message": "^1.0",
"laminas/laminas-inputfilter": "^2.7",
"laminas/laminas-paginator": "^2.7",
"laminas/laminas-eventmanager": "^3.0",
"psr/http-server-middleware": "^1.0",
"mezzio/mezzio-hal": "^1.0",
"mezzio/mezzio-helpers": "^5.0",
"mezzio/mezzio-hal": "^2.0",
"mezzio/mezzio-helpers": "^5.6",
"mezzio/mezzio-problem-details": "^1.0",
"laminas/laminas-diactoros": "^1.7 || ^2.2",
"los/uql": "^0.5",
"laminas/laminas-dependency-plugin": "^0.2"
"los/uql": "^1.1",
"doctrine/coding-standard": "^9.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.7",
"squizlabs/php_codesniffer": "^3.6",
"phpstan/phpstan": "^0.12",
"laminas/laminas-coding-standard": "^1.0",
"laminas/laminas-db": "^2.10",
"laminas/laminas-hydrator": "^3.0"
"laminas/laminas-hydrator": "^4.0"
},
"license": "MIT",
"autoload-dev": {
Expand Down
3 changes: 3 additions & 0 deletions src/Auth/AuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Interop\Container\ContainerInterface;
use Mezzio\ProblemDetails\ProblemDetailsResponseFactory;

/**
* @deprecated Use los/api-auth
*/
class AuthFactory
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Auth/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Psr\Http\Server\RequestHandlerInterface;
use Mezzio\ProblemDetails\ProblemDetailsResponseFactory;

/**
* @deprecated Use los/api-auth
*/
class AuthMiddleware implements MiddlewareInterface
{
/** @var array */
Expand Down
10 changes: 2 additions & 8 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@

class ConfigProvider
{
/**
* @return array
*/
public function __invoke()
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
];
}

/**
* @return array
*/
public function getDependencies()
public function getDependencies(): array
{
return [
'factories' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Entity implements EntityInterface

const IDENTIFIER_NAME = 'id';

protected $fields = [];
protected array $fields = [];

/**
* Exchange internal values from provided array.
Expand Down
40 changes: 10 additions & 30 deletions src/Handler/AbstractRestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@ abstract class AbstractRestHandler implements RequestHandlerInterface
{
const IDENTIFIER_NAME = 'id';

/** @var Entity */
protected $entityPrototype;
/** @var Request */
protected $request;
/** @var UrlHelper */
protected $urlHelper;
/** @var int */
protected $itemCountPerPage = 25;
/** @var ProblemDetailsResponseFactory */
protected $problemDetailsResponseFactory;
/** @var ResourceGenerator */
private $resourceGenerator;
/** @var HalResponseFactory */
private $responseFactory;
protected Entity $entityPrototype;
protected Request $request;
protected UrlHelper $urlHelper;
protected int $itemCountPerPage = 25;
protected ProblemDetailsResponseFactory $problemDetailsResponseFactory;
private ResourceGenerator $resourceGenerator;
private HalResponseFactory $responseFactory;

/**
* AbstractRestAction constructor.
Expand Down Expand Up @@ -160,13 +153,8 @@ protected function validateBody() : array

/**
* Generates a proper response based on the Entity ot Collection
*
* @param EntityInterface|Collection $entity
* @param int $code
* @throws \InvalidArgumentException
* @return Response
*/
protected function generateResponse($entity, $code = 200) : Response
protected function generateResponse($entity, int $code = 200) : Response
{
if ($entity instanceof Entity) {
$resource = $this->resourceGenerator->fromObject($entity, $this->request);
Expand Down Expand Up @@ -351,10 +339,6 @@ public function update($id, array $data, array $where = []): EntityInterface
throw MethodNotAllowedException::create();
}

/**
* @param array $data
* @return Collection
*/
public function updateList(array $data) : Collection
{
throw MethodNotAllowedException::create();
Expand All @@ -374,12 +358,12 @@ public function deleteList()
throw MethodNotAllowedException::create();
}

public function head()
public function head(): Response
{
throw MethodNotAllowedException::create();
}

public function options()
public function options(): Response
{
throw MethodNotAllowedException::create();
}
Expand All @@ -395,10 +379,6 @@ public function patch($id, array $data, array $where = []): EntityInterface
throw MethodNotAllowedException::create();
}

/**
* @param array $data
* @return Collection
*/
public function patchList(array $data) : Collection
{
throw MethodNotAllowedException::create();
Expand Down
8 changes: 2 additions & 6 deletions src/Handler/MapperRestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ abstract class MapperRestHandler extends AbstractRestHandler
{
const SORT_BY = self::IDENTIFIER_NAME;

/** @var MapperInterface */
protected $mapper;

/** @var int */
protected $limitItemsPerPage = 25;
protected MapperInterface $mapper;
protected int $limitItemsPerPage = 25;

public function __construct(
MapperInterface $mapper,
Expand Down Expand Up @@ -96,7 +93,6 @@ public function fetchAll(array $where = [], array $options = []): Collection
$where = array_merge($where, $query);
$hint = array_merge($options, $hint);

/** @var Collection $collection */
$collection = $this->mapper->findBy($where, $hint);

$page = (int) ($queryParams['page'] ?? $hint['page'] ?? 1);
Expand Down
12 changes: 4 additions & 8 deletions src/Mapper/ZendDbMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@

class ZendDbMapper implements MapperInterface
{
/** @var TableGateway */
protected $table;
/** @var string */
private $collectionClass;
/** @var int */
protected $limitItemsPerPage = 25;
/** @var int */
protected $itemCountPerPage = 25;
protected TableGateway $table;
private string $collectionClass;
protected int $limitItemsPerPage = 25;
protected int $itemCountPerPage = 25;

const IDENTIFIER_NAME = 'id';
const SORT_BY = 'name';
Expand Down
4 changes: 2 additions & 2 deletions src/Paginator/MapperAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class MapperAdapter implements AdapterInterface
{
private $mapper;
private $where;
private MapperInterface $mapper;
private array $where;
private $order;
private $group;

Expand Down

0 comments on commit 5f6f258

Please sign in to comment.