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/.github/workflows/static.yml b/.github/workflows/static.yml
index 0cb958d..3a8db18 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -9,4 +9,4 @@ jobs:
name: Static analysis
uses: monicahq/workflows/.github/workflows/static.yml@v2
with:
- php-version: 8.2
+ php-version: 8.3
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 88ef9d6..c88b67d 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -26,11 +26,11 @@ jobs:
name: Run tests
uses: monicahq/workflows/.github/workflows/library.yml@v2
with:
- php-versions: "['8.0', '8.1', '8.2', '8.3']"
- laravel-versions: "['8.*', '9.*', '10.*', '11.*']"
- default-php-version: '8.2'
- default-laravel-version: '10.*'
- matrix-exclude: "[{'php-version': '8.0', 'laravel-version': '10.*'},{'php-version': '8.0', 'laravel-version': '11.*'},{'php-version': '8.1', 'laravel-version': '11.*'}]"
+ php-versions: "['8.1', '8.2', '8.3']"
+ laravel-versions: "['^9.0', '^10.0', '^11.0']"
+ default-php-version: '8.3'
+ default-laravel-version: '^11.0'
+ matrix-exclude: "[{'php-version': '8.1', 'laravel-version': '^11.0'}]"
project: monicahq_laravel-cloudflare
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
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/psalm.xml b/psalm.xml
index 5106cb4..4c78738 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -4,6 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
+ findUnusedBaselineEntry="true"
+ findUnusedCode="false"
>
@@ -13,41 +15,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
+
diff --git a/src/CloudflareProxies.php b/src/CloudflareProxies.php
index 81c8b72..fb94fa6 100644
--- a/src/CloudflareProxies.php
+++ b/src/CloudflareProxies.php
@@ -10,33 +10,34 @@
class CloudflareProxies
{
+ /**
+ * Use IPv4 addresses.
+ *
+ * @var int
+ */
public const IP_VERSION_4 = 1 << 0;
- public const IP_VERSION_6 = 1 << 1;
-
- public const IP_VERSION_ANY = self::IP_VERSION_4 | self::IP_VERSION_6;
-
/**
- * The config repository instance.
+ * Use IPv6 addresses.
*
- * @var Repository
+ * @var int
*/
- protected $config;
+ public const IP_VERSION_6 = 1 << 1;
/**
- * The http factory instance.
+ * Use any IP addresses.
*
- * @var HttpClient
+ * @var int
*/
- protected $http;
+ public const IP_VERSION_ANY = self::IP_VERSION_4 | self::IP_VERSION_6;
/**
* 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;
}
}