Skip to content

Commit fa9760e

Browse files
committed
update: static analyses checks
1 parent 6aac2a4 commit fa9760e

File tree

7 files changed

+40
-10
lines changed

7 files changed

+40
-10
lines changed

Diff for: phpstan.neon.dist

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 4
5+
level: 6
66
paths:
77
- src
88
- config
@@ -11,4 +11,8 @@ parameters:
1111
checkOctaneCompatibility: true
1212
checkModelProperties: true
1313
checkMissingIterableValueType: false
14+
checkGenericClassInNonGenericObjectType: false
15+
ignoreErrors:
16+
- '#Internal error: Internal error: Target class \[laravel-csv\] does not exist.#'
17+
- '#Internal error: Internal error: Target class \[livewire\] does not exist.#'
1418

Diff for: src/Http/Livewire/HandleImports.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use function Coderflex\LaravelCsv\csv_view_path;
66
use Coderflex\LaravelCsv\Models\Import;
7+
use Illuminate\Database\Eloquent\Collection;
8+
use Illuminate\Contracts\View\View;
9+
use Illuminate\Contracts\View\Factory;
710
use Livewire\Component;
811

912
class HandleImports extends Component
@@ -16,12 +19,12 @@ class HandleImports extends Component
1619
'imports.refresh' => '$refresh',
1720
];
1821

19-
public function mount(string $model)
22+
public function mount(string $model): void
2023
{
2124
$this->model = $model;
2225
}
2326

24-
public function getImportsProperty()
27+
public function getImportsProperty(): Collection
2528
{
2629
/** @var \Illuminate\Foundation\Auth\User */
2730
$user = auth()->user();
@@ -34,7 +37,7 @@ public function getImportsProperty()
3437
->get();
3538
}
3639

37-
public function render()
40+
public function render(): View|Factory
3841
{
3942
return view(
4043
csv_view_path('handle-imports')

Diff for: src/Jobs/ImportCsv.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function handle()
3838
$affectedRows = $this->model::upsert(
3939
$this->chunk,
4040
['id'],
41-
collect($this->columns)->diff('id')->keys()->toArray(),
41+
collect($this->columns)->diff(['id'])->keys()->toArray(),
4242
);
4343

4444
$this->import->increment('processed_rows', $affectedRows);

Diff for: src/LaravelCsvDirectives.php

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,38 @@
44

55
class LaravelCsvDirectives
66
{
7-
public static function csvStyles()
7+
/**
8+
* Get CSV Styles
9+
*
10+
* @return string
11+
*/
12+
public static function csvStyles():string|null
813
{
914
if (config('laravel_csv.layout') == 'tailwindcss') {
1015
return self::getTailwindStyle();
1116
}
17+
18+
return self::getTailwindStyle();
1219
}
1320

14-
public static function csvScripts()
21+
/**
22+
* Get CSV Scripts
23+
*
24+
* @return string
25+
*/
26+
public static function csvScripts(): string
1527
{
1628
return <<<'HTML'
1729
<script src="{{ asset('vendor/csv/js/app.js') }}"></script>
1830
HTML;
1931
}
2032

21-
protected static function getTailwindStyle()
33+
/**
34+
* Get Tailwind Style Path
35+
*
36+
* @return string
37+
*/
38+
protected static function getTailwindStyle(): string
2239
{
2340
return <<<'HTML'
2441
<link href="{{ asset('vendor/csv/css/tailwind.css') }}" rel="stylesheet"></link>

Diff for: src/LaravelCsvServiceProvider.php

+3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ protected function configureComponents(): void
6060
*/
6161
protected function registerLivewireComponents(): void
6262
{
63+
/** @phpstan-ignore-next-line */
6364
Livewire::component('csv-importer', CsvImporter::class);
65+
66+
/** @phpstan-ignore-next-line */
6467
Livewire::component('handle-imports', HandleImports::class);
6568
}
6669

Diff for: src/Utilities/ChunkIterator.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Coderflex\LaravelCsv\Utilities;
44

5+
use Generator;
56
use Iterator;
67

78
/**
@@ -35,8 +36,10 @@ public function __construct(Iterator $iterator, int $chunkSize)
3536

3637
/**
3738
* Chunk the given data
39+
*
40+
* @return Generator
3841
*/
39-
public function get()
42+
public function get(): Generator
4043
{
4144
$chunk = [];
4245

Diff for: src/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @param string|null $view
1010
* @return string
1111
*/
12-
function csv_view_path($view): string
12+
function csv_view_path(string|null $view): string
1313
{
1414
return 'laravel-csv::livewire.'.config('laravel_csv.layout').'.'.$view;
1515
}

0 commit comments

Comments
 (0)