Skip to content

Commit fcc386c

Browse files
authored
Merge pull request #2 from imunew/upgrade-php8.x
Upgrade PHP 7.x to 8.x
2 parents 565621f + 6f8c17f commit fcc386c

14 files changed

+129
-44
lines changed

.github/workflows/qa.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Quality Assurance
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/qa.yml'
7+
- 'src/**'
8+
- 'tests/**'
9+
- 'composer.json'
10+
- 'composer.lock'
11+
- 'phpunit.xml.dist'
12+
13+
jobs:
14+
phpunit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
22+
- name: Install dependencies
23+
uses: php-actions/composer@v6
24+
with:
25+
php_version: "8.3"
26+
27+
- name: Run PHPUnit
28+
uses: php-actions/phpunit@v3
29+
with:
30+
version: "9.6"
31+
php_version: "8.3"
32+
33+
phpstan:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
persist-credentials: false
40+
41+
- name: Install dependencies
42+
uses: php-actions/composer@v6
43+
with:
44+
php_version: "8.3"
45+
46+
- name: Run PHPStan
47+
uses: php-actions/phpstan@v3
48+
with:
49+
php_version: "8.3"
50+
path: 'src tests'
51+
level: 'max'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ composer.lock
44

55
# PHPUnit
66
phpunit.xml
7+
.phpunit.result.cache
78

89
# Mac
910
.DS_Store

.phpunit.cache/test-results

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":{"Imunew\\Pipeline\\Test\\Context\\ContextTest::setStatus":8},"times":{"Imunew\\Pipeline\\Test\\Context\\StatusTest::isInitialized":0,"Imunew\\Pipeline\\Test\\Context\\StatusTest::isStarted":0,"Imunew\\Pipeline\\Test\\Context\\StatusTest::isStopped":0,"Imunew\\Pipeline\\Test\\Pipe\\PipesTest::mergeNumberPipes":0,"Imunew\\Pipeline\\Test\\PipelineTest::processSuccessWithIncrementNumberPipes":0,"Imunew\\Pipeline\\Test\\PipelineTest::processSuccessWithMessagePipes":0,"Imunew\\Pipeline\\Test\\PipelineTest::processSuccessWithExtraMessagePipes":0,"Imunew\\Pipeline\\Test\\PipelineTest::processFailedByNotReturnContext":0.001,"Imunew\\Pipeline\\Test\\Context\\ContextTest::setStatus":0.004,"Imunew\\Pipeline\\Test\\Context\\ContextTest::setStatus#0":0.001,"Imunew\\Pipeline\\Test\\Context\\ContextTest::setStatus#1":0,"Imunew\\Pipeline\\Test\\Context\\ContextTest::setStatus#2":0}}

composer.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
"Imunew\\Pipeline\\": "src"
1515
}
1616
},
17+
"autoload-dev": {
18+
"psr-4": {
19+
"Imunew\\Pipeline\\Test\\": "tests"
20+
}
21+
},
1722
"require": {
18-
"php": "^5.6 || ^7.0"
23+
"php": ">=8.1"
1924
},
2025
"require-dev": {
21-
"phpunit/phpunit": "^5.7"
26+
"phpunit/phpunit": "^11.0",
27+
"phpstan/phpstan": "^1.10"
2228
}
2329
}

phpunit.xml.dist

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
backupGlobals="false"
6-
verbose="true">
7-
<testsuite>
8-
<directory suffix="Test.php">tests</directory>
9-
</testsuite>
10-
11-
<filter>
12-
<whitelist processUncoveredFilesFromWhitelist="true">
13-
<directory suffix=".php">src</directory>
14-
</whitelist>
15-
</filter>
16-
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd" bootstrap="vendor/autoload.php" backupGlobals="false" cacheDirectory=".phpunit.cache">
3+
<testsuite name="tests">
4+
<directory suffix="Test.php">tests</directory>
5+
</testsuite>
6+
<source>
7+
<include>
8+
<directory suffix=".php">src</directory>
9+
</include>
10+
</source>
1711
</phpunit>

src/Context/Context.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ class Context implements ContextInterface
1010
/** @var StatusInterface */
1111
private $status;
1212

13-
/** @var array */
13+
/** @var array<string, mixed> */
1414
private $data;
1515

