Skip to content

Commit

Permalink
Apply rector and php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Sep 6, 2023
1 parent 43ecad3 commit 9ac69a3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
use Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
Expand Down Expand Up @@ -39,6 +40,7 @@
]);
$rectorConfig->skip([
__DIR__ . '/tests/database/migrations', // Does not fit autoloading standards
__DIR__ . '/tests/LaravelPhpdocAlignmentFixer.php', // Copied from Laravel
CallableThisArrayToAnonymousFunctionRector::class, // Callable in array form is shorter and more efficient
IssetOnPropertyObjectToPropertyExistsRector::class, // isset() is nice when moving towards typed properties
FlipTypeControlToUseExclusiveTypeRector::class, // Unnecessarily complex with PHPStan
Expand All @@ -54,6 +56,9 @@
GetClassToInstanceOfRector::class => [
__DIR__ . '/src/Schema/Types/Scalars/DateScalar.php', // We need to compare exact classes, not subclasses
],
MakeInheritedMethodVisibilitySameAsParentRector::class => [
__DIR__ . '/tests/Unit/Execution/ResolveInfoTest.php', // Makes method public on purpose
],
ExplicitBoolCompareRector::class, // if($truthy) is fine and very readable
EncapsedStringsToSprintfRector::class, // unreadable, slow, error prone
VarConstantCommentRector::class, // Noisy
Expand Down
2 changes: 1 addition & 1 deletion src/Console/FieldGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class FieldGeneratorCommand extends LighthouseGeneratorCommand

protected function getStub(): string
{
if (version_compare(PHP_VERSION, '8.2.0', '>=')) {
if (PHP_VERSION_ID >= 80200) {
return $this->option('full')
? __DIR__ . '/stubs/field_full.php82.stub'
: __DIR__ . '/stubs/field_simple.php82.stub';
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Responses/ResponseStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
class ResponseStream extends Stream implements CanStreamResponse
{
protected const EOL = "\r\n";

protected const BOUNDARY = self::EOL . '---' . self::EOL;

protected const TERMINATING_BOUNDARY = self::EOL . '-----' . self::EOL;

public function stream(array $data, array $paths, bool $isFinalChunk): void
Expand Down
12 changes: 6 additions & 6 deletions tests/Integration/Pennant/FeatureDirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testUnavailableWhenFeatureIsInactiveWithDefaultFeatureState(): v

public function testUnavailableWhenFeatureIsActive(): void
{
Feature::define('new-api', fn (): bool => true);
Feature::define('new-api', static fn (): bool => true);
$this->schema = /* @lang GraphQL */ <<<'GRAPHQL'
type Query {
fieldWhenInactive: String!
Expand All @@ -103,9 +103,9 @@ public function testUnavailableWhenFeatureIsActive(): void

public function testAvailableWhenFeatureIsActive(): void
{
Feature::define('new-api', fn (): bool => true);
Feature::define('new-api', static fn (): bool => true);
$fieldValue = 'active';
$this->mockResolver(fn (): string => $fieldValue);
$this->mockResolver(static fn (): string => $fieldValue);
$this->schema = /* @lang GraphQL */ <<<'GRAPHQL'
type Query {
fieldWhenActive: String!
Expand All @@ -131,9 +131,9 @@ public function testAvailableWhenFeatureIsActive(): void

public function testAvailableWhenFeatureIsActiveWithDefaultFeatureState(): void
{
Feature::define('new-api', fn (): bool => true);
Feature::define('new-api', static fn (): bool => true);
$fieldValue = 'active';
$this->mockResolver(fn (): string => $fieldValue);
$this->mockResolver(static fn (): string => $fieldValue);
$this->schema = /* @lang GraphQL */ <<<'GRAPHQL'
type Query {
fieldWhenActive: String!
Expand All @@ -160,7 +160,7 @@ public function testAvailableWhenFeatureIsActiveWithDefaultFeatureState(): void
public function testAvailableWhenFeatureIsInactive(): void
{
$fieldValue = 'inactive';
$this->mockResolver(fn (): string => $fieldValue);
$this->mockResolver(static fn (): string => $fieldValue);
$this->schema = /* @lang GraphQL */ <<<'GRAPHQL'
type Query {
fieldWhenInactive: String!
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Nuwave\Lighthouse\LighthouseServiceProvider;
use Nuwave\Lighthouse\OrderBy\OrderByServiceProvider;
use Nuwave\Lighthouse\Pagination\PaginationServiceProvider;
use Nuwave\Lighthouse\Pennant\PennantServiceProvider as LighthousePennantServiceProvider;
use Nuwave\Lighthouse\Schema\SchemaBuilder;
use Nuwave\Lighthouse\Scout\ScoutServiceProvider as LighthouseScoutServiceProvider;
use Nuwave\Lighthouse\SoftDeletes\SoftDeletesServiceProvider;
Expand Down
2 changes: 1 addition & 1 deletion tests/Utils/Models/User/UserBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class UserBuilder extends Builder
/** @param array{company: string} $args */
public function companyName(array $args): self
{
return $this->where(fn (self $builder) => $builder
return $this->where(static fn (self $builder): \Tests\Utils\Models\User\UserBuilder => $builder
->whereHas('company', static fn (EloquentBuilder $q): EloquentBuilder => $q
->where('name', $args['company'])));
}
Expand Down

0 comments on commit 9ac69a3

Please sign in to comment.