Skip to content

Commit

Permalink
Add laravel 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Mar 3, 2024
1 parent 4f6661a commit 3211723
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: PHP CS check

on:
push:
branches: [master]
paths:
- '**.php'
- 'composer.json'
Expand All @@ -23,7 +24,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none
tools: cs2pr

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Psalm

on:
push:
branches: [master]
paths:
- '**.php'
- 'psalm*'
Expand All @@ -12,6 +13,7 @@ on:
- '**.php'
- 'psalm*'
- 'composer.json'
- '.github/workflows/psalm.yml'

jobs:
psalm:
Expand All @@ -23,7 +25,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: 8.2
coverage: none

- name: Install composer dependencies
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Test laravel projects

on:
push:
branches: [master]
paths:
- '**.php'
- '**.stubphp'
Expand All @@ -13,8 +14,10 @@ on:
paths:
- '**.php'
- '**.stubphp'
- 'composer.json'
- 'tests/laravel*'
- 'tests/lumen*'
- '.github/workflows/test-laravel.yml'

jobs:
build:
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Tests
on:
workflow_dispatch:
push:
branches: [master]
paths:
- '**.php'
- '**.stubphp'
Expand All @@ -16,6 +17,7 @@ on:
- '**.stubphp'
- '**.feature'
- 'composer.json'
- '.github/workflows/test.yml'
schedule:
- cron: "0 6 * * *"

Expand All @@ -31,7 +33,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.2
coverage: none
tools: composer:v2

Expand All @@ -51,11 +53,13 @@ jobs:
fail-fast: true
matrix:
php: [8.3, 8.2, 8.0]
laravel: [^10.0, ^9.0]
laravel: [^11.0, ^10.0, ^9.0]
dependencies: [lowest, highest]
exclude:
- php: 8.0
laravel: ^10.0
- php: 8.0
laravel: ^11.0
name: Acceptance P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
steps:
- name: Checkout code
Expand All @@ -69,13 +73,10 @@ jobs:
coverage: none
tools: composer

- name: Install lowest dependencies from composer.json
if: "matrix.dependencies == 'lowest'"
run: composer update --with='laravel/framework:${{ matrix.laravel }}' --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest

