Skip to content

Fix CS #323

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

Merged
merged 1 commit into from
Feb 14, 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
30 changes: 15 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- staging
- main

env:
fail-fast: true

jobs:
integration-tests:
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
Expand All @@ -24,27 +27,24 @@ jobs:
MEILI_MASTER_KEY: masterKey
MEILI_NO_ANALYTICS: true
strategy:
# only TEMP
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
include:
php-version: ['7.4', '8.1', '8.2', '8.3']
sf-version: ['5.4.*', '6.4.*', '7.0.*']
exclude:
- php-version: '7.4'
sf-version: '5.4.*'
- php-version: '8.0'
sf-version: '6.0.*'
sf-version: '6.4.*'
- php-version: '7.4'
sf-version: '7.0.*'
- php-version: '8.1'
sf-version: '6.0.*'
sf-version: '5.4.*'
- php-version: '8.1'
sf-version: '6.1.*'
sf-version: '7.0.*'
- php-version: '8.2'
sf-version: '6.2.*'
- php-version: '8.3'
sf-version: '6.3.*'
sf-version: '5.4.*'
- php-version: '8.3'
sf-version: '6.4.*'
sf-version: '5.4.*'
- php-version: '8.3'
sf-version: '7.0.*'
sf-version: '5.4.*'

name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }})
steps:
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: 8.3

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down
7 changes: 3 additions & 4 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
status = [
'integration-tests (PHP 7.4) (Symfony 5.4.*)',
'integration-tests (PHP 8.0) (Symfony 6.0.*)',
'integration-tests (PHP 8.1) (Symfony 6.1.*)',
'integration-tests (PHP 8.2) (Symfony 6.2.*)',
'integration-tests (PHP 8.3) (Symfony 6.3.*)',
'integration-tests (PHP 8.1) (Symfony 6.4.*)',
'integration-tests (PHP 8.2) (Symfony 6.4.*)',
'integration-tests (PHP 8.3) (Symfony 6.4.*)',
'integration-tests (PHP 8.2) (Symfony 7.0.*)',
'integration-tests (PHP 8.3) (Symfony 7.0.*)',
'Code style'
]
Expand Down
6 changes: 3 additions & 3 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function map(callable $callback)
*
* @return static
*/
public function filter(callable $callback = null)
public function filter(?callable $callback = null)
{
if (null !== $callback) {
return new self(array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH));
Expand Down Expand Up @@ -143,7 +143,7 @@ public function unique($key = null, bool $strict = false)
/**
* Get the first item from the collection passing the given truth test.
*/
public function first(callable $callback = null, $default = null)
public function first(?callable $callback = null, $default = null)
{
if (is_null($callback)) {
if (empty($this->items)) {
Expand Down Expand Up @@ -339,7 +339,7 @@ private static function existsInArray($array, $key): bool
return array_key_exists($key, $array);
}

private function operatorForWhere(string $key, string $operator = null, $value = null): \Closure
private function operatorForWhere(string $key, ?string $operator = null, $value = null): \Closure
{
if (1 === func_num_args()) {
$value = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Aggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function getEntityClassFromObjectID(string $objectId): string
throw new EntityNotFoundInObjectID("Entity class from ObjectID $objectId not found.");
}

public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array
public function normalize(NormalizerInterface $normalizer, ?string $format = null, array $context = []): array
{
return array_merge(['objectID' => $this->objectID], $normalizer->normalize($this->entity, $format, $context));
}
Expand Down
2 changes: 1 addition & 1 deletion src/SearchableEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
string $indexUid,
$entity,
ClassMetadata $entityMetadata,
NormalizerInterface $normalizer = null,
?NormalizerInterface $normalizer = null,
array $extra = []
) {
$this->indexUid = $indexUid;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/MeilisearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class MeilisearchService implements SearchService
private array $classToSerializerGroup;
private array $indexIfMapping;

public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration, PropertyAccessorInterface $propertyAccessor = null)
public function __construct(NormalizerInterface $normalizer, Engine $engine, array $configuration, ?PropertyAccessorInterface $propertyAccessor = null)
{
$this->normalizer = $normalizer;
$this->engine = $engine;
Expand Down
4 changes: 2 additions & 2 deletions src/Services/UnixTimestampNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ final class UnixTimestampNormalizer implements NormalizerInterface
/**
* @param \DateTimeInterface $object
*/
public function normalize($object, string $format = null, array $context = []): int
public function normalize($object, ?string $format = null, array $context = []): int
{
return $object->getTimestamp();
}

/**
* @param mixed $data
*/
public function supportsNormalization($data, string $format = null, array $context = []): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof \DateTimeInterface && true === ($context['meilisearch'] ?? null);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/BaseKernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function setUp(): void
$this->cleanUp();
}

protected function createPost(int $id = null): Post
protected function createPost(?int $id = null): Post
{
$post = new Post();
$post->setTitle('Test Post');
Expand Down Expand Up @@ -83,7 +83,7 @@ protected function createSearchablePost(): SearchableEntity
);
}

protected function createComment(int $id = null): Comment
protected function createComment(?int $id = null): Comment
{
$post = new Post(['title' => 'What a post!']);
$comment = new Comment();
Expand All @@ -101,7 +101,7 @@ protected function createComment(int $id = null): Comment
return $comment;
}

protected function createImage(int $id = null): Image
protected function createImage(?int $id = null): Image
{
$image = new Image();
$image->setUrl('https://docs.meilisearch.com/logo.png');
Expand Down
8 changes: 8 additions & 0 deletions tests/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,13 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
],
]);
}

// @phpstan-ignore-next-line
if (Kernel::VERSION_ID >= 60400) {
$container->prependExtensionConfig('framework', [
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
]);
}
}
}