Skip to content
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

III-3558 Increase PHPStan to level 5 #304

Merged
merged 4 commits into from
Aug 19, 2024
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
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 4
level: 5
paths:
- app
- src
Expand Down
16 changes: 1 addition & 15 deletions src/ElasticSearch/Aggregation/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,14 @@

namespace CultuurNet\UDB3\Search\ElasticSearch\Aggregation;

use InvalidArgumentException;

final class Bucket
{
private string $key;

private int $count;

/**
* @param string $key
* @param int $count
*/
public function __construct($key, $count)
public function __construct(string $key, int $count)
{
if (!is_string($key)) {
throw new InvalidArgumentException('Bucket key should be a string.');
}

if (!is_int($count)) {
throw new InvalidArgumentException('Bucket count should be an int.');
}

$this->key = $key;
$this->count = $count;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace CultuurNet\UDB3\Search\Http\Organizer\RequestParser;

use CultuurNet\UDB3\Search\Http\ApiRequestInterface;
use CultuurNet\UDB3\Search\Organizer\OrganizerQueryBuilderInterface;
use Psr\Http\Message\ServerRequestInterface;

final class CompositeOrganizerRequestParser implements OrganizerRequestParser
{
Expand All @@ -27,7 +27,7 @@ public function withParser(OrganizerRequestParser $parser): self
}

public function parse(
ServerRequestInterface $request,
ApiRequestInterface $request,
OrganizerQueryBuilderInterface $organizerQueryBuilder
): OrganizerQueryBuilderInterface {
foreach ($this->parsers as $parser) {
Expand Down
8 changes: 4 additions & 4 deletions src/PagedResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace CultuurNet\UDB3\Search;

use CultuurNet\UDB3\Search\Facet\FacetTreeInterface;
use InvalidArgumentException;
use CultuurNet\UDB3\Search\Facet\FacetFilter;
use CultuurNet\UDB3\Search\ReadModel\JsonDocument;

final class PagedResultSet
Expand All @@ -20,7 +20,7 @@ final class PagedResultSet
private array $results;

/**
* @var FacetFilter[]
* @var FacetTreeInterface[]
*/
private $facets;

Expand Down Expand Up @@ -55,15 +55,15 @@ public function getResults(): array
return $this->results;
}

public function withFacets(FacetFilter ...$facetFilters): PagedResultSet
public function withFacets(FacetTreeInterface ...$facetFilters): PagedResultSet
{
$c = clone $this;
$c->facets = $facetFilters;
return $c;
}

/**
* @return FacetFilter[]
* @return FacetTreeInterface[]
*/
public function getFacets(): array
{
Expand Down
21 changes: 0 additions & 21 deletions tests/ElasticSearch/Aggregation/BucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace CultuurNet\UDB3\Search\ElasticSearch\Aggregation;

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

final class BucketTest extends TestCase
Expand All @@ -18,24 +17,4 @@ public function it_has_a_key_and_count(): void
$this->assertEquals('key', $bucket->getKey());
$this->assertEquals(10, $bucket->getCount());
}

/**
* @test
*/
public function it_checks_that_the_key_is_a_string(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Bucket key should be a string.');
new Bucket(true, 10);
}

/**
* @test
*/
public function it_checks_that_the_count_is_an_int(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Bucket count should be an int.');
new Bucket('key', '10,000,0000');
}
}
Loading