Skip to content

Commit

Permalink
PHPStan level max
Browse files Browse the repository at this point in the history
  • Loading branch information
othillo committed May 11, 2020
1 parent eeaeea9 commit d8e4a9e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
composer.lock
.php_cs.cache
.phpunit.result.cache
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test:
vendor/bin/phpunit --testdox --colors=always --group=functional

.PHONY: qa
qa: php-cs-fixer-ci
qa: php-cs-fixer-ci phpstan

.PHONY: php-cs-fixer
php-cs-fixer:
Expand All @@ -20,6 +20,10 @@ php-cs-fixer:
php-cs-fixer-ci:
vendor/bin/php-cs-fixer fix --dry-run --no-interaction --allow-risky=yes --diff --verbose

PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse --level=max src/

.PHONY: changelog
changelog:
git log $$(git describe --abbrev=0 --tags)...HEAD --no-merges --pretty=format:"* [%h](http://github.com/${TRAVIS_REPO_SLUG}/commit/%H) %s (%cN)"
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
],
"require-dev": {
"phpunit/phpunit": "^8.0",
"broadway/coding-standard": "^1.0"
"broadway/coding-standard": "^1.0",
"phpstan/phpstan": "@stable"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
checkMissingIterableValueType: false
21 changes: 14 additions & 7 deletions src/ElasticSearchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@
*/
class ElasticSearchRepository implements Repository
{
/** @var Client */
private $client;

/** @var Serializer */
private $serializer;

/** @var string */
private $index;

/** @var string */
private $class;

/** @var string[] */
private $notAnalyzedFields;

public function __construct(
Expand Down Expand Up @@ -121,7 +130,7 @@ public function remove($id): void
}
}

private function searchAndDeserializeHits(array $query)
private function searchAndDeserializeHits(array $query): array
{
try {
$result = $this->client->search($query);
Expand Down Expand Up @@ -153,7 +162,7 @@ protected function search(array $query, array $facets = [], int $size = 500): ar
}
}

protected function query(array $query)
protected function query(array $query): array
{
return $this->searchAndDeserializeHits(
[
Expand Down Expand Up @@ -183,7 +192,7 @@ private function buildFindAllQuery(): array
];
}

private function deserializeHit(array $hit)
private function deserializeHit(array $hit): Identifiable
{
return $this->serializer->deserialize(
[
Expand All @@ -193,12 +202,12 @@ private function deserializeHit(array $hit)
);
}

private function deserializeHits(array $hits)
private function deserializeHits(array $hits): array
{
return array_map([$this, 'deserializeHit'], $hits);
}

private function buildFilter(array $filter)
private function buildFilter(array $filter): array
{
$retval = [];

Expand Down Expand Up @@ -247,8 +256,6 @@ public function createIndex(): bool

/**
* Deletes the index for this repository's ReadModel.
*
* @return True, if the index was successfully deleted
*/
public function deleteIndex(): bool
{
Expand Down
3 changes: 3 additions & 0 deletions src/ElasticSearchRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
*/
class ElasticSearchRepositoryFactory implements RepositoryFactory
{
/** @var Client */
private $client;

/** @var Serializer */
private $serializer;

public function __construct(Client $client, Serializer $serializer)
Expand Down

0 comments on commit d8e4a9e

Please sign in to comment.