Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BedrockStreaming/Tornado
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0
Choose a base ref
...
head repository: BedrockStreaming/Tornado
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Mar 12, 2021

  1. Copy the full SHA
    aa15c30 View commit details

Commits on Mar 16, 2021

  1. Copy the full SHA
    3e92fb8 View commit details

Commits on Mar 17, 2021

  1. Copy the full SHA
    5069d42 View commit details
  2. Copy the full SHA
    f0ac54a View commit details

Commits on Mar 18, 2021

  1. Merge pull request #42 from M6Web/fix/amp-writabel-stream

    (test) Update amp test because of a library change
    valentin-claras authored Mar 18, 2021
    Copy the full SHA
    e9bf5e7 View commit details

Commits on Apr 19, 2021

  1. fix(examples): Incomplete namespace in examples

    Benoit Viguier committed Apr 19, 2021
    Copy the full SHA
    9d9c10c View commit details
  2. fix(CI): case issue in folder name

    Benoit Viguier committed Apr 19, 2021
    Copy the full SHA
    86ce24b View commit details

Commits on Apr 21, 2021

  1. Merge pull request #44 from M6Web/fix/ci-examples

    Fixed CI: examples are not tested
    b-viguier authored Apr 21, 2021
    Copy the full SHA
    373a145 View commit details

Commits on Apr 24, 2021

  1. feat(CI): remove PrettyCI

    Benoit Viguier authored and matyo91 committed Apr 24, 2021
    Copy the full SHA
    4214f75 View commit details
  2. feat(CI): add GH action for code style

    Benoit Viguier authored and matyo91 committed Apr 24, 2021
    Copy the full SHA
    10dafbe View commit details
  3. 👷 update github CI

    matyo91 committed Apr 24, 2021
    Copy the full SHA
    619cfc1 View commit details
  4. ➖ remove travis CI

    matyo91 committed Apr 24, 2021
    Copy the full SHA
    5536ea7 View commit details

Commits on Sep 1, 2021

  1. Merge pull request #45 from matyo91/feature/gh-actions

    Replace PrettyCI by GH-actions
    valentin-claras authored Sep 1, 2021
    Copy the full SHA
    71849ca View commit details
  2. Copy the full SHA
    b190dda View commit details
  3. Merge pull request #47 from BedrockStreaming/feat/phpstan-update

    feat: update phpstan and fix reported errors
    valentin-claras authored Sep 1, 2021
    Copy the full SHA
    aa078bb View commit details
  4. Copy the full SHA
    9027930 View commit details
  5. Copy the full SHA
    1801080 View commit details
  6. Merge pull request #48 from BedrockStreaming/feat/update-code-style

    Add code style check to the CI
    valentin-claras authored Sep 1, 2021
    Copy the full SHA
    f99d578 View commit details
  7. Copy the full SHA
    4b1835b View commit details
  8. Copy the full SHA
    bb0f4fd View commit details
  9. Copy the full SHA
    ddeb825 View commit details

Commits on Sep 2, 2021

  1. Copy the full SHA
    516c0e5 View commit details
  2. Copy the full SHA
    db42b73 View commit details

Commits on Oct 15, 2021

  1. Merge pull request #41 from BedrockStreaming/feat/php-80

    feat: allow for php version 8
    valentin-claras authored Oct 15, 2021
    Copy the full SHA
    03b5ede View commit details

Commits on Nov 24, 2021

  1. Fix build status badge

    jdecool authored Nov 24, 2021
    Copy the full SHA
    a4f9ea6 View commit details

Commits on Nov 29, 2021

  1. Copy the full SHA
    e77743c View commit details

Commits on Dec 6, 2021

  1. Merge pull request #49 from e-zannelli/feat/typing

    Generic promise
    e-zannelli authored Dec 6, 2021
    Copy the full SHA
    2c207f6 View commit details

Commits on Dec 22, 2021

  1. Merge pull request #50 from jdecool/patch-1

    Fix build status badge
    Oliboy50 authored Dec 22, 2021
    Copy the full SHA
    a9546b7 View commit details
