Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump dependencies: drop Laravel 10 and PHP 8.1 support #388

Merged
merged 41 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2c00c0a
Normalize composer.json
alies-dev Feb 2, 2025
aa5afa0
Fix typo
alies-dev Feb 2, 2025
c87f160
Bump dependencies: drop Laravel 10 support
alies-dev Feb 2, 2025
5e0c2ca
Improve DX with Laravel project test
alies-dev Feb 2, 2025
291c928
Fix composer version pattern
alies-dev Feb 2, 2025
abf9a0d
Fix indentation in xml
alies-dev Feb 2, 2025
42b2a78
Improve DX with Laravel project test
alies-dev Feb 2, 2025
9f5e514
Use Generator in a type test
alies-dev Feb 2, 2025
0a593bf
Simplify debugging: support failOnError config value
alies-dev Feb 2, 2025
b5cc6cd
Provide better type info for make()
alies-dev Feb 2, 2025
cde58ef
Fix xsi:schemaLocation
alies-dev Feb 2, 2025
44c088f
Fix type issues, update baseline
alies-dev Feb 2, 2025
f6d1b30
Rename failOnError to failOnInternalError
alies-dev Feb 2, 2025
7c19648
Fix coding style issues
alies-dev Feb 3, 2025
3a59342
Use real factory to fix GeneratorCommand
alies-dev Feb 6, 2025
b56090e
Add PHPDoc
alies-dev Feb 6, 2025
478ea07
Prevent Laravel's exception handler from interfering with Psalm's ana…
alies-dev Feb 15, 2025
7c2cfaf
Install fresh PHP 8.3 on CI
alies-dev Feb 15, 2025
e6af8bb
Ignore ClassMustBeFinal: it requires a major release
alies-dev Feb 15, 2025
801629e
Support Model::$factory static property (for HasFactory)
alies-dev Feb 15, 2025
417c03e
Support Model::$factory static property (for HasFactory) [p.2]
alies-dev Feb 15, 2025
0d16e4f
Fix ModelRelationshipPropertyHandler::relationExists to check relatio…
alies-dev Feb 16, 2025
fd5e70e
Limit handler's scope on factory type only (ModelFactoryTypeProvider)
alies-dev Feb 16, 2025
9986b3c
Add missing import
alies-dev Feb 16, 2025
49d6405
Remove outdated test_factory test
alies-dev Feb 16, 2025
7a9d4e6
Register ide-helper views path
alies-dev Feb 16, 2025
ec53403
Update ModelFactoryTypeProvider to properly support Model::$factory
alies-dev Feb 16, 2025
c05f4b7
Register 'ide-helper' view namespace manually
alies-dev Feb 16, 2025
aa1d8d0
Register IdeHelperServiceProvider directly instead of as deferred
alies-dev Feb 16, 2025
3600d4f
Lock barryvdh/laravel-ide-helper to make package more stable
alies-dev Feb 16, 2025
23f0107
Allow patch version installations barryvdh/laravel-ide-helper
alies-dev Feb 16, 2025
111e553
Update symfony components to use 7.1
alies-dev Feb 16, 2025
d66777d
Cleanuo PHPUnit output
alies-dev Feb 16, 2025
f9933d8
Update Psalm baseline
alies-dev Feb 16, 2025
82e0e37
Fix file ext from .feature to .phpt
alies-dev Feb 16, 2025
649a0df
Do not run tests over Laravel older 11.35
alies-dev Feb 16, 2025
d34ed7b
Hide deprecation notes for --prefer-lowest
alies-dev Feb 16, 2025
ef45e5b
Move error_reporting to a correct job and step
alies-dev Feb 16, 2025
d788c17
Improve readability
alies-dev Feb 16, 2025
25ae14e
Do not run tests over lowest dependencies
alies-dev Feb 16, 2025
e3b9e78
Revert PHPUnit settings
alies-dev Feb 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/test-laravel.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test laravel projects
name: Test Laravel app

on:
push:
Expand All @@ -19,13 +19,22 @@ on:
jobs:
build:
runs-on: ubuntu-latest

name: Test Laravel
name: Test Laravel app

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test Laravel
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

- name: Build a Laravel project and run Psalm on it
run: |
./tests/Application/laravel-test.sh

