diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8edd0ed..1c0670e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,21 +6,9 @@ updates: directory: "/" schedule: interval: weekly - time: "11:00" - labels: - - actions - - dependencies - - auto-squash # Maintain dependencies for Composer - package-ecosystem: composer directory: "/" schedule: interval: weekly - time: "07:00" - open-pull-requests-limit: 10 - versioning-strategy: lockfile-only - labels: - - php - - dependencies - - auto-squash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..42d8394 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,14 @@ +name: Lint files + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: Lint files ${{ github.ref }} + cancel-in-progress: true + +jobs: + php: + name: Lint PHP files + uses: monicahq/workflows/.github/workflows/lint_php.yml@v2 diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 6a678b7..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,3 +0,0 @@ -preset: laravel -enabled: - - fully_qualified_strict_types \ No newline at end of file diff --git a/composer.json b/composer.json index d3c8280..d57cfd2 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,10 @@ }, "require-dev": { "guzzlehttp/guzzle": "^6.3 || ^7.0", - "mockery/mockery": "^1.4", + "jschaedl/composer-git-hooks": "^4.0", "larastan/larastan": "^1.0 || ^2.4", + "laravel/pint": "^1.15", + "mockery/mockery": "^1.4", "ocramius/package-versions": "^1.5 || ^2.1", "orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0", "phpstan/phpstan-deprecation-rules": "^1.0", @@ -50,8 +52,23 @@ "providers": [ "Monicahq\\Cloudflare\\TrustedProxyServiceProvider" ] + }, + "hooks": { + "config": { + "stop-on-failure": [ + "pre-commit" + ] + }, + "pre-commit": [ + "files=$(git diff --staged --name-only);\"$(dirname \"$0\")/../../vendor/bin/pint\" $files; git add $files" + ] } }, + "scripts": { + "cghooks": "vendor/bin/cghooks", + "post-install-cmd": "cghooks add --ignore-lock", + "post-update-cmd": "cghooks update" + }, "suggest": { "guzzlehttp/guzzle": "Required to get cloudflares ip addresses (^6.5.5|^7.0)." }, diff --git a/src/CloudflareProxies.php b/src/CloudflareProxies.php index 81c8b72..8fa34d7 100644 --- a/src/CloudflareProxies.php +++ b/src/CloudflareProxies.php @@ -16,27 +16,13 @@ class CloudflareProxies public const IP_VERSION_ANY = self::IP_VERSION_4 | self::IP_VERSION_6; - /** - * The config repository instance. - * - * @var Repository - */ - protected $config; - - /** - * The http factory instance. - * - * @var HttpClient - */ - protected $http; - /** * Create a new instance of CloudflareProxies. */ - public function __construct(Repository $config, HttpClient $http) - { - $this->config = $config; - $this->http = $http; + public function __construct( + protected Repository $config, + protected HttpClient $http + ) { } /** diff --git a/src/LaravelCloudflare.php b/src/LaravelCloudflare.php index 97b7ad0..73c4e26 100644 --- a/src/LaravelCloudflare.php +++ b/src/LaravelCloudflare.php @@ -19,8 +19,8 @@ final class LaravelCloudflare */ public static function getProxies(): array { - if (static::$getProxiesCallback !== null) { - return call_user_func(static::$getProxiesCallback); + if (self::$getProxiesCallback !== null) { + return call_user_func(self::$getProxiesCallback); } return CloudflareProxies::load(); @@ -31,6 +31,6 @@ public static function getProxies(): array */ public static function getProxiesUsing(?Closure $callback): void { - static::$getProxiesCallback = $callback; + self::$getProxiesCallback = $callback; } } diff --git a/tests/Unit/Http/Middleware/TrustProxiesTest.php b/tests/Unit/Http/Middleware/TrustProxiesTest.php index 092b20f..ecc8f6d 100644 --- a/tests/Unit/Http/Middleware/TrustProxiesTest.php +++ b/tests/Unit/Http/Middleware/TrustProxiesTest.php @@ -4,7 +4,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Route; use Monicahq\Cloudflare\Http\Middleware\TrustProxies; use Monicahq\Cloudflare\LaravelCloudflare; use Monicahq\Cloudflare\Tests\FeatureTestCase;