Showing with 299 additions and 252 deletions.
  1. +42 −0 .github/workflows/ci.yml
  2. +2 −1 .gitignore
  3. +15 −0 .php-cs-fixer.dist.php
  4. +0 −11 .php_cs
  5. +0 −5 .prettyci.composer.json
  6. +0 −16 .travis.yml
  7. +1 −1 README.md
  8. +8 −7 composer.json
  9. +3 −1 examples/00-README-samples.php
  10. +3 −1 examples/01-async-countdown.php
  11. +3 −1 examples/02-failures.php
  12. +3 −1 examples/03-http-client.php
  13. +3 −1 examples/04-foreach.php
  14. +2 −2 examples/tests/ExamplesTest.php
  15. +24 −0 phpstan.neon
  16. +20 −24 phpunit.xml.dist
  17. +2 −6 src/Adapter/Amp/Internal/Deferred.php
  18. +3 −5 src/Adapter/Amp/Internal/PromiseWrapper.php
  19. +2 −6 src/Adapter/Guzzle/CurlMultiClientWrapper.php
  20. +5 −7 src/Adapter/Guzzle/HttpClient.php
  21. +1 −1 src/Adapter/ReactPhp/EventLoop.php
  22. +2 −6 src/Adapter/ReactPhp/Internal/Deferred.php
  23. +3 −5 src/Adapter/ReactPhp/Internal/PromiseWrapper.php
  24. +1 −1 src/Adapter/Symfony/HttpClient.php
  25. +2 −0 src/Adapter/Tornado/EventLoop.php
  26. +7 −3 src/Adapter/Tornado/Internal/PendingPromise.php
  27. +12 −9 src/Adapter/Tornado/Internal/StreamEventLoop.php
  28. +2 −0 src/Adapter/Tornado/Internal/Task.php
  29. +4 −5 src/Adapter/Tornado/SynchronousEventLoop.php
  30. +2 −0 src/Deferred.php
  31. +32 −3 src/EventLoop.php
  32. +3 −0 src/HttpClient.php
  33. +3 −0 src/Promise.php
  34. +1 −1 tests/Adapter/Amp/EventLoopTest.php
  35. +2 −11 tests/Adapter/Guzzle/GuzzleMockWrapper.php
  36. +2 −2 tests/Adapter/Guzzle/HttpClientTest.php
  37. +7 −7 tests/Adapter/Tornado/SynchronousEventLoopTest.php
  38. +11 −9 tests/EventLoopTest.php
  39. +17 −12 tests/EventLoopTest/AsyncTest.php
  40. +7 −5 tests/EventLoopTest/PromiseAllTest.php
  41. +14 −8 tests/EventLoopTest/PromiseForeachTest.php
  42. +6 −4 tests/EventLoopTest/PromiseRaceTest.php
  43. +2 −52 tests/EventLoopTest/StreamsTest.php
  44. +15 −12 tests/HttpClientTest.php
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Code Quality

on:
push:
branches:
- master
pull_request:

jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest

strategy:
matrix:
php: [ '7.3', '7.4', '8.0' ]

steps:
- name: 'Init repository'
uses: actions/checkout@v2

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, swoole
tools: composer

- name: "Install dependencies"
run: composer install

- name: 'Tests unit'
run: composer tests-unit

- name: 'Tests examples'
run: composer tests-examples

- name: 'Static analysis'
run: composer static-analysis

- name: 'Code style check'
run: composer code-style-check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bin/
/vendor/
/composer.lock
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create();
$finder->in(
[
__DIR__.'/src',
__DIR__.'/tests',
__DIR__.'/examples',
]
);

$config = new M6Web\CS\Config\BedrockStreaming();
$config->setFinder($finder);

return $config;
11 changes: 0 additions & 11 deletions .php_cs

This file was deleted.

5 changes: 0 additions & 5 deletions .prettyci.composer.json

This file was deleted.

16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tornado 🌪🐎
<img src="assets/Tornado-Logo.png?raw=true" width="250" align="right" alt="Tornado Logo">

