Skip to content

Commit

Permalink
Merge pull request #4 from MyOnlineStore/php74-8
Browse files Browse the repository at this point in the history
feat: Upgrade for PHP `^7.4 | ^8.0`
  • Loading branch information
fred-jan authored Feb 2, 2022
2 parents 4645cd3 + 0e6c5ab commit 99e7145
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 82 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test

on:
push:
branches-ignore:
- 'master'
tags-ignore:
- '**'

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- uses: actions/cache@v2
with:
path: vendor
key: php-7.4-vendor-${{ hashFiles('**/composer.json') }}
restore-keys: php-7.4-vendor-
- run: composer install --no-interaction --no-ansi
- id: set-php-versions
run: echo "::set-output name=php-versions::$(vendor/bin/devtools list:php-versions)"
- id: set-tools
run: echo "::set-output name=tools::$(vendor/bin/devtools list:enabled-tools)"
outputs:
php-versions: ${{ steps.set-php-versions.outputs.php-versions }}
tools: ${{ steps.set-tools.outputs.tools }}

test:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ${{ fromJson(needs.setup.outputs.php-versions) }}
tool: ${{ fromJson(needs.setup.outputs.tools) }}
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: date.timezone=Europe/Amsterdam, assert.exception=1, zend.assertions=1
- uses: actions/cache@v2
with:
path: vendor
key: php-${{ matrix.php-version }}-vendor-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php-version }}-vendor-
- run: composer install --no-interaction --no-ansi

- run: vendor/bin/devtools ${{ matrix.tool }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.idea
/.DS_Store
/.phpcs-cache
/.phpunit.result.cache
/vendor
/composer.lock
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
}
},
"require": {
"php": "^7.0.33",
"league/tactician": "^1.0"
"php": "^7.4 | ^8.0",
"league/tactician": "^1.1"
},
"require-dev": {
"myonlinestore/coding-standard": "^1.0",
"phpunit/phpunit": "^6.5"
"myonlinestore/coding-standard": "^3.1",
"myonlinestore/php-devtools": "^0.2",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.18"
},
"config": {
"vendor-dir": "vendor",
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"platform": {
"php": "7.0.33"
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
4 changes: 2 additions & 2 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<file>tests</file>

<rule ref="vendor/myonlinestore/coding-standard/MyOnlineStore/ruleset.xml">
<exclude name="Symfony.NamingConventions.ValidClassName.InvalidExceptionName"/>
<exclude name="Symfony.NamingConventions.ValidClassName.InvalidInterfaceName"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
</rule>
</ruleset>
22 changes: 0 additions & 22 deletions phpunit.xml

This file was deleted.

19 changes: 19 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
colors="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
16 changes: 16 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
totallyTyped="true"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
5 changes: 2 additions & 3 deletions src/Application/CommandBusInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ interface CommandBusInterface
/**
* Executes the given command and optionally returns a value
*
* @param object $command
*
* @return mixed
*
* @throws CommandFailedException
*/
public function handle($command);
// phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
public function handle(object $command);
}
2 changes: 1 addition & 1 deletion src/Domain/Exception/CommandFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ final class CommandFailedException extends \RuntimeException
{
public static function wrap(\Throwable $previous): self
{
return new self($previous->getMessage(), $previous->getCode(), $previous);
return new self($previous->getMessage(), (int) $previous->getCode(), $previous);
}
}
7 changes: 2 additions & 5 deletions src/Infrastructure/League/Tactician/CommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

final class CommandBus implements CommandBusInterface
{
/**
* @var TacticianCommandBus
*/
private $commandBus;
private TacticianCommandBus $commandBus;

public function __construct(TacticianCommandBus $commandBus)
{
Expand All @@ -21,7 +18,7 @@ public function __construct(TacticianCommandBus $commandBus)
/**
* @inheritdoc
*/
public function handle($command)
public function handle(object $command)
{
return $this->commandBus->handle($command);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Domain/Exception/CommandFailedExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class CommandFailedExceptionTest extends TestCase
{
public function testWrap()
public function testWrap(): void
{
$commandFailed = CommandFailedException::wrap(
$previous = new \Exception('Foobar', 234)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,23 @@

use League\Tactician\CommandBus as TacticianCommandBus;
use MyOnlineStore\CommandBus\Infrastructure\League\Tactician\CommandBus;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

final class CommandBusTest extends TestCase
{
/**
* @var TacticianCommandBus
*/
private $tacticianCommandBus;
/** @var TacticianCommandBus&MockObject */
private TacticianCommandBus $tacticianCommandBus;
private CommandBus $commandBus;

/**
* @var CommandBus
*/
private $commandBus;

protected function setUp()
protected function setUp(): void
{
$this->tacticianCommandBus = $this->createMock(TacticianCommandBus::class);

$this->commandBus = new CommandBus($this->tacticianCommandBus);
}

public function testWillThrowOnTheBus()
public function testWillThrowOnTheBus(): void
{
$command = new \stdClass();

Expand Down

0 comments on commit 99e7145

Please sign in to comment.