- run: |
echo "Psalm analysis failed on a fresh Laravel project. Please consider updating baseline: tests/Application/laravel-test-baseline.xml"
if: ${{ failure() }}
15 changes: 6 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
paths:
- '**.php'
- '**.stubphp'
- '**.feature'
- '**.phpt'
- '**.yml'
- 'composer.json'
- '.github/workflows/test.yml'
pull_request:
paths:
- '**.php'
- '**.stubphp'
- '**.feature'
- '**.phpt'
- 'composer.json'
- '.github/workflows/test.yml'
schedule:
Expand Down Expand Up @@ -51,13 +51,10 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.4, 8.3, 8.2, 8.1]
laravel: [^11.0, ^10.0]
dependencies: [lowest, highest]
exclude:
- php: 8.1
laravel: ^11.0
name: Type P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
php: [8.4, 8.3, 8.2]
laravel: [^11.35]
dependencies: [highest]
name: Type test P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
50 changes: 26 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@
],
"homepage": "https://github.com/psalm/psalm-plugin-laravel",
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-simplexml": "*",
"barryvdh/laravel-ide-helper": "^2.13 || ^3.0",
"illuminate/config": "^10.48 || ^11.0",
"illuminate/container": "^10.48 || ^11.0",
"illuminate/contracts": "^10.48 || ^11.0",
"illuminate/database": "^10.48 || ^11.0",
"illuminate/events": "^10.48 || ^11.0",
"illuminate/http": "^10.48 || ^11.0",
"illuminate/routing": "^10.48 || ^11.0",
"illuminate/support": "^10.48 || ^11.0",
"illuminate/view": "^10.48 || ^11.0",
"nikic/php-parser": "^4.18 || ^5.0",
"orchestra/testbench-core": "^8.22 || ^9.0",
"symfony/console": "^6.0 || ^7.0",
"symfony/finder": "^6.0 || ^7.0",
"vimeo/psalm": "^5.20|^6"
"barryvdh/laravel-ide-helper": "~3.5.4",
"illuminate/config": "^11.35",
"illuminate/container": "^11.35",
"illuminate/contracts": "^11.35",
"illuminate/database": "^11.35",
"illuminate/events": "^11.35",
"illuminate/http": "^11.35",
"illuminate/routing": "^11.35",
"illuminate/support": "^11.35",
"illuminate/view": "^11.35",
"nikic/php-parser": "^5.0",
"orchestra/testbench-core": "^9.9",
"symfony/console": "^7.1",
"symfony/finder": "^7.1",
"vimeo/psalm": "^5.26 || ^6.0"
},
"require-dev": {
"laravel/framework": "^10.48 || ^11.0",
"phpunit/phpunit": "^10.5 || ^11.0",
"laravel/framework": "^11.35",
"phpunit/phpunit": "^10.5 || ^11.5",
"phpyh/psalm-tester": "^0.1.0",
"ramsey/collection": "^1.3",
"rector/rector": "^1.0",
"slevomat/coding-standard": "^8.8",
"squizlabs/php_codesniffer": "*",
"symfony/http-foundation": "^6.0 || ^7.0"
"rector/rector": "^2.0",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.11",
"symfony/http-foundation": "^7.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down Expand Up @@ -68,14 +68,16 @@
"lint-fix": "phpcbf -n",
"psalm": "psalm --find-dead-code --find-unused-psalm-suppress --long-progress",
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
"rector": "./vendor/bin/rector",
"rector:dry": "./vendor/bin/rector --dry-run",
"test": [
"@lint",
"@psalm",
"@test:unit",
"@test:type"
],
"test:app": "./tests/Application/laravel-test.sh",
"test:type": "phpunit --testsuite=type",
"test:unit": "phpunit --testsuite=unit",
"rector": "./vendor/bin/rector --dry-run"
"test:unit": "phpunit --testsuite=unit"
}
}
40 changes: 20 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="type">
<directory>tests/Type</directory>
</testsuite>
</testsuites>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="type">
<directory>tests/Type</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
54 changes: 25 additions & 29 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,63 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
<file src="src/Handlers/Application/ContainerHandler.php">
<MixedArgument>
<code>$abstract</code>
</MixedArgument>
</file>
<files psalm-version="6.6.0@07e9a53713232e924da9acb4a6e47507461cd411">
<file src="src/Handlers/Auth/AuthConfigAnalyzer.php">
<MixedArgument>
<code><![CDATA[$this->config->get('auth.guards')]]></code>
</MixedArgument>
<MixedInferredReturnType>
<code>?string</code>
<code><![CDATA[class-string<\Illuminate\Contracts\Auth\Authenticatable>|null]]></code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code><![CDATA[$this->config->get("auth.providers.{$provider}.model", null)]]></code>
<code><![CDATA[$this->config->get('auth.defaults.guard')]]></code>
</MixedReturnStatement>
</file>
<file src="src/Handlers/Auth/AuthHandler.php">
<TypeDoesNotContainType>
<code>null</code>
<code><![CDATA[null]]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Handlers/Auth/GuardHandler.php">
<DeprecatedProperty>
<code><![CDATA[$previous_call->name->parts]]></code>
</DeprecatedProperty>
</file>
<file src="src/Handlers/Eloquent/ModelPropertyAccessorHandler.php">
<ArgumentTypeCoercion>
<code><![CDATA[$event->getFqClasslikeName()]]></code>
<code><![CDATA[$event->getFqClasslikeName()]]></code>
<code><![CDATA[$event->getFqClasslikeName()]]></code>
</ArgumentTypeCoercion>
<LessSpecificImplementedReturnType>
<code>array</code>
<code>array</code>
<code>array</code>
<code><![CDATA[array]]></code>
<code><![CDATA[array]]></code>
<code><![CDATA[array]]></code>
</LessSpecificImplementedReturnType>
</file>
<file src="src/Handlers/Eloquent/Schema/SchemaAggregator.php">
<DeprecatedProperty>
<code><![CDATA[$first_argument_of_nullable->value->name->parts]]></code>
</DeprecatedProperty>
</file>
<file src="src/Handlers/Helpers/PathHandler.php">
<InternalMethod>
<code>new TLiteralString($result)</code>
<code><![CDATA[new TLiteralString($result)]]></code>
</InternalMethod>
</file>
<file src="src/Plugin.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/**/*.stubphp')]]></code>
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/*.stubphp')]]></code>
<code><![CDATA[glob(dirname(__DIR__) . '/stubs/common/TaintAnalysis/Http/*.stubphp')]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Providers/ApplicationProvider.php">
<InternalMethod>
<code><![CDATA[createApplication]]></code>
</InternalMethod>
<InternalMethod>
<code><![CDATA[createApplication]]></code>
</InternalMethod>
<MixedArgument>
<code><![CDATA[$app['events']]]></code>
<code><![CDATA[$app['events']]]></code>
</MixedArgument>
<MixedMethodCall>
<code><![CDATA[addNamespace]]></code>
<code><![CDATA[bootstrap]]></code>
</MixedMethodCall>
</file>
<file src="src/Util/ContainerResolver.php">
<InternalMethod>
<code>new TLiteralString($concrete)</code>
<code><![CDATA[new TLiteralString($concrete)]]></code>
</InternalMethod>
</file>
</files>
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="false"
Expand All @@ -19,5 +19,6 @@

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />
<ClassMustBeFinal errorLevel="info" />
</issueHandlers>
</psalm>
8 changes: 1 addition & 7 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\Config\RectorConfig;
Expand All @@ -11,24 +10,19 @@
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector;
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;

return RectorConfig::configure()
->withPaths(['src', 'tests'])
->withPhpSets(php81: true)
->withPhpSets(php82: true)
->withPreparedSets(deadCode: true, codingStyle: true, typeDeclarations: true)
->withSkip([
ReadOnlyPropertyRector::class,
ClosureToArrowFunctionRector::class,
FirstClassCallableRector::class,
NullToStrictStringFuncCallArgRector::class,
BooleanInIfConditionRuleFixerRector::class,
BooleanInBooleanNotRuleFixerRector::class,
RemoveUnusedPrivateMethodRector::class,
SimplifyUselessVariableRector::class,
NullableCompareToNullRector::class,
EncapsedStringsToSprintfRector::class,
StaticClosureRector::class,
SplitDoubleAssignRector::class,
]);
9 changes: 9 additions & 0 deletions src/Exceptions/UnknownApplicationConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Psalm\LaravelPlugin\Exceptions;

final class UnknownApplicationConfiguration extends \LogicException
{
}
11 changes: 8 additions & 3 deletions src/Fakes/FakeModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ class FakeModelsCommand extends ModelsCommand
/** @var list<class-string<\Illuminate\Database\Eloquent\Model>> */
private array $model_classes = [];

public function __construct(Filesystem $files, private SchemaAggregator $schema)
private SchemaAggregator $schema;

/**
* While the setter of a required property is an anti-pattern,
* this is the only way to be less independent of changes in the parent ModelsCommand constructor.
*/
public function setSchemaAggregator(SchemaAggregator $schemaAggregator): void
{
parent::__construct($files);
$this->schema = $schemaAggregator;
}

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

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

Expand Down
Loading