mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Refactor rector and static view properties
This commit is contained in:
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ActiveIcon extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Badge extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class BadgeColor extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class BadgeTooltip extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ChangeIcon extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class CustomItems extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ use Filament\Pages\Page;
|
||||
|
||||
class DisabledNavigation extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Group extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class GroupCollapsible extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class GroupNotCollapsible extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class SidebarCollapsibleOnDesktop extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class SidebarFullyCollapsibleOnDesktop extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class SortItems extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class TopNavigation extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class UserMenuCustomization extends Page
|
||||
{
|
||||
protected static string $view = 'livewire.panels.navigation.empty';
|
||||
protected string $view = 'livewire.panels.navigation.empty';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ use Closure;
|
||||
use Exception;
|
||||
use Filament\Support\Concerns\HasAlignment;
|
||||
use Filament\Support\Concerns\HasExtraAlpineAttributes;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Support\Facades\FilamentIcon;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -529,51 +530,51 @@ class FileUpload extends BaseFileUpload
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.zoom_in.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-in') ?? Heroicon::MagnifyingGlassPlus, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-in') ?? Heroicon::MagnifyingGlassPlus->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.zoom(0.1)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.zoom_out.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-out') ?? Heroicon::MagnifyingGlassMinus, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-out') ?? Heroicon::MagnifyingGlassMinus->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.zoom(-0.1)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.zoom_100.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-100') ?? Heroicon::ArrowsPointingOut, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.zoom-100') ?? Heroicon::ArrowsPointingOut->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.zoomTo(1)',
|
||||
],
|
||||
],
|
||||
'move' => [
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.move_left.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-left') ?? Heroicon::ArrowLeftCircle, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-left') ?? Heroicon::ArrowLeftCircle->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.move(-10, 0)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.move_right.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-right') ?? Heroicon::ArrowRightCircle, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-right') ?? Heroicon::ArrowRightCircle->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.move(10, 0)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.move_up.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-up') ?? Heroicon::ArrowUpCircle, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-up') ?? Heroicon::ArrowUpCircle->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.move(0, -10)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.move_down.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-down') ?? Heroicon::ArrowDownCircle, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.move-down') ?? Heroicon::ArrowDownCircle->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.move(0, 10)',
|
||||
],
|
||||
],
|
||||
'transform' => [
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.rotate_left.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.rotate-left') ?? Heroicon::ArrowUturnLeft, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.rotate-left') ?? Heroicon::ArrowUturnLeft->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.rotate(-90)',
|
||||
],
|
||||
[
|
||||
'label' => __('filament-forms::components.file_upload.editor.actions.rotate_right.label'),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.rotate-right') ?? Heroicon::ArrowUturnRight, $iconSizeClasses)->toHtml(),
|
||||
'iconHtml' => svg(FilamentIcon::resolve('forms::components.file-upload.editor.actions.rotate-right') ?? Heroicon::ArrowUturnRight->getIconForSize(IconSize::Medium), $iconSizeClasses)->toHtml(),
|
||||
'alpineClickHandler' => 'editor.rotate(90)',
|
||||
],
|
||||
[
|
||||
|
||||
@@ -147,7 +147,7 @@ public static function table(Table $table): Table
|
||||
For further customization opportunities, you can override the static `$view` property on the page class to a custom view in your app:
|
||||
|
||||
```php
|
||||
protected static string $view = 'filament.resources.users.pages.list-users';
|
||||
protected string $view = 'filament.resources.users.pages.list-users';
|
||||
```
|
||||
|
||||
This assumes that you have created a view at `resources/views/filament/resources/users/pages/list-users.blade.php`.
|
||||
|
||||
@@ -473,7 +473,7 @@ protected function getFormActions(): array
|
||||
For further customization opportunities, you can override the static `$view` property on the page class to a custom view in your app:
|
||||
|
||||
```php
|
||||
protected static string $view = 'filament.resources.users.pages.create-user';
|
||||
protected string $view = 'filament.resources.users.pages.create-user';
|
||||
```
|
||||
|
||||
This assumes that you have created a view at `resources/views/filament/resources/users/pages/create-user.blade.php`.
|
||||
|
||||
@@ -387,7 +387,7 @@ public static function getRecordSubNavigation(Page $page): array
|
||||
For further customization opportunities, you can override the static `$view` property on the page class to a custom view in your app:
|
||||
|
||||
```php
|
||||
protected static string $view = 'filament.resources.users.pages.edit-user';
|
||||
protected string $view = 'filament.resources.users.pages.edit-user';
|
||||
```
|
||||
|
||||
This assumes that you have created a view at `resources/views/filament/resources/users/pages/edit-user.blade.php`.
|
||||
|
||||
@@ -191,7 +191,7 @@ public static function getRecordSubNavigation(Page $page): array
|
||||
For further customization opportunities, you can override the static `$view` property on the page class to a custom view in your app:
|
||||
|
||||
```php
|
||||
protected static string $view = 'filament.resources.users.pages.view-user';
|
||||
protected string $view = 'filament.resources.users.pages.view-user';
|
||||
```
|
||||
|
||||
This assumes that you have created a view at `resources/views/filament/resources/users/pages/view-user.blade.php`.
|
||||
|
||||
@@ -55,7 +55,7 @@ class EditProfile extends Page
|
||||
|
||||
protected static bool $isDiscovered = false;
|
||||
|
||||
protected static string $view;
|
||||
protected string $view;
|
||||
|
||||
public function getLayout(): string
|
||||
{
|
||||
@@ -69,7 +69,7 @@ class EditProfile extends Page
|
||||
|
||||
public function getView(): string
|
||||
{
|
||||
return static::$view ?? 'filament-panels::auth.pages.edit-profile';
|
||||
return $this->view ?? 'filament-panels::auth.pages.edit-profile';
|
||||
}
|
||||
|
||||
public static function getLabel(): string
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class BasePage extends Component implements HasActions, HasForms, HasIn
|
||||
|
||||
protected ?string $subheading = null;
|
||||
|
||||
protected static string $view;
|
||||
protected string $view;
|
||||
|
||||
public static ?Closure $reportValidationErrorUsing = null;
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class BasePage extends Component implements HasActions, HasForms, HasIn
|
||||
|
||||
public function getView(): string
|
||||
{
|
||||
return static::$view;
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
public function getLayout(): string
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class Page extends BasePage
|
||||
|
||||
protected static bool $shouldRegisterNavigation = true;
|
||||
|
||||
protected static string $view = 'filament-panels::pages.page';
|
||||
protected string $view = 'filament-panels::pages.page';
|
||||
|
||||
public function getLayout(): string
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ abstract class SimplePage extends BasePage
|
||||
use Concerns\HasMaxWidth;
|
||||
use Concerns\HasTopbar;
|
||||
|
||||
protected static string $view = 'filament-panels::pages.simple';
|
||||
protected string $view = 'filament-panels::pages.simple';
|
||||
|
||||
protected static string $layout = 'filament-panels::components.layout.simple';
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class RelationManager extends Component implements Actions\Contracts\HasActions,
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-panels::resources.relation-manager';
|
||||
protected string $view = 'filament-panels::resources.relation-manager';
|
||||
|
||||
#[Locked]
|
||||
public Model $ownerRecord;
|
||||
@@ -137,7 +137,7 @@ class RelationManager extends Component implements Actions\Contracts\HasActions,
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view(static::$view, $this->getViewData());
|
||||
return view($this->view, $this->getViewData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,5 +11,5 @@ class AccountWidget extends Widget
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-panels::widgets.account-widget';
|
||||
protected string $view = 'filament-panels::widgets.account-widget';
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ class FilamentInfoWidget extends Widget
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-panels::widgets.filament-info-widget';
|
||||
protected string $view = 'filament-panels::widgets.filament-info-widget';
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Filament\Upgrade\Rector;
|
||||
|
||||
use Closure;
|
||||
use Filament\Pages\Dashboard;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use PhpParser\Modifiers;
|
||||
use PhpParser\Node;
|
||||
@@ -13,6 +14,7 @@ use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\UnionType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Naming\VariableRenamer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
@@ -38,6 +40,9 @@ class SimpleMethodChangesRector extends AbstractRector
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => [
|
||||
Page::class,
|
||||
],
|
||||
'changes' => [
|
||||
'getFooterWidgetsColumns' => function (ClassMethod $node) {
|
||||
$node->returnType = new UnionType([new Identifier('int'), new Identifier('array')]);
|
||||
@@ -54,7 +59,6 @@ class SimpleMethodChangesRector extends AbstractRector
|
||||
'class' => [
|
||||
CreateRecord::class,
|
||||
],
|
||||
'classIdentifier' => 'extends',
|
||||
'changes' => [
|
||||
'canCreateAnother' => function (ClassMethod $node) {
|
||||
$node->flags &= ~Modifiers::STATIC;
|
||||
@@ -65,7 +69,6 @@ class SimpleMethodChangesRector extends AbstractRector
|
||||
'class' => [
|
||||
Dashboard::class,
|
||||
],
|
||||
'classIdentifier' => 'extends',
|
||||
'changes' => [
|
||||
'getColumns' => function (ClassMethod $node) {
|
||||
$node->returnType = new UnionType([new Identifier('int'), new Identifier('array')]);
|
||||
@@ -136,22 +139,12 @@ class SimpleMethodChangesRector extends AbstractRector
|
||||
$change['class'] :
|
||||
[$change['class']];
|
||||
|
||||
$classes = [
|
||||
...array_map(fn (string $class): string => ltrim($class, '\\'), $classes),
|
||||
...array_map(fn (string $class): string => '\\' . ltrim($class, '\\'), $classes),
|
||||
];
|
||||
$classes = array_map(fn (string $class): string => ltrim($class, '\\'), $classes);
|
||||
|
||||
if ($change['classIdentifier'] === 'extends') {
|
||||
return $class->extends && $this->isNames($class->extends, $classes);
|
||||
foreach ($classes as $classToCheck) {
|
||||
if ($this->isObjectType($class, new ObjectType($classToCheck))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($change['classIdentifier'] !== 'implements') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) count(array_filter(
|
||||
$class->implements,
|
||||
fn (Name $interface): bool => $this->isNames($interface, $classes),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,20 @@
|
||||
namespace Filament\Upgrade\Rector;
|
||||
|
||||
use Closure;
|
||||
use Filament\Auth\Pages\EditProfile;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Pages\BasePage;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\SimplePage;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Widgets\Widget;
|
||||
use PhpParser\Modifiers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@@ -25,15 +34,46 @@ class SimplePropertyChangesRector extends AbstractRector
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => [
|
||||
BasePage::class,
|
||||
RelationManager::class,
|
||||
Widget::class,
|
||||
],
|
||||
'changes' => [
|
||||
'activeNavigationIcon' => function (Property $node) {
|
||||
$node->type = new Name('string | \BackedEnum | null');
|
||||
'view' => function (Property $node) {
|
||||
$node->flags &= ~Modifiers::STATIC;
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => [
|
||||
SimplePage::class,
|
||||
EditProfile::class,
|
||||
],
|
||||
'changes' => [
|
||||
'maxWidth' => function (Property $node) {
|
||||
$node->type = new Name('\Filament\Support\Enums\Width | string | null');
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => [
|
||||
BasePage::class,
|
||||
],
|
||||
'changes' => [
|
||||
'maxContentWidth' => function (Property $node) {
|
||||
$node->type = new Name('\Filament\Support\Enums\Width | string | null');
|
||||
},
|
||||
'maxWidth' => function (Property $node) {
|
||||
$node->type = new Name('\Filament\Support\Enums\Width | string | null');
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => [
|
||||
Resource::class,
|
||||
Page::class,
|
||||
],
|
||||
'changes' => [
|
||||
'activeNavigationIcon' => function (Property $node) {
|
||||
$node->type = new Name('string | \BackedEnum | null');
|
||||
},
|
||||
'navigationIcon' => function (Property $node) {
|
||||
$node->type = new Name('string | \BackedEnum | null');
|
||||
@@ -47,7 +87,6 @@ class SimplePropertyChangesRector extends AbstractRector
|
||||
'class' => [
|
||||
RelationManager::class,
|
||||
],
|
||||
'classIdentifier' => 'extends',
|
||||
'changes' => [
|
||||
'icon' => function (Property $node) {
|
||||
$node->type = new Name('string | \BackedEnum | null');
|
||||
@@ -119,22 +158,14 @@ class SimplePropertyChangesRector extends AbstractRector
|
||||
$change['class'] :
|
||||
[$change['class']];
|
||||
|
||||
$classes = [
|
||||
...array_map(fn (string $class): string => ltrim($class, '\\'), $classes),
|
||||
...array_map(fn (string $class): string => '\\' . ltrim($class, '\\'), $classes),
|
||||
];
|
||||
$classes = array_map(fn (string $class): string => ltrim($class, '\\'), $classes);
|
||||
|
||||
if ($change['classIdentifier'] === 'extends') {
|
||||
return $class->extends && $this->isNames($class->extends, $classes);
|
||||
foreach ($classes as $classToCheck) {
|
||||
if ($this->isObjectType($class, new ObjectType($classToCheck))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($change['classIdentifier'] !== 'implements') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) count(array_filter(
|
||||
$class->implements,
|
||||
fn (Name $interface): bool => $this->isNames($interface, $classes),
|
||||
));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,6 @@ use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\Rector\String_\RenameStringRector;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->rules([
|
||||
Rector\SimpleMethodChangesRector::class,
|
||||
Rector\SimplePropertyChangesRector::class,
|
||||
]);
|
||||
|
||||
$rectorConfig->ruleWithConfiguration(
|
||||
RenameClassRector::class,
|
||||
// @todo Alphabetical
|
||||
@@ -260,4 +255,9 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
'filament-infolists::components.split' => 'filament-schemas::components.split',
|
||||
],
|
||||
);
|
||||
|
||||
$rectorConfig->rules([
|
||||
Rector\SimpleMethodChangesRector::class,
|
||||
Rector\SimplePropertyChangesRector::class,
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class ChartWidget extends Widget implements HasSchemas
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-widgets::chart-widget';
|
||||
protected string $view = 'filament-widgets::chart-widget';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ class StatsOverviewWidget extends Widget implements HasSchemas
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-widgets::stats-overview-widget';
|
||||
protected string $view = 'filament-widgets::stats-overview-widget';
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ class TableWidget extends Widget implements Actions\Contracts\HasActions, Forms\
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view = 'filament-widgets::table-widget';
|
||||
protected string $view = 'filament-widgets::table-widget';
|
||||
|
||||
/**
|
||||
* @deprecated Override the `table()` method to configure the table.
|
||||
|
||||
@@ -17,7 +17,7 @@ abstract class Widget extends Component
|
||||
/**
|
||||
* @var view-string
|
||||
*/
|
||||
protected static string $view;
|
||||
protected string $view;
|
||||
|
||||
/**
|
||||
* @var int | string | array<string, int | null>
|
||||
@@ -70,7 +70,7 @@ abstract class Widget extends Component
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view(static::$view, $this->getViewData());
|
||||
return view($this->view, $this->getViewData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.pages.manage-settings';
|
||||
protected string $view = 'filament.pages.manage-settings';
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.clusters.site.pages.manage-settings';
|
||||
protected string $view = 'filament.clusters.site.pages.manage-settings';
|
||||
|
||||
protected static ?string $cluster = Site::class;
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.pages.site.manage-settings';
|
||||
protected string $view = 'filament.pages.site.manage-settings';
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ class ManageUserPermissions extends Page
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.user-resource.pages.manage-user-permissions';
|
||||
protected string $view = 'filament.resources.user-resource.pages.manage-user-permissions';
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.pages.manage-settings';
|
||||
protected string $view = 'filament.pages.manage-settings';
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.clusters.site.pages.manage-settings';
|
||||
protected string $view = 'filament.clusters.site.pages.manage-settings';
|
||||
|
||||
protected static ?string $cluster = SiteCluster::class;
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ use Filament\Pages\Page;
|
||||
|
||||
class ManageSettings extends Page
|
||||
{
|
||||
protected static string $view = 'filament.pages.site.manage-settings';
|
||||
protected string $view = 'filament.pages.site.manage-settings';
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ class ManageUserPermissions extends Page
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.users.pages.manage-user-permissions';
|
||||
protected string $view = 'filament.resources.users.pages.manage-user-permissions';
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Actions extends Page
|
||||
{
|
||||
protected static string $view = 'pages.actions';
|
||||
protected string $view = 'pages.actions';
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Settings extends Page
|
||||
{
|
||||
protected static string $view = 'pages.settings';
|
||||
protected string $view = 'pages.settings';
|
||||
|
||||
protected static string | BackedEnum | null $navigationIcon = Heroicon::OutlinedCog6Tooth;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user