Skip to content

Commit

Permalink
upgrade: Dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Feb 14, 2025
1 parent d836bdc commit e481902
Show file tree
Hide file tree
Showing 41 changed files with 109 additions and 78 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@
"source": "https://github.com/moonshine-software/moonshine"
},
"require": {
"php": "^8.2",
"ext-curl": "*",
"ext-json": "*",
"illuminate/contracts": "^10|^11",
"illuminate/support": "^10|^11",
"illuminate/view": "^10|^11",
"lee-to/fast-attributes": "^0.1",
"lee-to/fast-attributes": "^0.2",
"lee-to/laravel-package-command": "^0.9",
"nyholm/psr7": "^1.8",
"php": "^8.2",
"symfony/psr-http-message-bridge": "^7.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64",
"larastan/larastan": "^2.0",
"moonshine/import-export": "^1.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0",
"rector/rector": "^1.0",
"friendsofphp/php-cs-fixer": "^3.68",
"larastan/larastan": "^3.0",
"moonshine/import-export": "^1",
"orchestra/testbench": "^9.9",
"pestphp/pest": "^3",
"pestphp/pest-plugin-laravel": "^3",
"rector/rector": "^2",
"symplify/monorepo-builder": "^11.2"
},
"replace": {
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ includes:

parameters:
editorUrl: 'anything'
editorUrlTitle: "\nat packages/moonshine/%%relFile%%:%%line%%"
paths:
- src/
level: 5
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false

ignoreErrors:
- '#Cannot cast Closure to string#'
- '#Cannot cast Closure\|null to string#'
- '#mixin contains invalid type Illuminate\\Support\\Traits\\Conditionable#'
- '#does not accept Illuminate\\View\\ComponentAttributeBag#'
- '#should return MoonShine\\Contracts\\UI\\ComponentAttributesBagContract but returns Illuminate\\View\\ComponentAttributeBag#'
- '#getResource\(\) should return#'
- '#getParentResource\(\) should return#'
- '#when\(\) expects#'
- '#Call to an undefined method Illuminate\\Http\\Request::getScalar#'
- '#Trait MoonShine\\Laravel\\Traits\\Resource\\ResourceWithParent is used zero times#'
excludePaths:
- ./src/Support/src/Traits/Makeable.php
- ./src/Laravel/routes/moonshine.php
- ./src/Laravel/config/moonshine.php
- ./src/Laravel/src/Providers/MoonShineServiceProvider.php
4 changes: 2 additions & 2 deletions src/AssetManager/src/Traits/HasLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function getLink(): string
{
$link = $this->link;

if (! str_contains($link, '&v=') && ! str_contains($link, '?v=') && ! \is_null($this->getVersion())) {
$separator = str_contains($link, '?') ? '&' : '?';
if (! str_contains((string) $link, '&v=') && ! str_contains((string) $link, '?v=') && ! \is_null($this->getVersion())) {
$separator = str_contains((string) $link, '?') ? '&' : '?';

return $link . $separator . 'v=' . $this->getVersion();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/src/AssetManager/AssetResolverContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface AssetResolverContract
{
public function get(string $path): string;

public function getDev(string $path): ?string;
public function getDev(string $path): string;

public function isDev(): bool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ public function getPath(string $path): string;

public function getUrl(string $path): string;

/**
* @return list<\SplFileInfo>
*/
public function getFiles(string $directory, bool $recursive = false): array;

/**
* @return string[]
*/
public function getDirectories(string $directory, bool $recursive = false): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

interface ViewRendererContract
{
public function render(string $view, array $data = []): Renderable|string;
public function render(string $view, array $data = []): Renderable;
}
7 changes: 5 additions & 2 deletions src/Core/src/Collections/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ final class Components extends BaseCollection implements ComponentsContract
use Conditionable;

/**
* @param list<ComponentContract> $elements
* @param list<ComponentContract> $data
* @template TType
* @param FieldsContract|ComponentsContract|list<ComponentContract> $elements
* @param class-string<TType> $type
* @param list<TType> $data
*
* @throws Throwable
*/
protected function extractOnly(iterable $elements, string $type, array &$data): void
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Pages/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,6 @@ protected function systemViewData(): array

public function getView(): string
{
return 'moonshine::page';
return $this->customView ?? $this->view ?: 'moonshine::page';
}
}
5 changes: 0 additions & 5 deletions src/Laravel/src/Applies/Filters/BelongsToManyModelApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use MoonShine\Contracts\UI\ApplyContract;
use MoonShine\Contracts\UI\FieldContract;
use MoonShine\Laravel\Fields\Relationships\BelongsToMany;
use MoonShine\Laravel\Fields\Relationships\ModelRelationField;

/**
* @implements ApplyContract<BelongsToMany>
Expand All @@ -20,10 +19,6 @@ class BelongsToManyModelApply implements ApplyContract
public function apply(FieldContract $field): Closure
{
return static function (Builder $query) use ($field): void {
if (! $field instanceof ModelRelationField) {
return;
}

$checkedKeys = $field->getCheckedKeys();

$relation = $field->getRelation();
Expand Down
8 changes: 3 additions & 5 deletions src/Laravel/src/Buttons/DeleteButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ public static function for(
$action = static fn (mixed $item, ?DataWrapperContract $data): string => $resource->getRoute(
'crud.destroy',
$data?->getKey(),
array_filter([
...$redirectAfterDelete
? ['_redirect' => $redirectAfterDelete]
: [],
])
$redirectAfterDelete
? ['_redirect' => $redirectAfterDelete]
: []
);

return ActionButton::make(
Expand Down
1 change: 1 addition & 0 deletions src/Laravel/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ private function confirmAction(
private function registerServiceProvider(): void
{
if (
// @phpstan-ignore-next-line
method_exists(ServiceProvider::class, 'addProviderToBootstrapFile')
&& file_exists(base_path('bootstrap/app.php'))
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Commands/MoonShineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static function addResourceOrPageTo(string $class, string $to, Closure $
$replaceContent->value(),
],
[
$headSection->replaceLast(';', (";\nuse $namespace;" . ($use ? "\nuse $use;" : ''))),
$headSection->replaceLast(';', (";\nuse $namespace;" . ($use ? "\nuse $use;" : '')))->value(),
$replace($replaceContent, $tab)->value(),
],
$content->value(),
Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private function publishAssetsTemplate(): void
info('Node packages installed');
}

info('App.css, postcss/tailwind.config published');
info("Don't forget to add to MoonShineServiceProvider `Vite::asset('resources/css/app.css')`");
info('app.css, postcss/tailwind.config published');
info("Don't forget to add styles to the Layout (Css::make(`Vite::asset('resources/css/app.css')`))");
}

private function publishResources(): void
Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/src/Components/Layout/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function getDefaultName(): string
return '';
}

return $this->user?->{$userField} ?? '';
return $this->user->{$userField} ?? '';
}

private function getDefaultUsername(): string
Expand All @@ -107,7 +107,7 @@ private function getDefaultUsername(): string
return '';
}

return $this->user?->{$userField} ?? '';
return $this->user->{$userField} ?? '';
}

private function getDefaultAvatar(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/DependencyInjection/AssetResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function get(string $path): string
return asset($path);
}

public function getDev(string $path): ?string
public function getDev(string $path): string
{
return Vite::useBuildDirectory('vendor/moonshine')
->useHotFile($path)
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/DependencyInjection/ViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class ViewRenderer implements ViewRendererContract
{
public function render(string $view, array $data = []): Renderable|string
public function render(string $view, array $data = []): Renderable
{
return view($view, $data);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Laravel/src/Fields/Relationships/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
use MoonShine\UI\Traits\WithFields;
use Throwable;

use function Pest\Laravel\call;

/**
* @template-covariant R of (HasOneOrMany|HasOneOrManyThrough|MorphOneOrMany)
* @extends ModelRelationField<R>
Expand Down Expand Up @@ -114,7 +116,7 @@ public function redirectAfter(Closure $callback): static
public function getRedirectAfter(Model|int|null|string $parentId): ?string
{
if (! \is_null($this->redirectAfter)) {
return (string) value($this->redirectAfter, $parentId, $this);
return (string) \call_user_func($this->redirectAfter, $parentId, $this);
}

if ($this->isAsync()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Fields/Relationships/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function redirectAfter(Closure $callback): static
public function getRedirectAfter(Model|int|null|string $parentId): ?string
{
if (! \is_null($this->redirectAfter)) {
return (string) value($this->redirectAfter, $parentId, $this);
return (string) \call_user_func($this->redirectAfter, $parentId, $this);
}

if ($this->isAsync() && ! \is_null($this->toValue())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function (?ModelResource $resource): void {

protected function prepareFill(array $raw = [], ?DataWrapperContract $casted = null): mixed
{
return $casted?->getOriginal()?->{$this->getRelationName()} ?? null;
return $casted?->getOriginal()->{$this->getRelationName()} ?? null;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Laravel/src/Http/Controllers/AuthenticateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public function authenticate(LoginFormRequest $request): RedirectResponse|JsonRe
{
if (filled(moonshineConfig()->getAuthPipelines())) {
$request = Pipeline::send($request)->through(
array_filter(
moonshineConfig()->getAuthPipelines()
)
moonshineConfig()->getAuthPipelines()
)->thenReturn();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Http/Requests/LoginFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getThrottleKey(): string
protected function prepareForValidation(): void
{
$this->merge([
'username' => request()->str('username')
'username' => $this->str('username')
->when(
moonshineConfig()->getUserField(
'username',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function getRelationName(): string
public function getPageField(): ?ModelRelationField
{
return memoize(function () {
/** @var Fields $fields */
/**
* @var Fields $fields
* @phpstan-ignore-next-line
*/
$fields = $this->getPage()->getComponents();

if ($parentField = request()->getScalar('_parent_field')) {
Expand Down
16 changes: 9 additions & 7 deletions src/Laravel/src/MoonShineAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ final class MoonShineAuth
{
public static function getModel(): ?Model
{
$model = self::getProvider()?->getModel();
$provider = self::getProvider();

return $model ? new $model() : null;
if(!$provider instanceof EloquentUserProvider) {
return null;
}

$model = $provider->getModel();

return new $model();
}

/**
* @return ?EloquentUserProvider
*/
public static function getProvider(): ?UserProvider
public static function getProvider(): UserProvider
{
/** @phpstan-ignore-next-line */
return self::getGuard()->getProvider();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Notifications/MoonShineNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function notify(

private function getUnreadNotifications(): DatabaseNotificationCollection
{
return MoonShineAuth::getGuard()->user()?->unreadNotifications ?? DatabaseNotificationCollection::make();
return MoonShineAuth::getGuard()->user()->unreadNotifications ?? DatabaseNotificationCollection::make();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Notifications/NotificationItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(

public function getId(): int|string|null
{
return $this->notification->id;
return $this->notification->getKey();
}

public function getReadRoute(): string
Expand Down
5 changes: 4 additions & 1 deletion src/Laravel/src/Pages/ErrorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ protected function components(): iterable
->getTranslator()
->get('moonshine::ui.back');

/** @var view-string $view */
$view = 'moonshine::errors.404';

return [
FlexibleRender::make(
static fn () => view('moonshine::errors.404'),
static fn () => view($view),
['code' => $code, 'message' => $message, 'logo' => $logo, 'backUrl' => $backUrl, 'backTitle' => $backTitle]
),
];
Expand Down
4 changes: 3 additions & 1 deletion src/Laravel/src/Pages/LoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class LoginPage extends Page

protected function components(): iterable
{
yield moonshineConfig()->getForm('login', LoginForm::class);
return [
moonshineConfig()->getForm('login', LoginForm::class)
];
}
}
2 changes: 1 addition & 1 deletion src/Laravel/src/Traits/Fields/WithRelatedLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function relatedLink(?string $linkRelation = null, Closure|bool|null $con

public function toRelatedCollection(): Collection
{
return $this->getRelatedModel()?->{$this->getRelationName()} ?? new Collection();
return $this->getRelatedModel()->{$this->getRelationName()} ?? new Collection();
}

protected function isRelatedLink(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/src/Traits/Resource/ResourceModelQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected function searchQuery(string $terms): void
{
$this->newQuery()->where(function (Builder $builder) use ($terms): void {
foreach ($this->getSearchColumns() as $key => $column) {
if (\is_string($column) && str($column)->contains('.')) {
if (str($column)->contains('.')) {
$column = str($column)
->explode('.')
->tap(static function (Collection $data) use (&$key): void {
Expand Down
Loading

0 comments on commit e481902

Please sign in to comment.