From e063efcdf5223ffd21820be918704509a9351f0d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 29 Aug 2023 15:28:35 +0200 Subject: [PATCH] Add cs rules --- examples/reqwest/.gitignore | 1 + examples/reqwest/.php-cs-fixer.dist.php | 23 +++++++++++++++++++++++ examples/reqwest/composer.json | 6 ++++++ examples/reqwest/lib/Client.php | 8 ++++---- examples/reqwest/test.php | 7 ++++--- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 examples/reqwest/.gitignore create mode 100644 examples/reqwest/.php-cs-fixer.dist.php diff --git a/examples/reqwest/.gitignore b/examples/reqwest/.gitignore new file mode 100644 index 0000000..3d0b430 --- /dev/null +++ b/examples/reqwest/.gitignore @@ -0,0 +1 @@ +.php_cs.cache diff --git a/examples/reqwest/.php-cs-fixer.dist.php b/examples/reqwest/.php-cs-fixer.dist.php new file mode 100644 index 0000000..c75730e --- /dev/null +++ b/examples/reqwest/.php-cs-fixer.dist.php @@ -0,0 +1,23 @@ + 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; diff --git a/examples/reqwest/composer.json b/examples/reqwest/composer.json index 1e4fcba..01bfb7a 100644 --- a/examples/reqwest/composer.json +++ b/examples/reqwest/composer.json @@ -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" } } diff --git a/examples/reqwest/lib/Client.php b/examples/reqwest/lib/Client.php index 41f90c2..7bb429e 100644 --- a/examples/reqwest/lib/Client.php +++ b/examples/reqwest/lib/Client.php @@ -1,4 +1,4 @@ - \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 diff --git a/examples/reqwest/test.php b/examples/reqwest/test.php index 8710379..6e840f1 100644 --- a/examples/reqwest/test.php +++ b/examples/reqwest/test.php @@ -1,4 +1,4 @@ -