Skip to content
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
106 changes: 29 additions & 77 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,38 @@ on:
branches:
- master

env:
default_php: 8.4

jobs:
coding-standards:
name: Coding Standards
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
- uses: actions/checkout@v4.2.2
- uses: shivammathur/setup-php@2.34.1
with:
php-version: 8.4
php-version: ${{ env.default_php }}
coverage: none
extensions: redis

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Run the linter
run: composer lint

- name: Check coding standards
run: composer cs-check
- uses: ramsey/composer-install@v3
- run: composer lint
- run: composer cs-check

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
- uses: actions/checkout@v4.2.2
- uses: shivammathur/setup-php@2.34.1
with:
coverage: none
php-version: 8.4
extensions: redis

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer update --no-interaction --no-progress --prefer-dist

- name: Run static analysis
run: php vendor/bin/phpstan analyse
php-version: ${{ env.default_php }}
- uses: ramsey/composer-install@v3
- run: php vendor/bin/phpstan analyse

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.3', '8.4']
Expand All @@ -90,32 +51,23 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
- uses: actions/checkout@v4.2.2
- uses: shivammathur/setup-php@2.34.1
with:
php-version: "${{ matrix.php-versions }}"
coverage: xdebug
extensions: redis

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: ramsey/composer-install@v3
- run: ./vendor/bin/phpunit
- uses: codecov/codecov-action@v1

- name: Cache dependencies
uses: actions/cache@v2
rector:
runs-on: ubuntu-latest
name: Run Rector on PHP
steps:
- uses: actions/checkout@v4.2.2
- uses: shivammathur/setup-php@2.34.1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader

- name: Run unit tests
run: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text

- name: Publish coverage report to Codecov
uses: codecov/codecov-action@v1
php-version: ${{ env.default_php }}
tools: composer
- uses: ramsey/composer-install@v3
- run: composer rector
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"doctrine/orm": "^2.8",
"guzzlehttp/guzzle": "^7.2",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.0.0",
"rector/rector": "^1.2",
"rector/rector": "^2.0",
"squizlabs/php_codesniffer": "^3.7",
"symfony/cache": "^6.0",
"symfony/serializer": "^6.0"
Expand Down Expand Up @@ -65,6 +66,7 @@
"rector:clear": "rector -n --clear-cache -vv",
"rector:fix": "rector -vv",
"stan": "phpstan analyse --no-progress",
"stan:b": "@stan -b --allow-empty-baseline",
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover clover.xml"
}
Expand Down
223 changes: 223 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
parameters:
ignoreErrors:
-
rawMessage: 'Argument of an invalid type mixed supplied for foreach, only iterables are supported.'
identifier: foreach.nonIterable
count: 1
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Offset ''*'' on array<class-string, array<string, list<string>>> on left side of ?? does not exist.'
identifier: nullCoalesce.offset
count: 1
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Parameter #1 $id of method Psr\Container\ContainerInterface::get() expects string, mixed given.'
identifier: argument.type
count: 1
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, mixed given.'
identifier: argument.type
count: 1
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Property CQRS\EventHandling\PsrContainerEventHandlerLocator::$handlers (array<class-string, array<string, list<string>>>) does not accept array<class-string, array<string, array<int<0, max>, string>>>.'
identifier: assign.propertyType
count: 3
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Property CQRS\EventHandling\PsrContainerEventHandlerLocator::$handlers (array<class-string, array<string, list<string>>>) does not accept non-empty-array<string, array<string, list<string>>>.'
identifier: assign.propertyType
count: 3
path: src/EventHandling/PsrContainerEventHandlerLocator.php

-
rawMessage: 'Call to function is_string() with string will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 1
path: src/EventStore/RedisEventRecord.php

-
rawMessage: 'Method CQRS\EventStore\RedisEventRecord::toArray() should return array{id: string, timestamp: string, payload: array{data: string, type: string}, metadata: array{data: array<string, mixed>, types: array<string, string>}, aggregate?: array{type: string, id: mixed, seq: int}} but returns mixed.'
identifier: return.type
count: 1
path: src/EventStore/RedisEventRecord.php

-
rawMessage: 'Parameter #2 $handlers of class CQRS\CommandHandling\PsrContainerCommandHandlerLocator constructor expects array<class-string, string>, array<string, string> given.'
identifier: argument.type
count: 1
path: tests/CommandHandling/PsrContainerCommandHandlerLocatorTest.php

-
rawMessage: 'Method CQRSTest\CommandHandling\Stubs\DummyCommandHandlerLocator::get() should return callable(): mixed but returns mixed.'
identifier: return.type
count: 1
path: tests/CommandHandling/Stubs/DummyCommandHandlerLocator.php

-
rawMessage: Property CQRSTest\CommandHandling\Stubs\DummyCommandHandlerLocator::$handlers type has no value type specified in iterable type array.
identifier: missingType.iterableValue
count: 1
path: tests/CommandHandling/Stubs/DummyCommandHandlerLocator.php

