Skip to content

Commit

Permalink
style: add laravel pint (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored May 4, 2024
1 parent 5d18e60 commit 033850b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 69 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 0 additions & 3 deletions .styleci.yml

This file was deleted.

19 changes: 18 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)."
},
Expand Down
46 changes: 16 additions & 30 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<projectFiles>
<directory name="src" />
Expand All @@ -13,41 +15,25 @@
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<file name="src/Commands/Reload.php" />
<file name="src/Commands/View.php" />
</errorLevel>
</PropertyNotSetInConstructor>

<RawObjectIteration errorLevel="info" />
<MissingClosureParamType>
<errorLevel type="suppress">
<file name="src/Commands/View.php" />
</errorLevel>
</MissingClosureParamType>

<UndefinedClass>
<MissingClassConstType>
<errorLevel type="suppress">
<file name="src/Http/Middleware/TrustProxies.php" />
<file name="src/CloudflareProxies.php" />
</errorLevel>
</UndefinedClass>
</MissingClassConstType>

</issueHandlers>
</psalm>
29 changes: 15 additions & 14 deletions src/CloudflareProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/LaravelCloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -31,6 +31,6 @@ public static function getProxies(): array
*/
public static function getProxiesUsing(?Closure $callback): void
{
static::$getProxiesCallback = $callback;
self::$getProxiesCallback = $callback;
}
}

0 comments on commit 033850b

Please sign in to comment.