Skip to content

Commit 6f98635

Browse files
authored
Merge pull request #388 from alies-dev/dump-dependencies
Dump dependencies: drop Laravel 10 and PHP 8.1 support
2 parents fc013ac + e3b9e78 commit 6f98635

27 files changed

+514
-259
lines changed

.github/workflows/test-laravel.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test laravel projects
1+
name: Test Laravel app
22

33
on:
44
push:
@@ -19,13 +19,22 @@ on:
1919
jobs:
2020
build:
2121
runs-on: ubuntu-latest
22-
23-
name: Test Laravel
22+
name: Test Laravel app
2423

2524
steps:
2625
- name: Checkout code
2726
uses: actions/checkout@v4
2827

29-
- name: Test Laravel
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: 8.3
32+
coverage: none
33+
34+
- name: Build a Laravel project and run Psalm on it
3035
run: |
3136
./tests/Application/laravel-test.sh
37+
38+
- run: |
39+
echo "Psalm analysis failed on a fresh Laravel project. Please consider updating baseline: tests/Application/laravel-test-baseline.xml"
40+
if: ${{ failure() }}

.github/workflows/test.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
paths:
77
- '**.php'
88
- '**.stubphp'
9-
- '**.feature'
9+
- '**.phpt'
1010
- '**.yml'
1111
- 'composer.json'
1212
- '.github/workflows/test.yml'
1313
pull_request:
1414
paths:
1515
- '**.php'
1616
- '**.stubphp'
17-
- '**.feature'
17+
- '**.phpt'
1818
- 'composer.json'
1919
- '.github/workflows/test.yml'
2020
schedule:
@@ -51,13 +51,10 @@ jobs:
5151
strategy:
5252
fail-fast: true
5353
matrix:
54-
php: [8.4, 8.3, 8.2, 8.1]
55-
laravel: [^11.0, ^10.0]
56-
dependencies: [lowest, highest]
57-
exclude:
58-
- php: 8.1
59-
laravel: ^11.0
60-
name: Type P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
54+
php: [8.4, 8.3, 8.2]
55+
laravel: [^11.35]
56+
dependencies: [highest]
57+
name: Type test P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
6158
steps:
6259
- name: Checkout code
6360
uses: actions/checkout@v4

composer.json

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@
1111
],
1212
"homepage": "https://github.com/psalm/psalm-plugin-laravel",
1313
"require": {
14-
"php": "^8.1",
14+
"php": "^8.2",
1515
"ext-simplexml": "*",
16-
"barryvdh/laravel-ide-helper": "^2.13 || ^3.0",
17-
"illuminate/config": "^10.48 || ^11.0",
18-
"illuminate/container": "^10.48 || ^11.0",
19-
"illuminate/contracts": "^10.48 || ^11.0",
20-
"illuminate/database": "^10.48 || ^11.0",
21-
"illuminate/events": "^10.48 || ^11.0",
22-
"illuminate/http": "^10.48 || ^11.0",
23-
"illuminate/routing": "^10.48 || ^11.0",
24-
"illuminate/support": "^10.48 || ^11.0",
25-
"illuminate/view": "^10.48 || ^11.0",
26-
"nikic/php-parser": "^4.18 || ^5.0",
27-
"orchestra/testbench-core": "^8.22 || ^9.0",
28-
"symfony/console": "^6.0 || ^7.0",
29-
"symfony/finder": "^6.0 || ^7.0",
30-
"vimeo/psalm": "^5.20|^6"
16+
"barryvdh/laravel-ide-helper": "~3.5.4",
17+
"illuminate/config": "^11.35",
18+
"illuminate/container": "^11.35",
19+
"illuminate/contracts": "^11.35",
20+
"illuminate/database": "^11.35",
21+
"illuminate/events": "^11.35",
22+
"illuminate/http": "^11.35",
23+
"illuminate/routing": "^11.35",
24+
"illuminate/support": "^11.35",
25+
"illuminate/view": "^11.35",
26+
"nikic/php-parser": "^5.0",
27+
"orchestra/testbench-core": "^9.9",
28+
"symfony/console": "^7.1",
29+
"symfony/finder": "^7.1",
30+
"vimeo/psalm": "^5.26 || ^6.0"
3131
},
3232
"require-dev": {
33-
"laravel/framework": "^10.48 || ^11.0",
34-
"phpunit/phpunit": "^10.5 || ^11.0",
33+
"laravel/framework": "^11.35",
34+
"phpunit/phpunit": "^10.5 || ^11.5",
3535
"phpyh/psalm-tester": "^0.1.0",
3636
"ramsey/collection": "^1.3",
37-
"rector/rector": "^1.0",
38-
"slevomat/coding-standard": "^8.8",
39-
"squizlabs/php_codesniffer": "*",
40-
"symfony/http-foundation": "^6.0 || ^7.0"
37+
"rector/rector": "^2.0",
38+
"slevomat/coding-standard": "^8.15",
39+
"squizlabs/php_codesniffer": "^3.11",
40+
"symfony/http-foundation": "^7.1"
4141
},
4242
"minimum-stability": "dev",
4343
"prefer-stable": true,
@@ -68,14 +68,16 @@
6868
"lint-fix": "phpcbf -n",
6969
"psalm": "psalm --find-dead-code --find-unused-psalm-suppress --long-progress",
7070
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
71+
"rector": "./vendor/bin/rector",
72+
"rector:dry": "./vendor/bin/rector --dry-run",
7173
"test": [
7274
"@lint",
7375
"@psalm",
7476
"@test:unit",
7577
"@test:type"
7678
],
79+
"test:app": "./tests/Application/laravel-test.sh",
7780
"test:type": "phpunit --testsuite=type",
78-
"test:unit": "phpunit --testsuite=unit",
79-
"rector": "./vendor/bin/rector --dry-run"
81+
"test:unit": "phpunit --testsuite=unit"
8082
}
8183
}

