Skip to content

Commit

Permalink
Raise PHP to 8.1 (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Jan 21, 2024
1 parent 4c918a1 commit 5339df8
Show file tree
Hide file tree
Showing 26 changed files with 126 additions and 133 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
| Is bugfix? | ✔️/❌
| New feature? | ✔️/❌
| Breaks BC? | ✔️/❌
| Fixed issues | comma-separated list of tickets # fixed by the PR, if any
40 changes: 29 additions & 11 deletions .github/workflows/bc.yml_
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'

name: backwards compatibility

jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
roave_bc_check:
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'psalm.xml'

push:
branches: [ 'master' ]
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -26,7 +26,8 @@ jobs:
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
with:
ini-values: pcov.directory=$GITHUB_WORKSPACE, pcov.exclude=#^(?!($GITHUB_WORKSPACE/config/|$GITHUB_WORKSPACE/src/)).*#
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2', '8.3']
4 changes: 2 additions & 2 deletions .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'psalm.xml'

push:
branches: [ 'master' ]
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2', '8.3']
4 changes: 2 additions & 2 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- 'psalm.xml'

push:
branches: [ 'master' ]
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -27,6 +27,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.3']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.2']
['8.3']
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'phpunit.xml.dist'

push:
branches: [ 'master' ]
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -29,4 +29,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2', '8.3']
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:

environment:
php:
version: 8.0.18
version: 8.1.26
ini:
xdebug.mode: coverage

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0",
"php": "^8.1",
"psr/container": "^1.0|^2.0",
"psr/log": "^2.0|^3.0",
"symfony/console": "^5.4|^6.0",
Expand All @@ -35,14 +35,14 @@
"yiisoft/injector": "^1.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"maglnet/composer-require-checker": "^4.7",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.19.0",
"roave/infection-static-analysis-plugin": "^1.16",
"roave/infection-static-analysis-plugin": "^1.34",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.8",
"vimeo/psalm": "^5.20",
"yiisoft/test-support": "^3.0",
"yiisoft/yii-debug": "dev-master|dev-php80"
"yiisoft/yii-debug": "dev-master"
},
"suggest": {
"ext-pcntl": "Need for process signals"
Expand Down
44 changes: 26 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
executionOrder="random"
verbose="true"
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnFailure="false"
colors="true"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Unit">
<testsuite name="Yii Queue unit tests">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<testsuite name="Yii Queue integration tests">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./config</directory>
</include>
</source>
</phpunit>
4 changes: 3 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -19,11 +20,12 @@

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
JsonThrowOnErrorRector::class,
ReadOnlyPropertyRector::class,
]);
};
6 changes: 3 additions & 3 deletions src/Enum/JobStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

class JobStatus
{
public const WAITING = 1;
public const RESERVED = 2;
public const DONE = 3;
final public const WAITING = 1;
final public const RESERVED = 2;
final public const DONE = 3;

protected int $status;

Expand Down
2 changes: 1 addition & 1 deletion tests/App/FakeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function staticExecute(MessageInterface $message): void
self::$processedMessages[] = $message;
}

public function executeWithException(MessageInterface $message): void
public function executeWithException(MessageInterface $message): never
{
throw new RuntimeException('Test exception');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ protected function getMessageHandlers(): array
{
return [
'simple' => fn () => $this->executionTimes++,
'exceptional' => function () {
'exceptional' => function (): never {
$this->executionTimes++;

throw new RuntimeException('test');
},
'retryable' => function () {
'retryable' => function (): never {
$this->executionTimes++;

throw new RuntimeException('test');
Expand Down
7 changes: 3 additions & 4 deletions tests/Unit/JobStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace Yiisoft\Queue\Tests\Unit;

use PHPUnit\Framework\Attributes\DataProvider;
use Yiisoft\Queue\Enum\JobStatus;
use Yiisoft\Queue\Exception\InvalidStatusException;
use Yiisoft\Queue\Tests\TestCase;
use Yiisoft\Queue\Tests\Unit\Support\TestJobStatus;

final class JobStatusTest extends TestCase
{
public function getStatusPairs(): array
public static function getStatusPairs(): array
{
return [
'waiting' => [
Expand Down Expand Up @@ -41,9 +42,7 @@ public function getStatusPairs(): array
];
}

/**
* @dataProvider getStatusPairs
*/
#[DataProvider('getStatusPairs')]
public function testInstanceValue(string $statusName, string $positiveMethod, array $negatives): void
{
$status = JobStatus::$statusName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace Yiisoft\Queue\Tests\Unit\Middleware\Consume;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
use Yiisoft\Queue\Middleware\InvalidMiddlewareDefinitionException;
use Yiisoft\Queue\Tests\Unit\Middleware\Consume\Support\TestCallableMiddleware;

final class InvalidMiddlewareDefinitionExceptionTest extends TestCase
{
public function dataBase(): array
public static function dataBase(): array
{
return [
[
Expand All @@ -33,26 +34,22 @@ public function dataBase(): array
];
}

/**
* @dataProvider dataBase
*/
#[DataProvider('dataBase')]
public function testBase(mixed $definition, string $expected): void
{
$exception = new InvalidMiddlewareDefinitionException($definition);
self::assertStringEndsWith('. Got ' . $expected . '.', $exception->getMessage());
}

public function dataUnknownDefinition(): array
public static function dataUnknownDefinition(): array
{
return [
[42],
[[new stdClass()]],
];
}

/**
* @dataProvider dataUnknownDefinition
*/
#[DataProvider('dataUnknownDefinition')]
public function testUnknownDefinition(mixed $definition): void
{
$exception = new InvalidMiddlewareDefinitionException($definition);
Expand Down
7 changes: 3 additions & 4 deletions tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Queue\Tests\Unit\Middleware\Consume;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Yiisoft\Test\Support\Container\SimpleContainer;
Expand Down Expand Up @@ -103,17 +104,15 @@ public function testMiddlewareStackInterrupted(): void
$this->assertSame('first', $request->getMessage()->getData());
}

public function dataHasMiddlewares(): array
public static function dataHasMiddlewares(): array
{
return [
[[], false],
[[[TestCallableMiddleware::class, 'index']], true],
];
}

/**
* @dataProvider dataHasMiddlewares
*/
#[DataProvider('dataHasMiddlewares')]
public function testHasMiddlewares(array $definitions, bool $expected): void
{
self::assertSame(
Expand Down
Loading

0 comments on commit 5339df8

Please sign in to comment.