[![Build Status](https://travis-ci.com/M6Web/Tornado.svg?branch=master)](https://travis-ci.com/M6Web/Tornado)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FBedrockStreaming%2FTornado%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/BedrockStreaming/Tornado/goto?ref=master)

A library for asynchronous programming in [Php](https://secure.php.net/).

15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -7,30 +7,31 @@
{
"name": "M6Web",
"email": "opensource@m6web.fr",
"homepage": "http://tech.m6web.fr/"
"homepage": "https://tech.bedrockstreaming.com"
}
],
"autoload": {
"psr-4": {"M6Web\\Tornado\\": "src/"}
},
"autoload-dev": {
"psr-4": {
"M6WebTest\\Tornado\\": "tests/"
"M6WebTest\\Tornado\\": "tests/",
"M6WebExamples\\Tornado\\": "examples/"
}
},
"require": {
"php": "^7.1",
"php": "^7.3|^8.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.3",
"phpunit/phpunit": "^9.4.4",
"amphp/amp": "^2.0",
"guzzlehttp/guzzle": "^6.3",
"m6web/php-cs-fixer-config": "^1.0",
"ext-curl": "^7.1",
"m6web/php-cs-fixer-config": "^2.0",
"ext-curl": "^7.3|^8.0",
"react/event-loop": "^1.0",
"react/promise": "^2.7",
"phpstan/phpstan": "^0.10.5",
"phpstan/phpstan": "^0.12",
"symfony/http-client": "^4.3",
"psr/http-factory": "^1.0",
"http-interop/http-factory-guzzle": "^1.0"
4 changes: 3 additions & 1 deletion examples/00-README-samples.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

namespace M6WebExamples\Tornado;

require __DIR__.'/../vendor/autoload.php';

use GuzzleHttp\Psr7;
@@ -98,7 +100,7 @@ function waitException(Tornado\EventLoop $eventLoop)
$eventLoop = new Tornado\Adapter\Tornado\EventLoop();
//$eventLoop = new Tornado\Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Tornado\Adapter\Amp\EventLoop();
//$eventLoop = new Tornado\Adapter\ReactPhp\EventLoop(new React\EventLoop\StreamSelectLoop());
//$eventLoop = new Tornado\Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());

// Tornado provides only one HttpClient implementation, using Guzzle
$httpClient = new Tornado\Adapter\Guzzle\HttpClient($eventLoop, new Tornado\Adapter\Guzzle\CurlMultiClientWrapper());
4 changes: 3 additions & 1 deletion examples/01-async-countdown.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

namespace M6WebExamples\Tornado;

require __DIR__.'/../vendor/autoload.php';

use M6Web\Tornado\Adapter;
@@ -24,7 +26,7 @@ function asynchronousCountdown(EventLoop $eventLoop, string $name, int $count):
$eventLoop = new Adapter\Tornado\EventLoop();
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new React\EventLoop\StreamSelectLoop());
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());

echo "Let's start!\n";

4 changes: 3 additions & 1 deletion examples/02-failures.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

namespace M6WebExamples\Tornado;

require __DIR__.'/../vendor/autoload.php';

use M6Web\Tornado\Adapter;
@@ -16,7 +18,7 @@ function throwingGenerator(): \Generator
$eventLoop = new Adapter\Tornado\EventLoop();
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new React\EventLoop\StreamSelectLoop());
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());

echo "Let's start!\n";

4 changes: 3 additions & 1 deletion examples/03-http-client.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

namespace M6WebExamples\Tornado;

require __DIR__.'/../vendor/autoload.php';

use M6Web\Tornado\Adapter;
@@ -24,7 +26,7 @@ function monitorRequest(EventLoop $eventLoop, HttpClient $httpClient, string $ur
$eventLoop = new Adapter\Tornado\EventLoop();
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new React\EventLoop\StreamSelectLoop());
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());

// Choose your adapter
$httpClient = new Adapter\Symfony\HttpClient(new \Symfony\Component\HttpClient\CurlHttpClient(), $eventLoop, new \Http\Factory\Guzzle\ResponseFactory(), new \Http\Factory\Guzzle\StreamFactory());
4 changes: 3 additions & 1 deletion examples/04-foreach.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

namespace M6WebExamples\Tornado;

require __DIR__.'/../vendor/autoload.php';

use M6Web\Tornado\Adapter;
@@ -67,7 +69,7 @@ function compareMethods(EventLoop $eventLoop)
$eventLoop = new Adapter\Tornado\EventLoop();
//$eventLoop = new Adapter\Tornado\SynchronousEventLoop();
//$eventLoop = new Adapter\Amp\EventLoop();
//$eventLoop = new Adapter\ReactPhp\EventLoop(new React\EventLoop\StreamSelectLoop());
//$eventLoop = new Adapter\ReactPhp\EventLoop(new \React\EventLoop\StreamSelectLoop());

echo "Let's start!\n";
// Run the event loop until our goal promise is reached.
4 changes: 2 additions & 2 deletions examples/tests/ExamplesTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace M6WebExamplesTest\Tornado;
namespace M6WebExamplesTests\Tornado;

use PHPUnit\Framework\TestCase;

@@ -29,7 +29,7 @@ public function examplesProvider()
/**
* @dataProvider examplesProvider
*/
public function testExampleShouldRun(string $exampleFile, string $eventloopName, string $exampleCode)
public function testExampleShouldRun(string $exampleFile, string $eventloopName, string $exampleCode): void
{
// Sanitize loop name to create a relevant temporary filename
$eventLoopFileId = preg_replace('/[^a-z0-9]+/', '', strtolower($eventloopName));
24 changes: 24 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
-
message: '#Negated boolean expression is always true\.#'
path: src/Adapter/Amp/Internal/PromiseWrapper.php
count: 1
-
message: '#Negated boolean expression is always true\.#'
path: src/Adapter/ReactPhp/Internal/PromiseWrapper.php
count: 1
-
message: '#Anonymous function should return Generator but empty return statement found.#'
path: src/Adapter/Tornado/EventLoop.php
count: 1
-
message: '#Unreachable statement - code above always terminates\.#'
path: src/Adapter/Tornado/EventLoop.php
count: 1
-
message: '#Unreachable statement - code above always terminates\.#'
path: tests/EventLoopTest.php
count: 3
44 changes: 20 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<!-- define your env variables for the test env here -->
</php>

<listeners>
<listener class="M6WebTest\Tornado\Adapter\Amp\LoopReset" />
</listeners>

<testsuites>
<testsuite name="Tornado Test Suite">
<directory>tests</directory>
</testsuite>
<testsuite name="Tornado Examples">
<directory>examples/tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<php>
<!-- define your env variables for the test env here -->
</php>
<listeners>
<listener class="M6WebTest\Tornado\Adapter\Amp\LoopReset"/>
</listeners>
<testsuites>
<testsuite name="Tornado Test Suite">
<directory>tests</directory>
</testsuite>
<testsuite name="Tornado Examples">
<directory>examples/tests</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 2 additions & 6 deletions src/Adapter/Amp/Internal/Deferred.php
Original file line number Diff line number Diff line change
@@ -10,14 +10,10 @@
*/
class Deferred implements \M6Web\Tornado\Deferred
{
/**
* @var \Amp\Deferred
*/
/** @var \Amp\Deferred */
private $ampDeferred;

/**
* @var PromiseWrapper
*/
/** @var PromiseWrapper */
private $promise;

public function __construct(\Amp\Deferred $ampDeferred, PromiseWrapper $promise)
8 changes: 3 additions & 5 deletions src/Adapter/Amp/Internal/PromiseWrapper.php
Original file line number Diff line number Diff line change
@@ -11,9 +11,7 @@
*/
class PromiseWrapper implements Promise
{
/**
* @var \Amp\Promise
*/
/** @var \Amp\Promise */
private $ampPromise;

/** @var bool */
@@ -26,7 +24,7 @@ private function __construct()
{
}

public static function createUnhandled(\Amp\Promise $ampPromise, FailingPromiseCollection $failingPromiseCollection)
public static function createUnhandled(\Amp\Promise $ampPromise, FailingPromiseCollection $failingPromiseCollection): self
{
$promiseWrapper = new self();
$promiseWrapper->isHandled = false;
@@ -42,7 +40,7 @@ function (?\Throwable $reason, $value) use ($promiseWrapper, $failingPromiseColl
return $promiseWrapper;
}

public static function createHandled(\Amp\Promise $ampPromise)
public static function createHandled(\Amp\Promise $ampPromise): self
{
$promiseWrapper = new self();
$promiseWrapper->isHandled = true;
8 changes: 2 additions & 6 deletions src/Adapter/Guzzle/CurlMultiClientWrapper.php
Original file line number Diff line number Diff line change
@@ -4,14 +4,10 @@

final class CurlMultiClientWrapper implements GuzzleClientWrapper
{
/**
* @var \GuzzleHttp\Handler\CurlMultiHandler
*/
/** @var \GuzzleHttp\Handler\CurlMultiHandler */
private $curlMultiHandler;

/**
* @var \GuzzleHttp\Client
*/
/** @var \GuzzleHttp\Client */
private $guzzleClient;

/**
Loading