mirror of
https://github.com/danog/php-tokio.git
synced 2024-11-26 12:24:58 +01:00
Add cs rules
This commit is contained in:
parent
87186112b7
commit
e063efcdf5
1
examples/reqwest/.gitignore
vendored
Normal file
1
examples/reqwest/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.php_cs.cache
|
23
examples/reqwest/.php-cs-fixer.dist.php
Normal file
23
examples/reqwest/.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$config = new class extends Amp\CodeStyle\Config {
|
||||
public function getRules(): array
|
||||
{
|
||||
return array_merge(parent::getRules(), [
|
||||
'void_return' => true,
|
||||
'array_indentation' => true,
|
||||
'ternary_to_null_coalescing' => true,
|
||||
'assign_null_coalescing_to_coalesce_equal' => true,
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
$config->getFinder()
|
||||
->in(__DIR__ . '/lib')
|
||||
->append([__DIR__ . '/test.php']);
|
||||
|
||||
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
|
||||
|
||||
$config->setCacheFile($cacheDir . '/.php_cs.cache');
|
||||
|
||||
return $config;
|
@ -3,9 +3,15 @@
|
||||
"revolt/event-loop": "^1.0",
|
||||
"amphp/amp": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/php-cs-fixer-config": "v2.x-dev"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Reqwest\\": "lib"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v --diff"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Reqwest;
|
||||
|
||||
@ -14,9 +14,9 @@ final class Client
|
||||
return;
|
||||
}
|
||||
|
||||
$f = fopen("php://fd/" . \Client::init(), "r+");
|
||||
stream_set_blocking($f, false);
|
||||
self::$id = EventLoop::onReadable($f, fn() => \Client::wakeup());
|
||||
$f = \fopen("php://fd/".\Client::init(), 'r+');
|
||||
\stream_set_blocking($f, false);
|
||||
self::$id = EventLoop::onReadable($f, fn () => \Client::wakeup());
|
||||
}
|
||||
|
||||
public static function reference(): void
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use Reqwest\Client;
|
||||
|
||||
@ -9,7 +9,8 @@ require 'vendor/autoload.php';
|
||||
|
||||
Client::init();
|
||||
|
||||
function test(int $delay): void {
|
||||
function test(int $delay): void
|
||||
{
|
||||
$url = "https://httpbin.org/delay/$delay";
|
||||
$t = time();
|
||||
echo "Making async reqwest to $url that will return after $delay seconds...".PHP_EOL;
|
||||
@ -23,4 +24,4 @@ $futures []= async(test(...), 5);
|
||||
$futures []= async(test(...), 5);
|
||||
$futures []= async(test(...), 5);
|
||||
|
||||
await($futures);
|
||||
await($futures);
|
||||
|
Loading…
Reference in New Issue
Block a user