Skip to content

Commit

Permalink
71. fix some phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrakovich committed Jan 28, 2025
1 parent 17dc00e commit aac68c0
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 37 deletions.
9 changes: 4 additions & 5 deletions src/app/Admin/Controllers/InfoPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace App\Admin\Controllers;

use App\Models\InfoPage;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Illuminate\Support\Str;

class InfoPageController extends AdminController
class InfoPageController extends AbstractAdminController
{
/**
* Title for current resource.
Expand All @@ -34,8 +33,8 @@ protected function grid()
$grid->column('html', __('Html'))->display(function ($text) {
return Str::limit(strip_tags($text), 300, '...');
});
$grid->created_at()->date('d.m.Y H:i:s');
$grid->updated_at()->date('d.m.Y H:i:s');
$grid->column('created_at', 'Дата создания')->display(fn ($datetime) => self::formatDateTime($datetime));
$grid->column('updated_at', 'Дата обновления')->display(fn ($datetime) => self::formatDateTime($datetime));

return $grid;
}
Expand All @@ -48,7 +47,7 @@ protected function grid()
*/
protected function detail($id)
{
$show = new Show(InfoPage::findOrFail($id));
$show = new Show(InfoPage::query()->findOrFail($id));

$show->field('id', __('Id'));
$show->field('slug', __('Slug'));
Expand Down
1 change: 0 additions & 1 deletion src/app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function edit(Request $request)
/**
* Получить данные профиля
*
* @param Request $request
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function update(User $user, UpdateRequest $request)
Expand Down
5 changes: 1 addition & 4 deletions src/app/Http/Controllers/FeedbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ public function index(GoogleTagManagerService $gtmService, ?string $type = null)

/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\FeedbackRequest $request
* @return \Illuminate\Http\Response
*/
public function store(FeedbackRequest $feedbackRequest)
public function store(FeedbackRequest $feedbackRequest): array
{
$this->feedbackService->store($feedbackRequest->validated());

Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/Logs/InventoryLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class InventoryLog extends Model
/**
* The name of the "updated at" column.
*
* @var string
* @var string|null
*/
public const UPDATED_AT = null;

Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/Logs/OrderActionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OrderActionLog extends Model
/**
* The name of the "updated at" column.
*
* @var string
* @var string|null
*/
public const UPDATED_AT = null;

Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/Logs/OrderItemStatusLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OrderItemStatusLog extends Model
/**
* The name of the "updated at" column.
*
* @var string
* @var string|null
*/
public const UPDATED_AT = null;

Expand Down
2 changes: 1 addition & 1 deletion src/app/Models/Logs/SmsLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SmsLog extends Model
/**
* The name of the "updated at" column.
*
* @var string
* @var string|null
*/
public const UPDATED_AT = null;

Expand Down
8 changes: 8 additions & 0 deletions src/app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Database\Eloquent\Relations;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;
use Spatie\GoogleTagManager\DataLayer;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
Expand Down Expand Up @@ -103,6 +104,13 @@ class Product extends Model implements HasMedia
*/
protected ?string $url = null;

/**
* DataLayer for product
*
* @todo remove from product Model
*/
public DataLayer $dataLayer;

/**
* Категория товара
*/
Expand Down
9 changes: 0 additions & 9 deletions src/app/Models/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ public function getFullName(): string

/**
* Interact with the user's first name.
*
* @param string $firstName
*/
public function firstName(): Attribute
{
Expand Down Expand Up @@ -277,8 +275,6 @@ public function mailings(): HasMany

/**
* Retrieve the blacklist associated with the user.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne The relationship between the user and the blacklist.
*/
public function blacklist(): HasOne
{
Expand All @@ -287,8 +283,6 @@ public function blacklist(): HasOne

/**
* Retrieve the blacklistLogs associated with the user.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany The relationship between the user and the blacklistLogs.
*/
public function blacklistLogs(): HasMany
{
Expand All @@ -297,8 +291,6 @@ public function blacklistLogs(): HasMany

/**
* Define a relationship with the user's online payments.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany The relationship between the user and their online payments.
*/
public function payments(): HasManyThrough
{
Expand Down Expand Up @@ -415,7 +407,6 @@ private function getDataForCache(): array
*/
private function _hasReviewAfterOrder(): bool
{
/** @var Order $lastOrder */
if ($lastOrderDate = $this->orders()->latest()->value('created_at')) {
return $this->reviews()->where('created_at', '>', $lastOrderDate)
->whereHas('media')->exists();
Expand Down
4 changes: 1 addition & 3 deletions src/app/Notifications/ChannelManagerWithLimits.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public function send($notifiables, $notification)

/**
* Check availability and limits for channel.
*
* @param mixed $notificationn
*/
private function checkAvailability($notification): bool
private function checkAvailability(mixed $notification): bool
{
if (method_exists($notification, 'checkAvailability')) {
return $notification->checkAvailability();
Expand Down
4 changes: 1 addition & 3 deletions src/app/Services/CurrencyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ public function format(float $price, ?string $currency = null, string $space = '
}

/**
* Conver & format price in current currency
*
* @param float $value
* Convert & format price in current currency
*/
public function convertAndFormat(float $priceInByn): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/Services/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function addEager(CursorPaginator|LengthAwarePaginator|EloquentCollection

public function getById(array $ids): EloquentCollection
{
return Product::whereIn('id', $ids)->with([
return Product::query()->whereIn('id', $ids)->with([
'category:id,title,path',
'brand:id,name',
'sizes:id,name',
Expand Down
9 changes: 3 additions & 6 deletions src/app/Services/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class SearchService
{
/**
* Searck keys list from search query
* Search keys list from search query
*
* @var array
*/
Expand All @@ -20,11 +20,8 @@ public function __construct(string $searchQuery)

/**
* Generate search query
*
* @param array $search
* @return Builder
*/
public function generateSearchQuery(Builder $query, string $column)
public function generateSearchQuery(Builder $query, string $column): Builder
{
$value = reset($this->searchKeys);
$query->where($column, 'like', "%$value%");
Expand All @@ -37,7 +34,7 @@ public function generateSearchQuery(Builder $query, string $column)
}

/**
* Prepare id list from serach query
* Prepare id list from search query
*/
public function getIds(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User\User>
*/
class UserFactory extends Factory
{
Expand Down

0 comments on commit aac68c0

Please sign in to comment.