diff --git a/composer.json b/composer.json index f87b7f7..a503490 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,10 @@ "require-dev": { "laravel/scout": "^10.10", "nunomaduro/collision": "^8.1", - "nunomaduro/larastan": "^2.0", + "nunomaduro/larastan": "^3.0", "orchestra/testbench": "^9.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^10.1", - "spatie/laravel-ray": "^1.30", "squizlabs/php_codesniffer": "^3.7", "vimeo/psalm": "^5.0" }, diff --git a/phpstan.neon b/phpstan.neon index 4db9f1d..8061fae 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,20 +2,11 @@ includes: - ./vendor/nunomaduro/larastan/extension.neon parameters: - - paths: - - src/ - - # Level 9 is the highest level - level: 6 - -# ignoreErrors: -# - '#PHPDoc tag @var#' -# -# excludePaths: -# - ./*/*/FileToBeExcluded.php -# -# checkMissingIterableValueType: false - checkMissingIterableValueType: false - - checkGenericClassInNonGenericObjectType: false + level: 6 + paths: + - src + ignoreErrors: + - '#Class [a-zA-Z0-9\\_]+ implements generic interface [a-zA-Z0-9\\_]+ but does not specify its types: [a-zA-Z0-9\\_]+#' + - '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\) return type with generic class [a-zA-Z0-9\\_]+ does not specify its types: .+#' + - '#Trait [a-zA-Z0-9\\_]+ is used zero times and is not analysed.#' + - '#Unable to resolve the template type TRelatedModel in call to method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#' diff --git a/resources/views/pages/import.blade.php b/resources/views/pages/import.blade.php index 2f1a419..c73d818 100644 --- a/resources/views/pages/import.blade.php +++ b/resources/views/pages/import.blade.php @@ -28,7 +28,7 @@
@include('crud::inc.grouped_errors') -
+ @csrf @includeFirst( diff --git a/src/Http/Controllers/Admin/Interfaces/ExportableCrud.php b/src/Http/Controllers/Admin/Interfaces/ExportableCrud.php index d5bec1f..ba02f74 100644 --- a/src/Http/Controllers/Admin/Interfaces/ExportableCrud.php +++ b/src/Http/Controllers/Admin/Interfaces/ExportableCrud.php @@ -8,5 +8,8 @@ interface ExportableCrud { public function getExport(): ImportExport; + /** + * @return array + */ public function getExportParameters(): array; } diff --git a/src/Http/Controllers/Admin/Interfaces/ImportableCrud.php b/src/Http/Controllers/Admin/Interfaces/ImportableCrud.php index 3b13f8c..684d2b8 100644 --- a/src/Http/Controllers/Admin/Interfaces/ImportableCrud.php +++ b/src/Http/Controllers/Admin/Interfaces/ImportableCrud.php @@ -8,5 +8,8 @@ interface ImportableCrud { public function getImport(): ImportExport; + /** + * @return array + */ public function getImportParameters(): array; } diff --git a/src/Http/Controllers/Admin/Interfaces/MultiExportableCrud.php b/src/Http/Controllers/Admin/Interfaces/MultiExportableCrud.php index 16c59f3..001142c 100644 --- a/src/Http/Controllers/Admin/Interfaces/MultiExportableCrud.php +++ b/src/Http/Controllers/Admin/Interfaces/MultiExportableCrud.php @@ -7,5 +7,8 @@ interface MultiExportableCrud public const QUERY_PARAM = 'export'; public const DEFAULT_EXPORT_NAME = 'default'; + /** + * @return array + */ public function getAvailableExports(): array; } diff --git a/src/Http/Controllers/Admin/Traits/HasImportButton.php b/src/Http/Controllers/Admin/Traits/HasImportButton.php index 891f957..2ca69fb 100644 --- a/src/Http/Controllers/Admin/Traits/HasImportButton.php +++ b/src/Http/Controllers/Admin/Traits/HasImportButton.php @@ -32,6 +32,9 @@ public function import(): View $this->data['crud'] = $this->crud; $this->data['title'] = $this->crud->getTitle(); + $this->data['action'] = url( + $this->crud->route . '/' . config('backpack-async-import-export.admin_import_route'), + ); return view('backpack-async-export::pages.import', $this->data); } diff --git a/src/Http/Requests/ImportRequest.php b/src/Http/Requests/ImportRequest.php index 787c586..8f2d9dd 100644 --- a/src/Http/Requests/ImportRequest.php +++ b/src/Http/Requests/ImportRequest.php @@ -8,6 +8,9 @@ class ImportRequest extends FormRequest { const PARAM_FILE = 'file'; + /** + * @return array + */ public function rules(): array { return [ diff --git a/src/Jobs/ExportJob.php b/src/Jobs/ExportJob.php index 05dc43d..3778629 100644 --- a/src/Jobs/ExportJob.php +++ b/src/Jobs/ExportJob.php @@ -26,9 +26,11 @@ class ExportJob implements ShouldQueue use SerializesModels; private ImportExport $export; - private array $exportParameters; - public function __construct(ImportExport $export, array $exportParameters) + /** + * @param array $exportParameters + */ + public function __construct(ImportExport $export, private array $exportParameters) { $this->export = $export; $this->exportParameters = $exportParameters; diff --git a/src/Jobs/ImportJob.php b/src/Jobs/ImportJob.php index 2136d8a..6a8f16d 100644 --- a/src/Jobs/ImportJob.php +++ b/src/Jobs/ImportJob.php @@ -21,6 +21,9 @@ class ImportJob implements ShouldQueue use Queueable; use SerializesModels; + /** + * @param array $exportParameters + */ public function __construct( private ImportExport $export, private array $exportParameters @@ -70,7 +73,7 @@ public function handle(): void ->implode(', '); throw new \Exception($message); } - } catch (\Exception|\Throwable $exception) { + } catch (\Throwable $exception) { $this->export->update([ ImportExport::COLUMN_STATUS => ImportExportStatus::Error, ImportExport::COLUMN_ERROR => $exception->getMessage(), diff --git a/src/Models/ImportExport.php b/src/Models/ImportExport.php index d3012f5..58f22db 100644 --- a/src/Models/ImportExport.php +++ b/src/Models/ImportExport.php @@ -59,6 +59,9 @@ class ImportExport extends Model implements ImportExportInterface self::COLUMN_STATUS => ImportExportStatus::class, ]; + /** + * @var array|string[] + */ protected array $dates = [ self::COLUMN_COMPLETED_AT, ]; @@ -68,7 +71,7 @@ public function user(): BelongsTo return $this->belongsTo(config('backpack-async-import-export.user_model')); } - protected static function boot() + protected static function boot(): void { parent::boot(); ImportExport::saving(function (ImportExport $export) { @@ -128,7 +131,7 @@ public function getDownloadButton(): string protected function isReady(): Attribute { return Attribute::make( - get: fn (): bool => ImportExportStatus::Successful === $this->{ImportExport::COLUMN_STATUS} + get: fn(): bool => ImportExportStatus::Successful === $this->{ImportExport::COLUMN_STATUS} && Storage::disk($this->disk)->exists($this->{self::COLUMN_FILENAME}), ); }