1616
/**
1717
* Context constructor.
18-
* @param array $data
18+
* @param array<string, mixed> $data
1919
*/
2020
public function __construct($data = [])
2121
{
@@ -36,7 +36,7 @@ public function setStatus($status)
3636

3737
/**
3838
* @param string $key
39-
* @param $value
39+
* @param mixed $value
4040
* @return ContextInterface
4141
*/
4242
public function setData($key, $value)

src/Context/ContextInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ContextInterface
99
{
1010
/**
1111
* Context constructor.
12-
* @param array $data
12+
* @param array<string, mixed> $data
1313
*/
1414
public function __construct($data = []);
1515

@@ -21,7 +21,7 @@ public function setStatus($status);
2121

2222
/**
2323
* @param string $key
24-
* @param $value
24+
* @param mixed $value
2525
* @return ContextInterface
2626
*/
2727
public function setData($key, $value);

src/Context/Status.php

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/**
55
* Class Status
66
* @package Imunew\Pipeline
7+
* @phpstan-consistent-constructor
78
*/
89
class Status implements StatusInterface
910
{

src/Pipe/Pipes.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Imunew\Pipeline\Pipe;
33

4+
use ReturnTypeWillChange;
5+
46
/**
57
* Class Pipes
68
* @package Imunew\Pipeline\Pipe
@@ -46,8 +48,9 @@ public function merge($pipes)
4648
}
4749

4850
/**
49-
* {@inheritdoc}
51+
* @return mixed
5052
*/
53+
#[ReturnTypeWillChange]
5154
public function current()
5255
{
5356
return current($this->pipes);
@@ -56,14 +59,16 @@ public function current()
5659
/**
5760
* {@inheritdoc}
5861
*/
62+
#[ReturnTypeWillChange]
5963
public function next()
6064
{
61-
return next($this->pipes);
65+
next($this->pipes);
6266
}
6367

6468
/**
65-
* {@inheritdoc}
69+
* @return int|string|null
6670
*/
71+
#[ReturnTypeWillChange]
6772
public function key()
6873
{
6974
return key($this->pipes);
@@ -72,6 +77,7 @@ public function key()
7277
/**
7378
* {@inheritdoc}
7479
*/
80+
#[ReturnTypeWillChange]
7581
public function valid()
7682
{
7783
return $this->key() !== null;
@@ -80,8 +86,9 @@ public function valid()
8086
/**
8187
* {@inheritdoc}
8288
*/
89+
#[ReturnTypeWillChange]
8390
public function rewind()
8491
{
85-
return reset($this->pipes);
92+
reset($this->pipes);
8693
}
8794
}

src/Pipe/PipesInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/**
77
* Interface PipesInterface
88
* @package Imunew\Pipeline\Pipe
9+
* @extends Iterator<int, callable>
910
*/
1011
interface PipesInterface extends Iterator
1112
{

tests/Context/ContextTest.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use Imunew\Pipeline\Context\Context;
55
use Imunew\Pipeline\Context\ContextInterface;
66
use Imunew\Pipeline\Context\Status;
7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\Attributes\Test;
79
use PHPUnit\Framework\TestCase;
810

911
/**
@@ -13,22 +15,26 @@
1315
class ContextTest extends TestCase
1416
{
1517
/**
16-
* @test
17-
* @dataProvider getTestStatus
18-
*
1918
* @param ContextInterface $context
20-
* @param $isInitialized
21-
* @param $isStarted
22-
* @param $isStopped
19+
* @param bool $isInitialized
20+
* @param bool $isStarted
21+
* @param bool $isStopped
22+
*
23+
* @return void
2324
*/
25+
#[Test]
26+
#[DataProvider('getTestStatus')]
2427
public function setStatus($context, $isInitialized, $isStarted, $isStopped)
2528
{
2629
$this->assertSame($isInitialized, $context->isInitialized());
2730
$this->assertSame($isStarted, $context->isStarted());
2831
$this->assertSame($isStopped, $context->isStopped());
2932
}
3033

31-
public function getTestStatus()
34+
/**
35+
* @return array<string, mixed>[]
36+
*/
37+
public static function getTestStatus()
3238
{
3339
$context = new Context();
3440

tests/Context/StatusTest.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
namespace Imunew\Pipeline\Test\Context;
33

44
use Imunew\Pipeline\Context\Status;
5+
use PHPUnit\Framework\Attributes\Test;
56
use PHPUnit\Framework\TestCase;
67

78
class StatusTest extends TestCase
89
{
910
/**
10-
* @test
11+
* @return void
1112
*/
13+
#[Test]
1214
public function isInitialized()
1315
{
1416
$status = Status::initialize();
@@ -19,8 +21,9 @@ public function isInitialized()
1921
}
2022

2123
/**
22-
* @test
24+
* @return void
2325
*/
26+
#[Test]
2427
public function isStarted()
2528
{
2629
$status = Status::start();
@@ -31,8 +34,9 @@ public function isStarted()
3134
}
3235

3336
/**
34-
* @test
37+
* @return void
3538
*/
39+
#[Test]
3640
public function isStopped()
3741
{
3842
$status = Status::stop();

tests/Pipe/PipesTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Imunew\Pipeline\Context\ContextInterface;
66
use Imunew\Pipeline\Pipe\Pipes;
77
use Imunew\Pipeline\Pipeline;
8+
use PHPUnit\Framework\Attributes\Test;
89
use PHPUnit\Framework\TestCase;
910

1011
/**
@@ -14,8 +15,9 @@
1415
class PipesTest extends TestCase
1516
{
1617
/**
17-
* @test
18+
* @return void
1819
*/
20+
#[Test]
1921
public function mergeNumberPipes()
2022
{
2123
$pipesA = (new Pipes())

0 commit comments

Comments
 (0)