Skip to content

Commit

Permalink
Merge pull request #9 from smoench/phpunit10
Browse files Browse the repository at this point in the history
Phpunit10
  • Loading branch information
smoench authored Oct 13, 2023
2 parents e501821 + d67a3c5 commit b9187e5
Show file tree
Hide file tree
Showing 240 changed files with 627 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '8.0', '8.1', '8.2' ]
php-version: [ '8.1', '8.2' ]

steps:
- name: Checkout project
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
}
],
"require": {
"php": "8.0.* || 8.1.* || 8.2.*",
"php": "8.1.* || 8.2.*",
"opensearch-project/opensearch-php": "^1.0 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpstan/phpstan": "1.10.21",
"phpstan/phpstan-phpunit": "1.3.13",
"rector/rector": "^0.14.5",
"symplify/easy-coding-standard": "^11.5.0"
"phpunit/phpunit": "^10.4.1",
"phpstan/phpstan": "1.10.38",
"phpstan/phpstan-phpunit": "1.3.15",
"rector/rector": "^0.18.5",
"symplify/easy-coding-standard": "^12.0.8"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
SetList::PHPUNIT,
SetList::PSR_12,
SetList::SPACES,
SetList::STRICT,
]);
};
6 changes: 0 additions & 6 deletions phpstan-baseline.neon

This file was deleted.

1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
includes:
- phpstan-baseline.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
Expand Down
27 changes: 11 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
<coverage>
<include>
<directory>./</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
<report>
<text outputFile="php://stdout" showOnlySummary="true"/>
</report>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd">
<testsuites>
<testsuite name="unit">
<directory>./tests/Unit/</directory>
Expand All @@ -26,4 +12,13 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</source>
</phpunit>
16 changes: 12 additions & 4 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
Expand All @@ -16,10 +19,15 @@
// register a single rule
//$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

$rectorConfig->rule(TypedPropertyRector::class);
$rectorConfig->rules([
TypedPropertyFromAssignsRector::class,
TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictGetterMethodReturnTypeRector::class,
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
SetList::CODE_QUALITY
LevelSetList::UP_TO_PHP_81,
PHPUnitSetList::PHPUNIT_100,
SetList::CODE_QUALITY,
]);
};
8 changes: 5 additions & 3 deletions src/Aggregation/AbstractAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -52,7 +54,7 @@ public function getField(): ?string

public function addAggregation(AbstractAggregation $abstractAggregation): static
{
if ($this->aggregations === null) {
if (! $this->aggregations instanceof \OpenSearchDSL\BuilderBag) {
$this->aggregations = $this->createBuilderBag();
}

Expand All @@ -68,7 +70,7 @@ public function addAggregation(AbstractAggregation $abstractAggregation): static
*/
public function getAggregations(): array
{
if ($this->aggregations !== null) {
if ($this->aggregations instanceof \OpenSearchDSL\BuilderBag) {
return $this->aggregations->all();
}

Expand Down Expand Up @@ -97,7 +99,7 @@ public function toArray(): array
if ($this->supportsNesting()) {
$nestedResult = $this->collectNestedAggregations();

if (! empty($nestedResult)) {
if ($nestedResult !== []) {
$result['aggregations'] = $nestedResult;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/Bucketing/AdjacencyMatrixAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand All @@ -24,7 +26,7 @@ class AdjacencyMatrixAggregation extends AbstractAggregation
{
use BucketingTrait;

public const FILTERS = 'filters';
final public const FILTERS = 'filters';

/**
* @var array<string, array<string, array|null>>
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/AutoDateHistogramAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/Bucketing/ChildrenAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -52,7 +54,7 @@ public function getType(): string

public function getArray(): array
{
if (count($this->getAggregations()) == 0) {
if ($this->getAggregations() === []) {
throw new LogicException("Children aggregation `{$this->getName()}` has no aggregations added");
}

Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/CompositeAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/Bucketing/DateHistogramAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -72,7 +74,7 @@ public function getArray(): array
'interval' => $this->getInterval(),
];

if (! empty($this->format)) {
if ($this->format !== null && $this->format !== '') {
$out['format'] = $this->format;
}

Expand Down
8 changes: 5 additions & 3 deletions src/Aggregation/Bucketing/DateRangeAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -99,10 +101,10 @@ public function addRange($from = null, $to = null, $key = null)
'to' => $to,
'key' => $key,
],
fn ($v) => ! is_null($v)
fn ($v) => null !== $v
);

if (empty($range)) {
if ($range === []) {
throw new LogicException('Either from or to must be set. Both cannot be null.');
}

Expand All @@ -113,7 +115,7 @@ public function addRange($from = null, $to = null, $key = null)

public function getArray(): array
{
if ($this->getField() && $this->getFormat() && ! empty($this->ranges)) {
if ($this->getField() && $this->getFormat() && $this->ranges !== []) {
return [
'format' => $this->getFormat(),
'field' => $this->getField(),
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
6 changes: 4 additions & 2 deletions src/Aggregation/Bucketing/FilterAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -31,7 +33,7 @@ public function __construct(string $name, ?BuilderInterface $filter = null)
{
parent::__construct($name);

if ($filter !== null) {
if ($filter instanceof \OpenSearchDSL\BuilderInterface) {
$this->setFilter($filter);
}
}
Expand All @@ -55,7 +57,7 @@ public function setField($field): static

public function getArray(): array
{
if ($this->filter === null) {
if (! $this->filter instanceof \OpenSearchDSL\BuilderInterface) {
throw new LogicException("Filter aggregation `{$this->getName()}` has no filter added");
}

Expand Down
6 changes: 4 additions & 2 deletions src/Aggregation/Bucketing/FiltersAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -61,11 +63,11 @@ public function setAnonymous(bool $anonymous): self
*/
public function addFilter(BuilderInterface $filter, string $name = ''): self
{
if (! $this->anonymous && empty($name)) {
if (! $this->anonymous && $name === '') {
throw new LogicException('In not anonymous filters filter name must be set.');
}

if (! $this->anonymous && ! empty($name)) {
if (! $this->anonymous && $name !== '') {
$this->filters['filters'][$name] = $filter->toArray() ?: null;
} else {
$this->filters['filters'][] = $filter->toArray() ?: null;
Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/Bucketing/GeoDistanceAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -110,7 +112,7 @@ public function addRange($from = null, $to = null)
],
);

if (empty($range)) {
if ($range === []) {
throw new LogicException('Either from or to must be set. Both cannot be null.');
}

Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/GeoHashGridAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/GlobalAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
6 changes: 4 additions & 2 deletions src/Aggregation/Bucketing/HistogramAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand All @@ -24,9 +26,9 @@ class HistogramAggregation extends AbstractAggregation
{
use BucketingTrait;

public const DIRECTION_ASC = 'asc';
final public const DIRECTION_ASC = 'asc';

public const DIRECTION_DESC = 'desc';
final public const DIRECTION_DESC = 'desc';

private ?int $interval = null;

Expand Down
4 changes: 3 additions & 1 deletion src/Aggregation/Bucketing/Ipv4RangeAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down Expand Up @@ -75,7 +77,7 @@ public function getType(): string

public function getArray(): array
{
if ($this->getField() && ! empty($this->ranges)) {
if ($this->getField() && $this->ranges !== []) {
return [
'field' => $this->getField(),
'ranges' => array_values($this->ranges),
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/MissingAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Aggregation/Bucketing/NestedAggregation.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ONGR package.
*
Expand Down
Loading

0 comments on commit b9187e5

Please sign in to comment.