Skip to content

Commit

Permalink
Use laravel pint
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrig committed Mar 14, 2024
1 parent 11c8c86 commit 2b8d9e6
Show file tree
Hide file tree
Showing 27 changed files with 95 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
- name: Execute tests
run: |
vendor/bin/phpcs
vendor/bin/pint --test -v
vendor/bin/phpunit
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Laravel pint.

### Changed
- **BREAKING**: Require Laravel 11 and PHP 8.2.

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
},
"require-dev": {
"graham-campbell/testbench": "^6.0",
"laravel/pint": "^1.14",
"mockery/mockery": "^1.4.4",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.6"
"phpunit/phpunit": "^10.0"
},
"suggest": {
"barryvdh/laravel-debugbar": "View debug information in responses."
Expand Down
2 changes: 1 addition & 1 deletion config/butler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'namespace' => env('BUTLER_GRAPHQL_NAMESPACE', 'App\\Http\\Graphql\\'),

'schema' => env('BUTLER_GRAPHQL_SCHEMA', base_path('app/Http/Graphql/schema.graphql')),

'schema_extensions_path' => env('BUTLER_GRAPHQL_SCHEMA_EXTENSIONS_PATH', base_path('app/Http/Graphql/')),
'schema_extensions_glob' => env('BUTLER_GRAPHQL_SCHEMA_EXTENSIONS_GLOB', 'schema-*.graphql'),

Expand Down
18 changes: 0 additions & 18 deletions phpcs.xml

This file was deleted.

15 changes: 15 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"preset": "laravel",
"rules": {
"concat_space": {
"spacing": "one"
},
"no_multiline_whitespace_around_double_arrow": false,
"class_attributes_separation" : {
"elements" : {
"method" : "one",
"trait_import" : "none"
}
}
}
}
1 change: 1 addition & 0 deletions src/Concerns/AssertsPromises.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function assertPromiseFulfills($promise, $expectedValue = null): void

if ($expectedValue instanceof Closure) {
$this->assertTrue($expectedValue($result));

return;
}

Expand Down
16 changes: 9 additions & 7 deletions src/Concerns/HandlesGraphqlRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ trait HandlesGraphqlRequests
/**
* Invoke the Graphql request handler.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function __invoke(Request $request)
Expand Down Expand Up @@ -95,10 +94,10 @@ public function __invoke(Request $request)
public function beforeExecutionHook(
Schema $schema,
DocumentNode $query,
string $operationName = null,
?string $operationName = null,
$variables = null
): void {
return;

}

public function errorFormatter(GraphqlError $graphqlError)
Expand Down Expand Up @@ -201,6 +200,7 @@ public function decorateTypeConfig(array $config, TypeDefinitionNode $typeDefini
if ($this->shouldDecorateWithResolveType($typeDefinitionNode)) {
$config['resolveType'] = [$this, 'resolveType'];
}

return $config;
}

Expand All @@ -219,6 +219,7 @@ public function debugFlags()
if (config('butler.graphql.include_trace')) {
$flags |= DebugFlag::INCLUDE_TRACE;
}

return $flags;
}

Expand Down Expand Up @@ -398,18 +399,19 @@ public function typesNamespace(): string

public function returnTypeIsLeaf(ResolveInfo $info): bool
{
$returnType = $info->returnType instanceof WrappingType
? $info->returnType->getWrappedType(true)
: $info->returnType;
$returnType = $info->returnType instanceof WrappingType
? $info->returnType->getWrappedType(true)
: $info->returnType;

return $returnType instanceof LeafType;
return $returnType instanceof LeafType;
}

public function decorateResponse(array $data): array
{
if (app()->bound('debugbar') && app('debugbar')->isEnabled()) {
$data['debug'] = app('debugbar')->getData();
}

return $data;
}

Expand Down
5 changes: 3 additions & 2 deletions src/DataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private function identifierForClosure(Closure $closure)

private function makeLoader(Closure $batchLoadFunction, $defaultResolveValue)
{
return new class ($batchLoadFunction, $defaultResolveValue)
return new class($batchLoadFunction, $defaultResolveValue)
{
private $batchLoadFunction;
private $defaultResolveValue;
Expand Down Expand Up @@ -94,7 +94,7 @@ private function resolve()
unset($this->deferredPromises[$key]);
}

++$currentIndex;
$currentIndex++;
}

foreach ($this->deferredPromises as $key => [$deferredPromise]) {
Expand All @@ -112,6 +112,7 @@ private static function serializeKey($key)
} elseif (is_array($key)) {
return md5(json_encode($key));
}

return (string) $key;
}
};
Expand Down
9 changes: 7 additions & 2 deletions tests/AssertsPromisesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ public function test_assertPromiseFulfills_fails_on_unexpected_result()
} catch (Exception $exception) {
$this->assertEquals(
"Failed asserting that promise fulfills with a specified value.\n" .
"Failed asserting that 4 is identical to 5.",
'Failed asserting that 4 is identical to 5.',
$exception->getMessage()
);

return;
}

Expand All @@ -84,6 +85,7 @@ public function test_assertPromiseFulfills_handles_exceptions()
'Failed asserting that promise fulfills. Promise was rejected: Provided value not an integer',
$exception->getMessage()
);

return;
}

Expand All @@ -101,6 +103,7 @@ public function test_assertPromiseFulfills_handles_rejected_promise()
'Failed asserting that promise fulfills. Promise was rejected: foo bar',
$exception->getMessage()
);

return;
}

Expand All @@ -109,7 +112,8 @@ public function test_assertPromiseFulfills_handles_rejected_promise()

private function createTestObject(): TestCase
{
return new class extends TestCase {
return new class extends TestCase
{
use AssertsPromises;

private $context;
Expand All @@ -124,6 +128,7 @@ public function square($base): PromiseInterface
return $this->context['loader'](function (array $numbers) {
return collect($numbers)->map(function ($base) {
throw_unless(is_int($base), RuntimeException::class, 'Provided value not an integer');

return pow($base, 2);
});
})->load($base);
Expand Down
Loading

0 comments on commit 2b8d9e6

Please sign in to comment.