-
rawMessage: 'Method CQRSTest\EventHandling\Stubs\DummyEventHandler::onEventExecutionFailed() has parameter $event with no type specified.'
identifier: missingType.parameter
count: 1
path: tests/EventHandling/Stubs/DummyEventHandler.php

-
rawMessage: 'Property CQRSTest\EventHandling\Stubs\DummyEventHandler::$failureEvent (CQRS\EventHandling\EventExecutionFailed|null) does not accept mixed.'
identifier: assign.propertyType
count: 1
path: tests/EventHandling/Stubs/DummyEventHandler.php

-
rawMessage: 'Match expression does not handle remaining value: string'
identifier: match.unhandled
count: 1
path: tests/EventHandling/Stubs/DummyEventHandlerLocator.php

-
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.'
identifier: staticMethod.alreadyNarrowedType
count: 1
path: tests/EventHandling/SynchronousEventBusTest.php

-
rawMessage: Cannot access offset 0 on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: tests/EventStore/RedisEventStoreTest.php

-
rawMessage: Cannot access offset 1 on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: tests/EventStore/RedisEventStoreTest.php

-
rawMessage: 'Cannot call method toMessage() on CQRS\EventStore\RedisEventRecord|null.'
identifier: method.nonObject
count: 1
path: tests/EventStore/RedisEventStoreTest.php

-
rawMessage: 'Method CQRSTest\EventStore\RedisEventStoreTest::getData() return type has no value type specified in iterable type array.'
identifier: missingType.iterableValue
count: 1
path: tests/EventStore/RedisEventStoreTest.php

-
rawMessage: 'Parameter #2 $actualJson of static method PHPUnit\Framework\Assert::assertJsonStringEqualsJsonString() expects string, mixed given.'
identifier: argument.type
count: 1
path: tests/EventStore/RedisEventStoreTest.php

-
rawMessage: 'Method CQRSTest\EventStore\SomeSerializer::deserialize() should return object but returns array|CQRS\Domain\Message\Metadata|CQRSTest\EventStore\SomeEvent|null.'
identifier: return.type
count: 1
path: tests/EventStore/SomeSerializer.php

-
rawMessage: PHPDoc tag @var with type Doctrine\ORM\EntityManagerInterface is not subtype of native type PHPUnit\Framework\MockObject\MockObject.
identifier: varTag.nativeType
count: 3
path: tests/Plugin/Doctrine/CommandHandling/ExplicitOrmTransactionManagerTest.php

-
rawMessage: PHPDoc tag @var with type Doctrine\ORM\EntityManagerInterface is not subtype of native type PHPUnit\Framework\MockObject\MockObject.
identifier: varTag.nativeType
count: 3
path: tests/Plugin/Doctrine/CommandHandling/ImplicitOrmTransactionManagerTest.php

-
rawMessage: 'Property CQRSTest\Serializer\Model\FloatObject::$value is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/Model/FloatObject.php

-
rawMessage: 'Property CQRSTest\Serializer\Model\IntObject::$value is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/Model/IntObject.php

-
rawMessage: 'Property CQRSTest\Serializer\Model\IntegerObject::$value is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/Model/IntegerObject.php

-
rawMessage: 'Property CQRSTest\Serializer\Model\StringObject::$value is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/Model/StringObject.php

-
rawMessage: Property CQRSTest\Serializer\SomeEvent2::$foo has no type specified.
identifier: missingType.property
count: 1
path: tests/Serializer/SomeEvent2.php

-
rawMessage: Property CQRSTest\Serializer\SomeEvent2::$id has no type specified.
identifier: missingType.property
count: 1
path: tests/Serializer/SomeEvent2.php

-
rawMessage: Property CQRSTest\Serializer\SomeEvent2::$object has no type specified.
identifier: missingType.property
count: 1
path: tests/Serializer/SomeEvent2.php

-
rawMessage: Property CQRSTest\Serializer\SomeEvent2::$time has no type specified.
identifier: missingType.property
count: 1
path: tests/Serializer/SomeEvent2.php

-
rawMessage: 'Property CQRSTest\Serializer\SomeEvent3::$int is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/SomeEvent3.php

-
rawMessage: 'Property CQRSTest\Serializer\SomeEvent3::$string1 is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/SomeEvent3.php

-
rawMessage: 'Property CQRSTest\Serializer\SomeEvent3::$string2 is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/SomeEvent3.php

-
rawMessage: 'Property CQRSTest\Serializer\SomeEvent3::$uuid is never read, only written.'
identifier: property.onlyWritten
count: 1
path: tests/Serializer/SomeEvent3.php

-
rawMessage: Constructor of class CQRSTest\Serializer\TestEventWithCustomConstructor has an unused parameter $someAggregate.
identifier: constructor.unusedParameter
count: 1
path: tests/Serializer/TestEventWithCustomConstructor.php

-
rawMessage: 'Method CQRSTest\Stubs\MemoryContainer::__construct() has parameter $services with no value type specified in iterable type array.'
identifier: missingType.iterableValue
count: 1
path: tests/Stubs/MemoryContainer.php
6 changes: 4 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- phpstan-baseline.neon
parameters:
level: max
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
paths:
- src
- tests
Loading