phpunit.xml.dist

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheDirectory=".phpunit.cache"
6-
executionOrder="depends,defects"
7-
beStrictAboutCoverageMetadata="true"
8-
beStrictAboutOutputDuringTests="true"
9-
failOnRisky="true"
10-
failOnWarning="true">
11-
<testsuites>
12-
<testsuite name="unit">
13-
<directory>tests/Unit</directory>
14-
</testsuite>
15-
<testsuite name="type">
16-
<directory>tests/Type</directory>
17-
</testsuite>
18-
</testsuites>
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
beStrictAboutCoverageMetadata="true"
8+
beStrictAboutOutputDuringTests="true"
9+
failOnRisky="true"
10+
failOnWarning="true">
11+
<testsuites>
12+
<testsuite name="unit">
13+
<directory>tests/Unit</directory>
14+
</testsuite>
15+
<testsuite name="type">
16+
<directory>tests/Type</directory>
17+
</testsuite>
18+
</testsuites>
1919

2020
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
21-
<include>
22-
<directory>src</directory>
23-
</include>
24-
</source>
21+
<include>
22+
<directory>src</directory>
23+
</include>
24+
</source>
2525
</phpunit>

psalm-baseline.xml

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,59 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
3-
<file src="src/Handlers/Application/ContainerHandler.php">
4-
<MixedArgument>
5-
<code>$abstract</code>
6-
</MixedArgument>
7-
</file>
2+
<files psalm-version="6.6.0@07e9a53713232e924da9acb4a6e47507461cd411">
83
<file src="src/Handlers/Auth/AuthConfigAnalyzer.php">
94
<MixedArgument>
105
<code><![CDATA[$this->config->get('auth.guards')]]></code>
116
</MixedArgument>
12-
<MixedInferredReturnType>
13-
<code>?string</code>
14-
<code><![CDATA[class-string<\Illuminate\Contracts\Auth\Authenticatable>|null]]></code>
15-
</MixedInferredReturnType>
167
<MixedReturnStatement>
178
<code><![CDATA[$this->config->get("auth.providers.{$provider}.model", null)]]></code>
189
<code><![CDATA[$this->config->get('auth.defaults.guard')]]></code>
1910
</MixedReturnStatement>
2011
</file>
2112
<file src="src/Handlers/Auth/AuthHandler.php">
2213
<TypeDoesNotContainType>
23-
<code>null</code>
14+
<code><![CDATA[null]]></code>
2415
</TypeDoesNotContainType>
2516
</file>
26-
<file src="src/Handlers/Auth/GuardHandler.php">
27-
<DeprecatedProperty>
28-
<code><![CDATA[$previous_call->name->parts]]></code>
29-
</DeprecatedProperty>
30-
</file>
3117
<file src="src/Handlers/Eloquent/ModelPropertyAccessorHandler.php">
3218
<ArgumentTypeCoercion>
3319
<code><![CDATA[$event->getFqClasslikeName()]]></code>
3420
<code><![CDATA[$event->getFqClasslikeName()]]></code>
3521
<code><![CDATA[$event->getFqClasslikeName()]]></code>
3622
</ArgumentTypeCoercion>
3723
<LessSpecificImplementedReturnType>
38-
<code>array</code>
39-
<code>array</code>
40-
<code>array</code>
24+
<code><![CDATA[array]]></code>
25+
<code><![CDATA[array]]></code>
26+
<code><![CDATA[array]]></code>
4127
</LessSpecificImplementedReturnType>
4228
</file>
43-
<file src="src/Handlers/Eloquent/Schema/SchemaAggregator.php">
44-
<DeprecatedProperty>
45-
<code><![CDATA[$first_argument_of_nullable->value->name->parts]]></code>
46-
</DeprecatedProperty>
47-
</file>
4829
<file src="src/Handlers/Helpers/PathHandler.php">
4930
<InternalMethod>
50-
<code>new TLiteralString($result)</code>
31+
<code><![CDATA[new TLiteralString($result)]]></code>
5132
</InternalMethod>
5233
</file>
34+
<file src="src/Plugin.php">
35+
<RiskyTruthyFalsyComparison>
36+
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/**/*.stubphp')]]></code>
37+
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/*.stubphp')]]></code>
38+
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/common/TaintAnalysis/Http/*.stubphp')]]></code>
39+
</RiskyTruthyFalsyComparison>
40+
</file>
5341
<file src="src/Providers/ApplicationProvider.php">
54-
<InternalMethod>
55-
<code><![CDATA[createApplication]]></code>
56-
</InternalMethod>
42+
<InternalMethod>
43+
<code><![CDATA[createApplication]]></code>
44+
</InternalMethod>
45+
<MixedArgument>
46+
<code><![CDATA[$app['events']]]></code>
47+
<code><![CDATA[$app['events']]]></code>
48+
</MixedArgument>
49+
<MixedMethodCall>
50+
<code><![CDATA[addNamespace]]></code>
51+
<code><![CDATA[bootstrap]]></code>
52+
</MixedMethodCall>
5753
</file>
5854
<file src="src/Util/ContainerResolver.php">
5955
<InternalMethod>
60-
<code>new TLiteralString($concrete)</code>
56+
<code><![CDATA[new TLiteralString($concrete)]]></code>
6157
</InternalMethod>
6258
</file>
6359
</files>

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<psalm
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
5-
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
5+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
66
errorLevel="1"
77
errorBaseline="psalm-baseline.xml"
88
findUnusedBaselineEntry="false"
@@ -19,5 +19,6 @@
1919

2020
<issueHandlers>
2121
<LessSpecificReturnType errorLevel="info" />
22+
<ClassMustBeFinal errorLevel="info" />
2223
</issueHandlers>
2324
</psalm>

rector.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
44
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
5-
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
65
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
76
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
87
use Rector\Config\RectorConfig;
@@ -11,24 +10,19 @@
1110
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
1211
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
1312
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
14-
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
15-
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
1613

1714
return RectorConfig::configure()
1815
->withPaths(['src', 'tests'])
19-
->withPhpSets(php81: true)
16+
->withPhpSets(php82: true)
2017
->withPreparedSets(deadCode: true, codingStyle: true, typeDeclarations: true)
2118
->withSkip([
2219
ReadOnlyPropertyRector::class,
2320
ClosureToArrowFunctionRector::class,
2421
FirstClassCallableRector::class,
2522
NullToStrictStringFuncCallArgRector::class,
26-
BooleanInIfConditionRuleFixerRector::class,
27-
BooleanInBooleanNotRuleFixerRector::class,
2823
RemoveUnusedPrivateMethodRector::class,
2924
SimplifyUselessVariableRector::class,
3025
NullableCompareToNullRector::class,
3126
EncapsedStringsToSprintfRector::class,
32-
StaticClosureRector::class,
3327
SplitDoubleAssignRector::class,
3428
]);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Psalm\LaravelPlugin\Exceptions;
6+
7+
final class UnknownApplicationConfiguration extends \LogicException
8+
{
9+
}

src/Fakes/FakeModelsCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ class FakeModelsCommand extends ModelsCommand
2121
/** @var list<class-string<\Illuminate\Database\Eloquent\Model>> */
2222
private array $model_classes = [];
2323

24-
public function __construct(Filesystem $files, private SchemaAggregator $schema)
24+
private SchemaAggregator $schema;
25+
26+
/**
27+
* While the setter of a required property is an anti-pattern,
28+
* this is the only way to be less independent of changes in the parent ModelsCommand constructor.
29+
*/
30+
public function setSchemaAggregator(SchemaAggregator $schemaAggregator): void
2531
{
26-
parent::__construct($files);
32+
$this->schema = $schemaAggregator;
2733
}
2834

2935
/** @return list<class-string<\Illuminate\Database\Eloquent\Model>> */
@@ -109,7 +115,6 @@ public function getPropertiesFromTable($model): void
109115
}
110116

111117
if ($column->nullable) {
112-
/** @psalm-suppress MixedArrayAssignment */
113118
$this->nullableColumns[$column_name] = true;
114119
}
115120

0 commit comments

Comments
 (0)