Skip to content

Commit

Permalink
Merge pull request spatie#199 from shuvroroy/patch-1
Browse files Browse the repository at this point in the history
Migrate to PHP-CS-Fixer 3.x
  • Loading branch information
freekmurze authored Jun 4, 2021
2 parents db2f33b + 0686f4e commit 9f17f02
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist --allow-risky=yes
args: --config=.php-cs-fixer.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
.php_cs
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
build
composer.lock
Expand Down
8 changes: 4 additions & 4 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
->ignoreDotFiles(true)
->ignoreVCS(true);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
Expand All @@ -31,7 +31,7 @@
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method',
'method' => 'one'
],
],
'method_argument_space' => [
Expand Down
2 changes: 2 additions & 0 deletions src/Watchers/ApplicationLogWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public function register(): void
case 'alert':
case 'emergency':
$ray->color('red');

break;
case 'warning':
$ray->color('orange');

break;
}
});
Expand Down
10 changes: 6 additions & 4 deletions src/Watchers/HttpClientWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

namespace Spatie\LaravelRay\Watchers;


use Illuminate\Http\Client\Events\RequestSending;
use Illuminate\Http\Client\Events\ResponseReceived;
use Illuminate\Http\Client\Request;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Event;
use Spatie\Ray\Payloads\TablePayload;
use Spatie\LaravelRay\Ray;
use Spatie\Ray\Payloads\TablePayload;
use Spatie\Ray\Settings\Settings;
use SplObjectStorage;

Expand Down Expand Up @@ -93,7 +92,9 @@ protected function handleResponse(Request $request, Response $response)
'Success' => $response->successful(),
'Status' => $response->status(),
'Headers' => $response->headers(),
'Body' => rescue(function() use ($response) { return $response->json(); }, $response->body(), false),
'Body' => rescue(function () use ($response) {
return $response->json();
}, $response->body(), false),
'Cookies' => $response->cookies(),
'Duration' => $this->calculateResponseTime($request),
], 'Http');
Expand All @@ -112,7 +113,8 @@ protected function calculateResponseTime(Request $request)
return $timing;
}

public static function supportedByLaravelVersion() {
public static function supportedByLaravelVersion()
{
return version_compare(app()->version(), '8.45.0', '>=');
}
}
4 changes: 1 addition & 3 deletions tests/Unit/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Spatie\LaravelRay\Tests\Unit;


use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Http;
use Spatie\LaravelRay\Tests\TestCase;
Expand All @@ -23,7 +22,7 @@ public function setUp(): void
[
'*/ok*' => Http::response(['hello' => 'world'], 200, ['Content-Type' => 'application/json']),
'*/not-found*' => Http::response(null, 404),
'*/json*' => Http::response(['foo' => 'bar'])
'*/json*' => Http::response(['foo' => 'bar']),
]
);
}
Expand Down Expand Up @@ -83,5 +82,4 @@ public function show_http_client_can_be_colorized()
$this->assertEquals($sentPayloads[0]['uuid'], $sentPayloads[1]['uuid']);
$this->assertNotEquals('fakeUuid', $sentPayloads[0]['uuid']);
}

}

0 comments on commit 9f17f02

Please sign in to comment.