Skip to content

Commit

Permalink
[3.x] Adds type checking (#1272)
Browse files Browse the repository at this point in the history
* Adds type checking

* Apply fixes from StyleCI

* Fixes tests

* Update .gitattributes

* Update static-analysis.yml

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
nunomaduro and StyleCIBot authored Feb 23, 2023
1 parent 4e0e034 commit 026882b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
.gitignore export-ignore
.styleci.yml export-ignore
CHANGELOG.md export-ignore
phpstan.neon.dist export-ignore
phpunit.xml.dist export-ignore
UPGRADE.md export-ignore
41 changes: 41 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: static analysis

on:
push:
branches:
- master
- '*.x'
pull_request:

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-22.04

strategy:
fail-fast: true

name: Static Analysis

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute type checking
run: vendor/bin/phpstan
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
"require-dev": {
"inertiajs/inertia-laravel": "^0.6.5",
"laravel/sanctum": "^3.0",
"livewire/livewire": "^2.12",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^7.0|^8.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.3"
},
"conflict": {
Expand Down
11 changes: 11 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
paths:
- config
- database
- routes
- src

level: 0

ignoreErrors:
- "#Unsafe usage of new static\\(\\)#"
4 changes: 4 additions & 0 deletions src/JetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ public function boot()
$this->configureCommands();

RedirectResponse::macro('banner', function ($message) {
/** @var \Illuminate\Http\RedirectResponse $this */

return $this->with('flash', [
'bannerStyle' => 'success',
'banner' => $message,
]);
});

RedirectResponse::macro('dangerBanner', function ($message) {
/** @var \Illuminate\Http\RedirectResponse $this */

return $this->with('flash', [
'bannerStyle' => 'danger',
'banner' => $message,
Expand Down
7 changes: 6 additions & 1 deletion tests/OrchestraTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\Fortify\FortifyServiceProvider;
use Laravel\Jetstream\Features;
use Laravel\Jetstream\JetstreamServiceProvider;
use Livewire\LivewireServiceProvider;
use Mockery;
use Orchestra\Testbench\TestCase;

Expand All @@ -22,7 +23,11 @@ public function tearDown(): void

protected function getPackageProviders($app)
{
return [JetstreamServiceProvider::class, FortifyServiceProvider::class];
return [
LivewireServiceProvider::class,
JetstreamServiceProvider::class,
FortifyServiceProvider::class,
];
}

protected function defineEnvironment($app)
Expand Down

0 comments on commit 026882b

Please sign in to comment.