From b43eebab0a8576e72d03df00c78b435db1876e49 Mon Sep 17 00:00:00 2001 From: Ssionn Date: Wed, 27 Aug 2025 03:39:35 +0200 Subject: [PATCH 1/2] Added PHPCS --- .github/workflows/qol.yml | 17 +++++++++++++++++ .gitignore | 2 ++ .php-cs-fixer.dist.php | 20 ++++++++++++++++++++ composer.json | 8 +++++++- src/GithubClient.php | 4 +++- src/GithubForgeServiceProvider.php | 2 +- src/Traits/ApiActionTrait.php | 4 ++-- 7 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/qol.yml create mode 100644 .php-cs-fixer.dist.php diff --git a/.github/workflows/qol.yml b/.github/workflows/qol.yml new file mode 100644 index 0000000..0b1b85b --- /dev/null +++ b/.github/workflows/qol.yml @@ -0,0 +1,17 @@ +jobs: + phpcs: + runs-on: ubuntu-latest + steps: + - name: Checkout code + - uses: actions/checkout@v5 + + - name: Set up PHP + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + + - name: Install dependencies + - run: composer install + + - name: Run PHP CodeSniffer + - run: composer cs diff --git a/.gitignore b/.gitignore index 32399c1..bdf1e67 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ composer.lock .env /phpunit.xml /.env +.php-cs-fixer.php +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..3c052ce --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,20 @@ +setRiskyAllowed(false) + ->setParallelConfig( + ParallelConfigFactory::detect() + ) + ->setRules([ + '@PSR12' => true, + ]) + ->setFinder( + (new Finder()) + ->in(__DIR__) + ->exclude('vendor') + ->name('*.php') + ); diff --git a/composer.json b/composer.json index b460217..1950629 100644 --- a/composer.json +++ b/composer.json @@ -43,11 +43,17 @@ "phpstan/phpstan": "^2.1", "pestphp/pest": "^3.8", "orchestra/testbench": "^10.4", - "pestphp/pest-plugin-laravel": "^3.2" + "pestphp/pest-plugin-laravel": "^3.2", + "friendsofphp/php-cs-fixer": "^3.86" }, "config": { "allow-plugins": { "pestphp/pest-plugin": true } + }, + "scripts": { + "test": "vendor/bin/pest", + "cs": "vendor/bin/php-cs-fixer check", + "cs:fix": "vendor/bin/php-cs-fixer fix" } } diff --git a/src/GithubClient.php b/src/GithubClient.php index 90cdba2..1cb8b83 100644 --- a/src/GithubClient.php +++ b/src/GithubClient.php @@ -16,7 +16,9 @@ class GithubClient implements GithubClientInterface { use ApiActionTrait; - public function __construct(protected string $token) {} + public function __construct(protected string $token) + { + } /** * Get a user's profile by username. diff --git a/src/GithubForgeServiceProvider.php b/src/GithubForgeServiceProvider.php index 7e2f7c1..0aa6147 100644 --- a/src/GithubForgeServiceProvider.php +++ b/src/GithubForgeServiceProvider.php @@ -16,7 +16,7 @@ public function register(): void $this->app->singleton( 'github-forge', - fn($app) => new GithubClient( + fn ($app) => new GithubClient( $app['config']->get('github-forge.token') ) ); diff --git a/src/Traits/ApiActionTrait.php b/src/Traits/ApiActionTrait.php index 504e0de..d730570 100644 --- a/src/Traits/ApiActionTrait.php +++ b/src/Traits/ApiActionTrait.php @@ -49,9 +49,9 @@ public function getResponse(string $route = '', array $queryParams = [], array $ * @return Collection * @throws ConnectionException */ - public function getPaginatedResponse(string $route = '', array $queryParams = [], array $headers = []): Collection + public function getPaginatedResponse(string $route = '', array $queryParams = [], array $headers = []): Collection { - $results = new Collection; + $results = new Collection(); $page = 1; do { From 100c51742368a11a12f79c963ffcb576b461dcc8 Mon Sep 17 00:00:00 2001 From: Ssionn Date: Wed, 27 Aug 2025 03:49:30 +0200 Subject: [PATCH 2/2] Fix attempt #1 --- .github/workflows/qol.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/qol.yml b/.github/workflows/qol.yml index 0b1b85b..ad847a5 100644 --- a/.github/workflows/qol.yml +++ b/.github/workflows/qol.yml @@ -1,9 +1,10 @@ jobs: phpcs: + name: PHP CodeSniffer runs-on: ubuntu-latest steps: - name: Checkout code - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 - name: Set up PHP - uses: shivammathur/setup-php@v2