Skip to content

Commit d3b6650

Browse files
committed
Support Laravel 12
Supersedes #361
1 parent 934aed9 commit d3b6650

File tree

8 files changed

+22
-26
lines changed

8 files changed

+22
-26
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ on:
55

66
jobs:
77
tests:
8-
runs-on: ${{ matrix.os }}
8+
runs-on: ubuntu-latest
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [ubuntu-latest]
13-
php: [8.0, 8.1, 8.2, 8.3]
12+
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
1413
dependency-versions: [lowest, highest]
1514

16-
name: Tests - P${{ matrix.php }} - ${{ matrix.dependency-versions }} - ${{ matrix.os }}
15+
name: Tests - PHP ${{ matrix.php }} - ${{ matrix.dependency-versions }}
1716

1817
steps:
1918
- uses: actions/checkout@v4
@@ -41,10 +40,10 @@ jobs:
4140
strategy:
4241
fail-fast: false
4342
matrix:
44-
php: [8.0, 8.1, 8.2, 8.3]
43+
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
4544
dependency-versions: [lowest, highest]
4645

47-
name: Static Analysis - P${{ matrix.php }} - ${{ matrix.dependency-versions }}
46+
name: Static Analysis - PHP ${{ matrix.php }} - ${{ matrix.dependency-versions }}
4847

4948
steps:
5049
- uses: actions/checkout@v4

.php-cs-fixer.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
<?php declare(strict_types=1);
22

3-
use function MLL\PhpCsFixerConfig\risky;
4-
53
$finder = PhpCsFixer\Finder::create()
64
->in(__DIR__)
75
->name('*.php')
86
->notPath('vendor')
97
->notPath('tests/Enums/Annotate') // Generated
108
->notPath('tests/Enums/AnnotateFixtures') // Matches laminas/laminas-code
11-
->notPath('tests/Enums/ToNative') // Generated
12-
->notPath('tests/Enums/ToNativeFixtures') // Matches laminas/laminas-code
139
->ignoreDotFiles(false)
1410
->ignoreVCS(true);
1511

16-
return risky($finder);
12+
return MLL\PhpCsFixerConfig\risky($finder);

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ it: fix stan test docs ## Run the commonly used targets
33

44
.PHONY: help
55
help: ## Displays this list of targets with descriptions
6-
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
6+
@grep --extended-regexp '^[a-zA-Z0-9_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
77

88
.PHONY: fix
99
fix: vendor ## Apply automatic code fixes

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@
2626
"require": {
2727
"php": "^8",
2828
"composer/class-map-generator": "^1",
29-
"illuminate/contracts": "^9 || ^10 || ^11",
30-
"illuminate/support": "^9 || ^10 || ^11",
29+
"illuminate/contracts": "^9 || ^10 || ^11 || ^12",
30+
"illuminate/support": "^9 || ^10 || ^11 || ^12",
3131
"laminas/laminas-code": "^3.4 || ^4",
3232
"nikic/php-parser": "^4.13.2 || ^5"
3333
},
3434
"require-dev": {
3535
"doctrine/dbal": "^3.4",
3636
"ergebnis/composer-normalize": "^2.28.3",
37-
"larastan/larastan": "^2.6.3",
37+
"larastan/larastan": "^2.6.3 || ^3",
3838
"mll-lab/php-cs-fixer-config": "^5.4",
3939
"mockery/mockery": "^1.5",
40-
"orchestra/testbench": "^7.6.1 || ^8 || ^9",
40+
"orchestra/testbench": "^7.6.1 || ^8 || ^9 || ^10",
4141
"phpstan/extension-installer": "^1",
42-
"phpstan/phpstan": "^1.8.2",
43-
"phpstan/phpstan-mockery": "^1.1",
44-
"phpstan/phpstan-phpunit": "^1.1.1",
45-
"phpunit/phpunit": "^9.5.21 || ^10 || ^11",
46-
"rector/rector": "^1",
42+
"phpstan/phpstan": "^1.8.2 || ^2",
43+
"phpstan/phpstan-mockery": "^1.1 || ^2",
44+
"phpstan/phpstan-phpunit": "^1.1.1 || ^2",
45+
"phpunit/phpunit": "^9.5.21 || ^10 || ^11 || ^12",
46+
"rector/rector": "^1 || ^2",
4747
"symplify/rule-doc-generator": "^11 || ^12 || ^13"
4848
},
4949
"minimum-stability": "dev",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
checkOctaneCompatibility: true
99
reportUnmatchedIgnoredErrors: false # As long as we support multiple Laravel versions at once, there will be some dead spots
1010
treatPhpDocTypesAsCertain: false
11+
noEnvCallsOutsideOfConfig: false
1112
ignoreErrors:
1213
- '#Unsafe usage of new static.*#' # This is a library, so it should be extendable
1314
# The Process API is only available in newer Laravel versions
@@ -16,7 +17,6 @@ parameters:
1617
- '#invalid type Illuminate\\Process#'
1718
- '#^Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist\.$#' # Only available with newer PHPUnit versions
1819
excludePaths:
19-
- tests/Enums/ToNativeFixtures # Fails with PHP < 8.1
2020
- tests/PHPStan/Fixtures
2121
# Install https://plugins.jetbrains.com/plugin/7677-awesome-console to make those links clickable
2222
editorUrl: '%%relFile%%:%%line%%'

src/Enum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static function fromValue(mixed $enumValue): static
8585
return $enumValue;
8686
}
8787

88-
return new static($enumValue);
88+
return new static($enumValue); // @phpstan-ignore return.type (generic variance)
8989
}
9090

9191
/**

src/PHPStan/UniqueValuesRule.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ public function processNode(Node $node, Scope $scope): array
3535
foreach ($constants as $name => $value) {
3636
$constantsWithValue = array_filter($constants, fn (mixed $v): bool => $v === $value);
3737
if (count($constantsWithValue) > 1) {
38-
$duplicateConstants[] = array_keys($constantsWithValue);
38+
$duplicateConstants[] = json_encode(array_keys($constantsWithValue));
3939
}
4040
}
4141
$duplicateConstants = array_unique($duplicateConstants);
4242

4343
if (count($duplicateConstants) > 0) {
4444
$fqcn = $reflection->getName();
45-
$constantsString = json_encode($duplicateConstants);
45+
$constantsString = implode(',', $duplicateConstants);
4646

4747
return [
4848
RuleErrorBuilder::message("Enum class {$fqcn} contains constants with duplicate values: {$constantsString}.")
49+
->identifier('enum.duplicateValues')
4950
->build(),
5051
];
5152
}

tests/PHPStan/UniqueValuesRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testRule(): void
2222
],
2323
[
2424
[
25-
'Enum class BenSampo\Enum\Tests\PHPStan\Fixtures\DuplicateValue contains constants with duplicate values: [["A","B"]].',
25+
'Enum class BenSampo\Enum\Tests\PHPStan\Fixtures\DuplicateValue contains constants with duplicate values: ["A","B"].',
2626
13,
2727
],
2828
],

0 commit comments

Comments
 (0)