Skip to content

Commit

Permalink
Add symfony 6 comptability (php-task#46)
Browse files Browse the repository at this point in the history
* Add symfony 6 comptability

* Remove old php and symfony versions

* Fix scrutinizer upload for php8
  • Loading branch information
Prokyonn authored Jul 22, 2022
1 parent 4a7c567 commit 4aca1ef
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 44 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,19 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '5.6'
dependencies: 'lowest'
- php-version: '5.6'
- php-version: '7.0'
dependencies: 'lowest'
- php-version: '7.0'
dependencies: 'lowest'
- php-version: '7.1'
- php-version: '8.0'
dependencies: 'lowest'
- php-version: '7.1'
- php-version: '7.4'
coverage: 'true'
- php-version: '8.0'
- php-version: '8.1'
coverage: 'true'

steps:
- name: Checkout project
uses: actions/checkout@v2
with:
# Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. If you use a shallow git checkout, please checkout at least a depth of one."), see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository
# 10 commits is an arbitrary value that is more than 1 commit
fetch-depth: 10

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -45,7 +41,7 @@ jobs:
tools: 'composer:v2'

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist --no-suggest
Expand All @@ -56,5 +52,5 @@ jobs:
- name: Coverage
if: ${{ matrix.coverage }}
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover
composer global require scrutinizer/ocular
~/.composer/vendor/bin/ocular code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
}
],
"require": {
"php": "^5.6 || ^7.0 || ^8.0",
"php": "^8.0 || ^8.1",
"doctrine/collections": "^1.0",
"ramsey/uuid": "^3.1 || ^4.0",
"symfony/event-dispatcher": "^2.6 || ^3.4 || ^4.0 || ^5.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"dragonmantank/cron-expression": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"mikey179/vfsstream": "^1.6.7",
"psr/log": "^1.0",
"symfony/phpunit-bridge": "^5.2.3"
"symfony/phpunit-bridge": "^5.4 || ^6.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 1 addition & 6 deletions src/Task/Runner/TaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Task\Runner;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
use Task\Event\Events;
use Task\Event\TaskExecutionEvent;
use Task\Execution\TaskExecutionInterface;
Expand Down Expand Up @@ -218,10 +217,6 @@ private function finalize(TaskExecutionInterface $execution, $start)

private function dispatch($eventName, $event)
{
if (class_exists(LegacyEventDispatcherProxy::class)) {
return $this->eventDispatcher->dispatch($event, $eventName);
} else {
return $this->eventDispatcher->dispatch($eventName, $event);
}
return $this->eventDispatcher->dispatch($event, $eventName);
}
}
6 changes: 1 addition & 5 deletions src/Task/Scheduler/TaskScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ protected function scheduleTask(TaskInterface $task)

private function dispatch($eventName, $event)
{
if (class_exists(LegacyEventDispatcherProxy::class)) {
return $this->eventDispatcher->dispatch($event, $eventName);
} else {
return $this->eventDispatcher->dispatch($eventName, $event);
}
return $this->eventDispatcher->dispatch($event, $eventName);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Lock/LockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LockTest extends TestCase
*/
private $key = 'test-key';

protected function setUp()
protected function setUp(): void
{
$this->storage = $this->prophesize(LockStorageInterface::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Lock/Storage/FileLockStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FileLockStorageTest extends TestCase
*/
private $storage;

public function setUp()
public function setUp(): void
{
$this->root = vfsStream::setup('tmp');

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Runner/InsideProcessExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InsideProcessExecutorTest extends TestCase
*/
private $executor;

protected function setUp()
protected function setUp(): void
{
$this->handlerFactory = $this->prophesize(TaskHandlerFactoryInterface::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Runner/PendingExecutionFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PendingExecutionFinderTest extends TestCase
*/
private $lockingHandler;

protected function setUp()
protected function setUp(): void
{
$this->taskExecutionRepository = $this->prophesize(TaskExecutionRepositoryInterface::class);
$this->taskHandlerFactory = $this->prophesize(TaskHandlerFactoryInterface::class);
Expand Down
8 changes: 2 additions & 6 deletions tests/Unit/Runner/TaskRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TaskRunnerTest extends TestCase
*/
private $taskRunner;

protected function setUp()
protected function setUp(): void
{
$this->taskExecutionRepository = $this->prophesize(TaskExecutionRepositoryInterface::class);
$this->executionFinder = $this->prophesize(ExecutionFinderInterface::class);
Expand Down Expand Up @@ -259,11 +259,7 @@ private function createTaskExecution(

private function dispatch($eventName, $event)
{
if (class_exists(LegacyEventDispatcherProxy::class)) {
return $this->eventDispatcher->dispatch($event, $eventName)->shouldBeCalled()->willReturnArgument(0);
} else {
return $this->eventDispatcher->dispatch($eventName, $event)->shouldBeCalled()->willReturnArgument(0);
}
return $this->eventDispatcher->dispatch($event, $eventName)->shouldBeCalled()->willReturnArgument(0);
}
}

Expand Down
8 changes: 2 additions & 6 deletions tests/Unit/Scheduler/TaskSchedulerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TaskSchedulerTest extends TestCase
*/
private $taskScheduler;

protected function setUp()
protected function setUp(): void
{
$this->factory = $this->prophesize(TaskBuilderFactoryInterface::class);
$this->taskRepository = $this->prophesize(TaskRepositoryInterface::class);
Expand Down Expand Up @@ -197,11 +197,7 @@ private function createTask($interval, $firstExecution = null)

private function dispatch($eventName, $event)
{
if (class_exists(LegacyEventDispatcherProxy::class)) {
return $this->eventDispatcher->dispatch($event, $eventName)->shouldBeCalled()->willReturnArgument(0);
} else {
return $this->eventDispatcher->dispatch($eventName, $event)->shouldBeCalled()->willReturnArgument(0);
}
return $this->eventDispatcher->dispatch($event, $eventName)->shouldBeCalled()->willReturnArgument(0);
}
}

Expand Down

0 comments on commit 4aca1ef

Please sign in to comment.