- name: Install highest dependencies from composer.json
if: "matrix.dependencies == 'highest'"
run: composer update --with='laravel/framework:${{ matrix.laravel }}' --no-interaction --no-progress --prefer-dist --prefer-stable
- name: Install dependencies from composer.json
run: |
composer require "illuminate/support:${{ matrix.laravel }}" --no-update
composer update --no-interaction --no-progress --prefer-dist --prefer-stable ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }}
- name: Run Acceptance Tests
run: composer test:type
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"require": {
"php": "^8.0.2",
"ext-simplexml": "*",
"barryvdh/laravel-ide-helper": "^2.13",
"illuminate/config": "^9.48 || ^10.0",
"illuminate/container": "^9.48 || ^10.0",
"illuminate/contracts": "^9.48 || ^10.0",
"illuminate/database": "^9.48 || ^10.0",
"illuminate/events": "^9.48 || ^10.0",
"illuminate/http": "^9.48 || ^10.0",
"illuminate/routing": "^9.48 || ^10.0",
"illuminate/support": "^9.48 || ^10.0",
"illuminate/view": "^9.48 || ^10.0",
"barryvdh/laravel-ide-helper": "^2.13 || ^3.0",
"illuminate/config": "^9.48 || ^10.0 || ^11.0",
"illuminate/container": "^9.48 || ^10.0 || ^11.0",
"illuminate/contracts": "^9.48 || ^10.0 || ^11.0",
"illuminate/database": "^9.48 || ^10.0 || ^11.0",
"illuminate/events": "^9.48 || ^10.0 || ^11.0",
"illuminate/http": "^9.48 || ^10.0 || ^11.0",
"illuminate/routing": "^9.48 || ^10.0 || ^11.0",
"illuminate/support": "^9.48 || ^10.0 || ^11.0",
"illuminate/view": "^9.48 || ^10.0 || ^11.0",
"nikic/php-parser": "^4.13",
"orchestra/testbench": "^7.19 || ^8.0",
"symfony/console": "^6.0",
"orchestra/testbench": "^7.19 || ^8.0 || ^9.0",
"symfony/console": "^6.0 || ^7.0",
"vimeo/psalm": "^4.30 || ^5.1"
},
"require-dev": {
Expand All @@ -38,7 +38,7 @@
"ramsey/collection": "^1.3",
"slevomat/coding-standard": "^8.8",
"squizlabs/php_codesniffer": "*",
"symfony/http-foundation": "^6.0"
"symfony/http-foundation": "^6.0 || ^7.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion src/Fakes/FakeFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class FakeFilesystem extends Filesystem
*/
public function put($path, $contents, $lock = false)
{
$destination = $this->destination ?: $path;
$destination = $this->destination !== null ? $this->destination : $path;

$this->destination = null;

Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/Eloquent/ModelMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event)
if ($event->getMethodNameLowercase() === '__callstatic') {
$called_method_name_lowercase = $event->getCalledMethodNameLowercase();

if (!$called_method_name_lowercase) {
if ($called_method_name_lowercase === null) {
return null;
}
$methodId = new MethodIdentifier($called_fq_classlike_name, $called_method_name_lowercase);
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/Eloquent/Schema/SchemaColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public function __construct(
$this->name = $name;
$this->type = $type;
$this->nullable = $nullable;
$this->options = $options ?: [];
$this->options = $options !== null ? $options : [];
}
}
2 changes: 1 addition & 1 deletion src/Providers/ViewFactoryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function get(): Factory

$file_path = $service_helper_reflection->getFileName();

if (!$file_path) {
if ($file_path === false) {
throw new UnexpectedValueException('Service helper should have a file path');
}

Expand Down
19 changes: 17 additions & 2 deletions tests/Acceptance/acceptance/FoundationHelpers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,30 @@ Feature: Foundation helpers
When I run Psalm
Then I see no errors

Scenario: app() support: env can be pulled off the app
Scenario: app() support: env can be pulled off the app [ Psalm <5.20 ]
Given I have the following code
"""
if (app()->environment('production')) {
// do something
}
"""
And I have Psalm older than "5.20.0" (because of "changed issue type")
When I run Psalm
Then I see no errors

Scenario: app() support: env can be pulled off the app [ Psalm >5.20 ]
Given I have the following code
"""
if (app()->environment('production')) {
// do something
}
"""
And I have Psalm newer than "5.20.0" (because of "changed issue type")
When I run Psalm
Then I see these errors
| Type | Message |
| RiskyTruthyFalsyComparison | Operand of type bool\|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. |

Scenario: auth() support
Given I have the following code
"""
Expand Down Expand Up @@ -187,14 +201,15 @@ Feature: Foundation helpers
When I run Psalm
Then I see no errors

Scenario: precognitive() support
Scenario: precognitive() support [ Psalm 5 ]
Given I have the following code
"""
$payload = precognitive(function () {
return ['foo' => 'bar'];
});
/** @psalm-check-type $payload = array{'foo': 'bar'} */
"""
And I have Psalm newer than "5.0" (because of "new psalm-check-type syntax")
When I run Psalm
Then I see no errors

Expand Down
6 changes: 4 additions & 2 deletions tests/Acceptance/acceptance/PathHelpers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ Feature: Path helpers
| Type | Message |
| MissingFile | Cannot find file |

Scenario: public path can be resolved from application instance
Scenario: public path can be resolved from application instance [ Psalm 5 ]
Given I have the following code
"""
/** @psalm-check-type $path = string */
$path = app()->make('path.public');
"""
And I have Psalm newer than "5.0" (because of "new psalm-check-type syntax")
When I run Psalm
Then I see no errors

Expand Down Expand Up @@ -150,11 +151,12 @@ Feature: Path helpers
| Type | Message |
| MissingFile | Cannot find file |

Scenario: storage path can be resolved from application instance
Scenario: storage path can be resolved from application instance [ Psalm 5 ]
Given I have the following code
"""
/** @psalm-check-type $path = string */
$path = app()->make('path.storage');
"""
And I have Psalm newer than "5.0" (because of "new psalm-check-type syntax")
When I run Psalm
Then I see no errors
5 changes: 5 additions & 0 deletions tests/Application/laravel-test-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
<code>ExampleProvider</code>
</UnusedClass>
</file>
<file src="app/Providers/RouteServiceProvider.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$request->user()?->id]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="app/Rules/ExampleRule.php">
<UnusedClass>
<code>ExampleRule</code>
Expand Down
3 changes: 3 additions & 0 deletions tests/Application/lumen-test-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<code>User</code>
<code>User</code>
</PropertyNotSetInConstructor>
<NonInvariantDocblockPropertyType>
<code>$fillable</code>
</NonInvariantDocblockPropertyType>
</file>
<file src="app/Providers/AuthServiceProvider.php">
<MissingClosureParamType>
Expand Down

0 comments on commit 3211723

Please sign in to comment.