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

phpstan.neon.dist

Lines changed: 5 additions & 1 deletion
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

src/Http/Livewire/HandleImports.php

Lines changed: 6 additions & 3 deletions
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')

src/Jobs/ImportCsv.php

Lines changed: 1 addition & 1 deletion
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);

src/LaravelCsvDirectives.php

Lines changed: 20 additions & 3 deletions
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>

src/LaravelCsvServiceProvider.php

Lines changed: 3 additions & 0 deletions
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

src/Utilities/ChunkIterator.php

Lines changed: 4 additions & 1 deletion
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

src/helpers.php

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy