Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjansen authored and actions-user committed Dec 21, 2021
1 parent df1df75 commit ad3c93f
Show file tree
Hide file tree
Showing 24 changed files with 37 additions and 44 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.1.0","version":"3.4.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true},"hashes":{"src\/View\/Components\/AppLayout.php":1613367892,"src\/Fields\/Table.php":3336449241,"src\/Fields\/Concerns\/WithStackableFields.php":1599391380,"src\/Fields\/Concerns\/ShowsConditionally.php":3271719097,"src\/Fields\/Concerns\/WithHelpText.php":898286327,"src\/Fields\/Concerns\/HasResource.php":1367907483,"src\/Fields\/Status.php":617248576,"src\/Fields\/Step.php":1541960012,"src\/Fields\/Date.php":805661630,"src\/Fields\/Country.php":885987730,"src\/Fields\/Files.php":366953723,"src\/Fields\/Id.php":2374783717,"src\/Fields\/Editor.php":3027611809,"src\/Fields\/Element.php":3483313108,"src\/Fields\/Currency.php":2865048290,"src\/Fields\/Panel.php":3146779467,"src\/Fields\/Password.php":1651049694,"src\/Fields\/Text.php":729603788,"src\/Fields\/Placeholder.php":1113952230,"src\/Fields\/FieldElement.php":2424210381,"src\/Fields\/Field.php":4080538979,"src\/Fields\/Number.php":1695604394,"src\/Fields\/Json.php":1831669047,"src\/Fields\/HasMany.php":123517808,"src\/Fields\/HasOne.php":2692685530,"src\/Fields\/Textarea.php":3358988108,"src\/Fields\/Title.php":3394848086,"src\/Fields\/Select.php":1430014433,"src\/Fields\/Column.php":1647161446,"src\/Move.php":1950622418,"src\/Collections\/ResourceCollection.php":4284425507,"src\/Support\/DataTransferObjectCollection.php":3633712681,"src\/Support\/helpers.php":1370540711,"src\/Support\/Encoding.php":1224462771,"src\/Support\/Livewire\/Concerns\/HasFilter.php":1030487299,"src\/Support\/Livewire\/Concerns\/HasCrud.php":594241466,"src\/Support\/Livewire\/Concerns\/HasStore.php":1562010567,"src\/Support\/Livewire\/Concerns\/StoresPreviousUrl.php":3551721058,"src\/Support\/Livewire\/FormComponent.php":3350319084,"src\/Support\/Livewire\/TableComponent.php":1406605288,"src\/Status\/TrashedStatus.php":2414202037,"src\/Concerns\/CanPretendToBeAFile.php":2583386292,"src\/Concerns\/FilesModal.php":1160623839,"src\/Concerns\/WithFilename.php":3282783721,"src\/Concerns\/QueryBuilder.php":3718268625,"src\/Concerns\/WithAuthorization.php":2844441077,"src\/Concerns\/HasParent.php":1473417635,"src\/Concerns\/WithRedirects.php":3976981096,"src\/Concerns\/Metable.php":3038314173,"src\/Concerns\/WithClosures.php":1773064246,"src\/Concerns\/HasRequired.php":3769467885,"src\/Concerns\/WithActionableFields.php":3178077400,"src\/Concerns\/HasSelected.php":1571911162,"src\/Concerns\/HasMountActions.php":1539007819,"src\/Concerns\/IsStacked.php":3232969383,"src\/Concerns\/HasDependencies.php":2557481922,"src\/Concerns\/Only.php":463418872,"src\/Concerns\/HasFiles.php":1980192617,"src\/Concerns\/Makeable.php":2150212415,"src\/Concerns\/WithHeadings.php":2242598481,"src\/Concerns\/HasRules.php":149853784,"src\/Concerns\/AuthorizedToSee.php":3211407748,"src\/Concerns\/WithChunkCount.php":575441387,"src\/Concerns\/WithListeners.php":509565003,"src\/Concerns\/GloballySearchable.php":3060456067,"src\/Concerns\/HasHelpText.php":1364026724,"src\/Concerns\/Except.php":473090979,"src\/Concerns\/LoadableFiles.php":4071023820,"src\/Concerns\/Sortable.php":2238020194,"src\/Concerns\/WithModal.php":865490203,"src\/Concerns\/WithDisk.php":2834012375,"src\/Concerns\/WithMount.php":2008583356,"src\/Concerns\/WithSteps.php":1831516120,"src\/Concerns\/HasResource.php":791094066,"src\/TableActions\/ExportToExcelAction.php":362874372,"src\/File\/TemporaryUploadedResourceFile.php":1839356987,"src\/File\/ResourceFile.php":3053572234,"src\/File\/ResourceFileContract.php":3820745798,"src\/File\/HasResourceFile.php":1801013478,"src\/Actions\/LivewireCloseModal.php":699077158,"src\/Actions\/Action.php":3299526870,"src\/Actions\/UnsetField.php":1856712101,"src\/Actions\/ExportToExcel.php":3424549928,"src\/Requests\/ResourceIndexRequest.php":4239549700,"src\/Requests\/ResourceRequest.php":2755530863,"src\/MoveBladeDirectives.php":308817953,"src\/Rules\/UniquePostcodeHousenumber.php":4112303357,"src\/Filters\/Filter.php":1627547567,"src\/Resource.php":3581238461,"src\/Query\/ApplyTrashedConstraint.php":704042145,"src\/DomainActions\/DeleteResource.php":1970078078,"src\/DomainActions\/SyncMediaAction.php":3375876584,"src\/DomainActions\/StoreResource.php":2176001580,"src\/DomainActions\/WithSyncableMedia.php":626203456,"src\/Exceptions\/FindResourceException.php":3362040704,"src\/Exceptions\/InvalidExcelDownloadException.php":3747490066,"src\/Exceptions\/UnknownResourceException.php":4152294449,"src\/Exceptions\/ResourcesException.php":72549047,"src\/Exceptions\/AuthorizationFailedException.php":375408103,"src\/DataTransferObjects\/MediaData.php":2530988413,"src\/DataTransferObjects\/MediaCollectable.php":588901680,"src\/DataTransferObjects\/MediaCollection.php":55244709,"src\/ResourceFinder.php":4072418415,"src\/Contracts\/ElementInterface.php":2013120074,"src\/Contracts\/PanelInterface.php":3525584316,"src\/Finders\/ModelFinder.php":1305016612,"src\/Commands\/MoveCommand.php":2107669443,"src\/Commands\/InstallCommand.php":1845782120,"src\/Commands\/ResourceCommand.php":4153673588,"src\/Help\/ProposedCustomName.php":1480185318,"src\/Facades\/Move.php":3354553929,"src\/MoveServiceProvider.php":2156315248,"src\/TableFilters\/PaginationFilter.php":1661521004,"src\/Livewire\/ResourceTable.php":225324693,"src\/Livewire\/HeaderSearch.php":4198543023,"src\/Livewire\/ResourceShow.php":2961282635,"src\/Livewire\/ResourceForm.php":4115239835,"src\/Livewire\/BaseResourceForm.php":1082155391,"src\/Controllers\/CanPretendToBeAFile.php":3105370058,"src\/Controllers\/MoveStyleAssets.php":3080897394,"src\/Controllers\/PreviewFileController.php":498344258,"src\/Controllers\/MoveJavaScriptAssets.php":3580454963,"src\/Controllers\/DownloadController.php":650148729,"tests\/TestCase.php":4074449449,"tests\/Fixtures\/OtherNamespace\/UserResource.php":399235553,"tests\/Fixtures\/Contact.php":4204603303,"tests\/Fixtures\/UserResource.php":2681885697,"tests\/Fixtures\/User.php":3777191281,"tests\/Factories\/UserFactory.php":669143013,"tests\/Factories\/ContactFactory.php":2547650010,"tests\/Feature\/ResourceFieldTest.php":3510683364,"tests\/Feature\/Fields\/HasOne.php":3635753058,"tests\/Feature\/ResourceFinderTest.php":1329362441,"tests\/Feature\/MoveTest.php":396860773,"tests\/Feature\/StatusTest.php":1282757930,"tests\/Feature\/ResourceRoutesTest.php":1364098323,"tests\/Feature\/RulesTest.php":2112257075,"tests\/ExampleTest.php":709183769}}
2 changes: 1 addition & 1 deletion src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle(): void
$this->installMoveServiceProvider();

// Layouts...
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/resources/views/layouts', resource_path('views/layouts'));
(new Filesystem())->copyDirectory(__DIR__.'/../../stubs/resources/views/layouts', resource_path('views/layouts'));

// Assets...
copy(__DIR__.'/../../stubs/public/css/app.css', public_path('css/app.css'));
Expand Down
2 changes: 0 additions & 2 deletions src/Concerns/HasFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Uteq\Move\Concerns;

use Illuminate\Support\Facades\URL;
use Intervention\Image\Facades\Image;
use Livewire\WithFileUploads;
use Symfony\Component\HttpFoundation\File\File;
use Uteq\Move\DataTransferObjects\MediaCollection;
Expand Down Expand Up @@ -87,7 +86,6 @@ public function getFilesPaths(Field $field): \Uteq\Move\DataTransferObjects\Medi

$urls = $this->loadFiles($field, true)
->map(function (ResourceFileContract $file, $key) use ($field) {

$inDelete = isset($this->deletedFiles[$field->attribute][$key]);

// Only add Resource file to deleted if it already exists
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected static function defaultQuery(
protected static function applySoftTrashedConstraint(Builder $query, $trashedStatus)
{
return static::usesSoftDeletes()
? (new ApplyTrashedConstraint)->__invoke($query, $trashedStatus)
? (new ApplyTrashedConstraint())->__invoke($query, $trashedStatus)
: $query;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/WithClosures.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function initializeWithClosures(): void
return;
}

$this->beforeMount(fn() => $this->serializeClosures());
$this->beforeMount(fn () => $this->serializeClosures());
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Concerns/WithListeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function addListener($key, $method = null): void
if (is_array($key)) {
$this->listeners = array_replace($key, $this->listeners);
} else {

if (isset($this->listeners[$key])) {
throw new Exception(sprintf(
'%s: The given listener `%s` already exists',
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/WithMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function mountTestStore(): void

private function mountSteps(): void
{
if ((!$this->activeStep || !$this->model->id) && $step = $this->steps()->first()) {
if ((! $this->activeStep || ! $this->model->id) && $step = $this->steps()->first()) {
$this->activeStep = $step->attribute;
$this->availableSteps[] = $this->activeStep;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Fields/Concerns/ShowsConditionally.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ public function isShownOn($action, $resource = null, $request = null): bool
$request = $request ?: request();

$handler = [
'create' => fn(): bool => $this->isShownOnCreation($request),
'update' => fn(): bool => $this->isShownOnUpdate($request, $resource),
'index' => fn(): bool => $this->isShownOnIndex($request, $resource),
'show' => fn(): bool => $this->isShownOnDetail($request, $resource),
'create' => fn (): bool => $this->isShownOnCreation($request),
'update' => fn (): bool => $this->isShownOnUpdate($request, $resource),
'index' => fn (): bool => $this->isShownOnIndex($request, $resource),
'show' => fn (): bool => $this->isShownOnDetail($request, $resource),
][$action] ?? false;

return $handler ? $handler() : false;
Expand Down
5 changes: 2 additions & 3 deletions src/Fields/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Uteq\Move\Fields;

use Illuminate\Support\Str;
use Stringable;

class Currency extends Number
{
Expand All @@ -14,8 +13,8 @@ public function numberFormat(int $decimals = 0, string $decimalSeparator = '.',
$this->resourceDataCallback = function ($value): string {
return Str::of($value)
->rtrim('0')
->when(str_ends_with($value, '.'), function($string) {
return $string->replace('.', '');
->when(str_ends_with($value, '.'), function ($string) {
return $string->replace('.', '');
});
};

Expand Down
1 change: 0 additions & 1 deletion src/Fields/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public function init(): void

public function fixUTF8($string): string
{

if (mb_detect_encoding(mb_convert_encoding($string, 'Windows-1251', 'UTF-8'), 'Windows-1251,UTF-8', true) === 'UTF-8') {
return utf8_decode($string) ?: $string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function getPlaceholder($resource): ?string
{
return $this->placeholder
?? (string) __('Add a :label', [
'label' => lcfirst($resource->singularLabel()) . ' ' . lcfirst($this->name)
'label' => lcfirst($resource->singularLabel()) . ' ' . lcfirst($this->name),
]);
}

Expand Down Expand Up @@ -622,7 +622,7 @@ public function afterValueCallback(Closure $afterCallback): void
$callback = $this->valueCallback;

$this->valueCallback = $callback
? fn($value, ...$args) => $afterCallback($callback($value, ...$args))
? fn ($value, ...$args) => $afterCallback($callback($value, ...$args))
: $afterCallback;
}

Expand Down
1 change: 0 additions & 1 deletion src/Fields/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Uteq\Move\Fields;

use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\RequiredIf;

Expand Down
3 changes: 1 addition & 2 deletions src/Fields/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Uteq\Move\Fields;

use Uteq\Move\Fields\Concerns\HasResource;
use Uteq\Move\Resource;

class HasOne extends Select
{
Expand All @@ -14,7 +13,7 @@ public function __construct(string $name, string $attribute, string $resource, \
$this->resourceName = $this->findResourceName($name, $resource);

/** @psalm-suppress UnusedClosureParam */
$valueCallback ??= function($value) use ($resource) {
$valueCallback ??= function ($value) use ($resource) {
/** @psalm-suppress InvalidPropertyFetch */
$model = $resource::$model;

Expand Down
1 change: 0 additions & 1 deletion src/Fields/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class Placeholder extends Panel
{

}
5 changes: 4 additions & 1 deletion src/Fields/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

class Select extends Field
{
use WithModal, WithListeners, WithClosures, WithRedirects;
use WithModal;
use WithListeners;
use WithClosures;
use WithRedirects;

public string $component = 'select-field';

Expand Down
6 changes: 2 additions & 4 deletions src/Fields/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Closure;
use Uteq\Move\Actions\LivewireCloseModal;
use Uteq\Move\Facades\Move;
use Uteq\Move\Fields\Concerns\WithStackableFields;

class Table extends Panel
{
Expand All @@ -23,8 +22,7 @@ public function __construct(
$name,
public string $resourceClass,
array $fields = null
)
{
) {
$this->id = static::class . md5($resourceClass);

$this->withMeta([
Expand Down Expand Up @@ -120,7 +118,7 @@ public function fields(): \Illuminate\Support\Collection

return collect($fields)
->filter(fn ($field) => in_array($field->attribute, $this->showFields, true))
->filter(fn ($field) => !in_array($field->attribute, $this->hideFields, true))
->filter(fn ($field) => ! in_array($field->attribute, $this->hideFields, true))
->each(function ($field) {
$field->storePrefix = $field->defaultStorePrefix . '.' . $this->id();
$field->hideName();
Expand Down
2 changes: 1 addition & 1 deletion src/File/ResourceFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getPath()
$dir = dirname($path);

if (! file_exists($dir)) {
if (!mkdir($dir, recursive: true) && !is_dir($dir)) {
if (! mkdir($dir, recursive: true) && ! is_dir($dir)) {
throw new RuntimeException(sprintf('Directory "%s" was not created', $dir));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Livewire/HeaderSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function searchResult()
->filter(function ($resource) {
$resourceModel = $resource::$model;

return Schema::hasTable((new $resourceModel)->getTable());
return Schema::hasTable((new $resourceModel())->getTable());
})
->map(function ($resource, $key) {
$resourceModel = $resource::$model;
Expand Down
2 changes: 1 addition & 1 deletion src/MoveServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function register()
public function registerComponentAutoDiscovery(): void
{
$this->app->singleton(ResourceFinder::class, function () {
return new ResourceFinder(new Filesystem, base_path() . DIRECTORY_SEPARATOR);
return new ResourceFinder(new Filesystem(), base_path() . DIRECTORY_SEPARATOR);
});
}

Expand Down
6 changes: 2 additions & 4 deletions src/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function newModel(): ?Model
{
$model = isset(static::$model) ? static::$model : null;

return $model ? new $model : null;
return $model ? new $model() : null;
}

public static function singularLabel(): string
Expand Down Expand Up @@ -233,8 +233,7 @@ public function getForDetail($requestQuery): array
public function handler(string $key, array $args = [])
{
return app()->make($this->actionHandlers[$key]
?? (static::$defaultActionHandlers[$key] ?? null)
, $args);
?? (static::$defaultActionHandlers[$key] ?? null), $args);
}

public function handleAction(string $key, Model $model, array $fields, string $from, array $args = [])
Expand Down Expand Up @@ -470,7 +469,6 @@ public function route()

public function fullRoute($action): void
{

}

public function icon()
Expand Down
6 changes: 3 additions & 3 deletions src/Status/TrashedStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class TrashedStatus
{
const DEFAULT = '';
const WITH = 'with';
const ONLY = 'only';
public const DEFAULT = '';
public const WITH = 'with';
public const ONLY = 'only';

public static function fromBoolean($status): string
{
Expand Down
12 changes: 6 additions & 6 deletions src/Support/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

class Encoding
{
const ICONV_TRANSLIT = "TRANSLIT";
const ICONV_IGNORE = "IGNORE";
const WITHOUT_ICONV = "";
public const ICONV_TRANSLIT = "TRANSLIT";
public const ICONV_IGNORE = "IGNORE";
public const WITHOUT_ICONV = "";

protected static $win1252ToUtf8 = [
128 => "\xe2\x82\xac",
Expand Down Expand Up @@ -194,9 +194,9 @@ public static function toUTF8($text)
for ($i = 0; $i < $max; $i++) {
$c1 = $text[$i];
if ($c1 >= "\xc0") { //Should be converted to UTF8, if it's not UTF8 already
$c2 = $i + 1 >= $max? "\x00" : $text[$i + 1];
$c3 = $i + 2 >= $max? "\x00" : $text[$i + 2];
$c4 = $i + 3 >= $max? "\x00" : $text[$i + 3];
$c2 = $i + 1 >= $max ? "\x00" : $text[$i + 1];
$c3 = $i + 2 >= $max ? "\x00" : $text[$i + 2];
$c4 = $i + 3 >= $max ? "\x00" : $text[$i + 3];
if ($c1 >= "\xc0" & $c1 <= "\xdf") { //looks like 2 bytes UTF8
if ($c2 >= "\x80" && $c2 <= "\xbf") { //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2;
Expand Down
1 change: 0 additions & 1 deletion src/Support/Livewire/Concerns/HasStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function hasStoreRefreshModel(): void

public function save()
{

$this->hasStoreRefreshModel();

$store = move_arr_expand($this->store);
Expand Down
4 changes: 3 additions & 1 deletion src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ function move_class_to_label($class): string
* @param array $array
* @return array
*/
function move_arr_expand(array $array) {
function move_arr_expand(array $array)
{
$valueSet = [];
foreach ($array as $key => $item) {
Arr::set($valueSet, $key, $item);
}

return $valueSet;
}

0 comments on commit ad3c93f

Please sign in to comment.