Skip to content

Commit a7526e5

Browse files
committed
To promise version 3 + php 81 82
1 parent 6706b47 commit a7526e5

7 files changed

Lines changed: 55 additions & 24 deletions

File tree

.circleci/config.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
rm -Rf var/*
1717
php vendor/bin/phpunit --testsuite=with-stopwatch --exclude-group=with-filesystem
1818
19-
test-php74-filesystem:
19+
test-php80-no-filesystem:
2020
docker:
21-
- image: circleci/php:7.4-cli
21+
- image: circleci/php:8.0-cli
2222

2323
working_directory: ~/project
2424
steps:
@@ -27,14 +27,28 @@ jobs:
2727
- run:
2828
name: Run tests / Highest
2929
command: |
30-
composer require react/filesystem:^0.1 --no-update
3130
composer update -n --prefer-dist
3231
rm -Rf var/*
33-
php vendor/bin/phpunit --testsuite=base --exclude-group=without-filesystem
32+
php vendor/bin/phpunit --testsuite=base --exclude-group=with-filesystem
3433
35-
test-php80-no-filesystem:
34+
test-php81-no-filesystem:
3635
docker:
37-
- image: circleci/php:8.0-cli
36+
- image: cimg/php:8.1
37+
38+
working_directory: ~/project
39+
steps:
40+
- checkout
41+
42+
- run:
43+
name: Run tests / Highest
44+
command: |
45+
composer update -n --prefer-dist
46+
rm -Rf var/*
47+
php vendor/bin/phpunit --testsuite=base --exclude-group=with-filesystem
48+
49+
test-php82-no-filesystem:
50+
docker:
51+
- image: cimg/php:8.2
3852

3953
working_directory: ~/project
4054
steps:
@@ -52,5 +66,6 @@ workflows:
5266
test:
5367
jobs:
5468
- test-php74-no-filesystem
55-
- test-php74-filesystem
56-
- test-php80-no-filesystem
69+
- test-php80-no-filesystem
70+
- test-php81-no-filesystem
71+
- test-php82-no-filesystem

AsyncEventDispatcherMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function doAsyncDispatch(
6868
string $eventName,
6969
Event $event
7070
) {
71-
$promise = resolve();
71+
$promise = resolve(null);
7272
foreach ($listeners as $listener) {
7373
$promise = $promise->then(function () use ($event, $eventName, $listener) {
7474
return

AsyncHttpKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private function callAsyncView(
221221
int $type
222222
): PromiseInterface {
223223
return
224-
(resolve())
224+
(resolve(null))
225225
->then(function () use ($request, $response, $controller, $type) {
226226
$event = new ViewEvent($this, $request, $type, $response);
227227

AsyncKernel.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Symfony\Component\DependencyInjection\ContainerBuilder;
3030
use Symfony\Component\DependencyInjection\Definition;
3131
use Symfony\Component\DependencyInjection\Reference;
32-
use Symfony\Component\Filesystem\Filesystem;
3332
use Symfony\Component\HttpFoundation\Request;
3433
use Symfony\Component\HttpKernel\Kernel;
3534

@@ -58,21 +57,41 @@ public function boot()
5857
$this->uid = $this->generateUID();
5958

6059
if (!$this->forceCacheUsage && ($_ENV['DRIFT_CACHE_ENABLED'] ?? '0') !== '1') {
61-
$fs = new Filesystem();
6260
// AsyncKernel loads the container only once when it loads. Storing it in the filesystem is not for cache purposes
6361
// but more for using the same loading process as Kernel class use.
6462
// Hence, everytime before AsyncKernel initiates the container it deletes the cache dir,
6563
// to make sure it is building the updated kernel
6664
$cachePath = $this->getCacheDir();
67-
if ($fs->exists($cachePath)) {
68-
$fs->remove($cachePath);
65+
if (is_dir($cachePath)) {
66+
$this->rrmdir($cachePath);
6967
}
7068
}
7169
}
7270

7371
parent::boot();
7472
}
7573

74+
/**
75+
* @param $src
76+
* @return void
77+
*/
78+
function rrmdir($src) {
79+
$dir = opendir($src);
80+
while(false !== ( $file = readdir($dir)) ) {
81+
if (( $file != '.' ) && ( $file != '..' )) {
82+
$full = $src . '/' . $file;
83+
if ( is_dir($full) ) {
84+
$this->rrmdir($full);
85+
}
86+
else {
87+
unlink($full);
88+
}
89+
}
90+
}
91+
closedir($dir);
92+
rmdir($src);
93+
}
94+
7695
/**
7796
* Preload kernel.
7897
*/

Tests/Listener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Listener
4242
*/
4343
public function handleGetResponsePromiseA(RequestEvent $event)
4444
{
45-
return (resolve())
45+
return (resolve(null))
4646
->then(function () use ($event) {
4747
$event->setResponse(new Response('A'));
4848
});
@@ -57,7 +57,7 @@ public function handleGetResponsePromiseA(RequestEvent $event)
5757
*/
5858
public function handleGetResponsePromiseB(RequestEvent $event)
5959
{
60-
return (resolve())
60+
return (resolve(null))
6161
->then(function () use ($event) {
6262
$event->setResponse(new Response('B'));
6363
});
@@ -90,7 +90,7 @@ public function handleGetExceptionNothing(ExceptionEvent $event)
9090
*/
9191
public function handleGetExceptionA(ExceptionEvent $event)
9292
{
93-
return (resolve())
93+
return (resolve(null))
9494
->then(function () use ($event) {
9595
$event->setResponse(new Response('EXC', 404));
9696
});
@@ -106,7 +106,7 @@ public function handleGetExceptionA(ExceptionEvent $event)
106106
public function handleGetResponsePromise1(RequestEvent $event): PromiseInterface
107107
{
108108
return
109-
(resolve())
109+
(resolve(null))
110110
->then(function () {
111111
$_GET['partial'] .= '1';
112112
});

Tests/Services/AFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(LoopInterface $loop)
4141
*/
4242
public static function createAFulfilledClass(): PromiseInterface
4343
{
44-
return (resolve())
44+
return (resolve(null))
4545
->then(function () {
4646
return new AClass();
4747
});
@@ -52,7 +52,7 @@ public static function createAFulfilledClass(): PromiseInterface
5252
*/
5353
public static function createARejectedClass(): PromiseInterface
5454
{
55-
return (resolve())
55+
return (resolve(null))
5656
->then(function () {
5757
throw new \Exception();
5858
});

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"symfony/event-dispatcher-contracts": "^2.0",
1919
"symfony/http-foundation": "^5.0",
2020
"symfony/routing": "^5.0",
21-
"react/promise": "^2.7",
21+
"react/promise": "^3",
2222
"react/http": "^1.0",
2323
"clue/block-react": "^1.3"
2424
},
@@ -29,9 +29,6 @@
2929
"symfony/yaml": "^5.0",
3030
"symfony/console": "^5.0"
3131
},
32-
"suggest": {
33-
"react/filesystem": "*"
34-
},
3532
"autoload": {
3633
"psr-4": {
3734
"Drift\\HttpKernel\\": ""

0 commit comments

Comments
 (0)