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

Upgrade PHP 7.x to 8.x #2

Merged
merged 7 commits into from
Apr 13, 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
51 changes: 51 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Quality Assurance

on:
push:
paths:
- '.github/workflows/qa.yml'
- 'src/**'
- 'tests/**'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml.dist'

jobs:
phpunit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: "8.3"

- name: Run PHPUnit
uses: php-actions/phpunit@v3
with:
version: "9.6"
php_version: "8.3"

phpstan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: "8.3"

- name: Run PHPStan
uses: php-actions/phpstan@v3
with:
php_version: "8.3"
path: 'src tests'
level: 'max'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ composer.lock

# PHPUnit
phpunit.xml
.phpunit.result.cache

# Mac
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +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}}
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
"Imunew\\Pipeline\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Imunew\\Pipeline\\Test\\": "tests"
}
},
"require": {
"php": "^5.6 || ^7.0"
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^11.0",
"phpstan/phpstan": "^1.10"
}
}
24 changes: 9 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<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">
<testsuite name="tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions src/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class Context implements ContextInterface
/** @var StatusInterface */
private $status;

/** @var array */
/** @var array<string, mixed> */
private $data;

/**
* Context constructor.
* @param array $data
* @param array<string, mixed> $data
*/
public function __construct($data = [])
{
Expand All @@ -36,7 +36,7 @@ public function setStatus($status)

/**
* @param string $key
* @param $value
* @param mixed $value
* @return ContextInterface
*/
public function setData($key, $value)
Expand Down
4 changes: 2 additions & 2 deletions src/Context/ContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ContextInterface
{
/**
* Context constructor.
* @param array $data
* @param array<string, mixed> $data
*/
public function __construct($data = []);

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

/**
* @param string $key
* @param $value
* @param mixed $value
* @return ContextInterface
*/
public function setData($key, $value);
Expand Down
1 change: 1 addition & 0 deletions src/Context/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/**
* Class Status
* @package Imunew\Pipeline
* @phpstan-consistent-constructor
*/
class Status implements StatusInterface
{
Expand Down
15 changes: 11 additions & 4 deletions src/Pipe/Pipes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Imunew\Pipeline\Pipe;

use ReturnTypeWillChange;

/**
* Class Pipes
* @package Imunew\Pipeline\Pipe
Expand Down Expand Up @@ -46,8 +48,9 @@ public function merge($pipes)
}

/**
* {@inheritdoc}
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return current($this->pipes);
Expand All @@ -56,14 +59,16 @@ public function current()
/**
* {@inheritdoc}
*/
#[ReturnTypeWillChange]
public function next()
{
return next($this->pipes);
next($this->pipes);
}

/**
* {@inheritdoc}
* @return int|string|null
*/
#[ReturnTypeWillChange]
public function key()
{
return key($this->pipes);
Expand All @@ -72,6 +77,7 @@ public function key()
/**
* {@inheritdoc}
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->key() !== null;
Expand All @@ -80,8 +86,9 @@ public function valid()
/**
* {@inheritdoc}
*/
#[ReturnTypeWillChange]
public function rewind()
{
return reset($this->pipes);
reset($this->pipes);
}
}
1 change: 1 addition & 0 deletions src/Pipe/PipesInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/**
* Interface PipesInterface
* @package Imunew\Pipeline\Pipe
* @extends Iterator<int, callable>
*/
interface PipesInterface extends Iterator
{
Expand Down
20 changes: 13 additions & 7 deletions tests/Context/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use Imunew\Pipeline\Context\Context;
use Imunew\Pipeline\Context\ContextInterface;
use Imunew\Pipeline\Context\Status;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -13,22 +15,26 @@
class ContextTest extends TestCase
{
/**
* @test
* @dataProvider getTestStatus
*
* @param ContextInterface $context
* @param $isInitialized
* @param $isStarted
* @param $isStopped
* @param bool $isInitialized
* @param bool $isStarted
* @param bool $isStopped
*
* @return void
*/
#[Test]
#[DataProvider('getTestStatus')]
public function setStatus($context, $isInitialized, $isStarted, $isStopped)
{
$this->assertSame($isInitialized, $context->isInitialized());
$this->assertSame($isStarted, $context->isStarted());
$this->assertSame($isStopped, $context->isStopped());
}

public function getTestStatus()
/**
* @return array<string, mixed>[]
*/
public static function getTestStatus()
{
$context = new Context();

Expand Down
10 changes: 7 additions & 3 deletions tests/Context/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
namespace Imunew\Pipeline\Test\Context;

use Imunew\Pipeline\Context\Status;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class StatusTest extends TestCase
{
/**
* @test
* @return void
*/
#[Test]
public function isInitialized()
{
$status = Status::initialize();
Expand All @@ -19,8 +21,9 @@ public function isInitialized()
}

/**
* @test
* @return void
*/
#[Test]
public function isStarted()
{
$status = Status::start();
Expand All @@ -31,8 +34,9 @@ public function isStarted()
}

/**
* @test
* @return void
*/
#[Test]
public function isStopped()
{
$status = Status::stop();
Expand Down
4 changes: 3 additions & 1 deletion tests/Pipe/PipesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Imunew\Pipeline\Context\ContextInterface;
use Imunew\Pipeline\Pipe\Pipes;
use Imunew\Pipeline\Pipeline;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -14,8 +15,9 @@
class PipesTest extends TestCase
{
/**
* @test
* @return void
*/
#[Test]
public function mergeNumberPipes()
{
$pipesA = (new Pipes())
Expand Down
Loading