Skip to content

Commit

Permalink
Update coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscris committed Jan 9, 2025
1 parent adea5bf commit c8fe11f
Show file tree
Hide file tree
Showing 122 changed files with 136 additions and 252 deletions.
1 change: 0 additions & 1 deletion formwork/fields/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Formwork\Data\Contracts\Arrayable;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;

use Formwork\Fields\Field;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/number.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;

use Formwork\Fields\Field;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/range.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;

use Formwork\Fields\Field;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Formwork\Cms\App;
use Formwork\Fields\Field;

use Formwork\Utils\Arr;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
2 changes: 1 addition & 1 deletion formwork/fields/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

if ($field->has('pattern')) {
$value = array_filter($value, static fn ($item): bool => Constraint::matchesRegex($item, $field->get('pattern')));
$value = array_filter($value, static fn($item): bool => Constraint::matchesRegex($item, $field->get('pattern')));
}

return array_values(array_filter($value));
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Formwork\Cms\App;
use Formwork\Fields\Exceptions\ValidationException;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
1 change: 0 additions & 1 deletion formwork/fields/togglegroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Formwork\Cms\App;
use Formwork\Fields\Field;

use Formwork\Utils\Constraint;

return function (App $app) {
Expand Down
2 changes: 1 addition & 1 deletion formwork/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
return Date::formatTimestampAsDistance($timestamp, $app->translations()->getCurrent());
},

'translate' => fn (string $key, ...$arguments) => $app->translations()->getCurrent()->translate($key, ...$arguments),
'translate' => fn(string $key, ...$arguments) => $app->translations()->getCurrent()->translate($key, ...$arguments),
];
};
2 changes: 1 addition & 1 deletion formwork/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

// Log requests to the console as if they were not rewritten
register_shutdown_function(fn () => error_log(sprintf(
register_shutdown_function(fn() => error_log(sprintf(
'%s:%d [%d]: %s %s',
$_SERVER['REMOTE_ADDR'],
$_SERVER['REMOTE_PORT'],
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Backup/Backupper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ final class Backupper
*/
public function __construct(
private array $options,
) {
}
) {}

/**
* Make a backup of all site files
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public function __construct(
protected mixed $value,
protected int $expirationTime,
protected int $cachedTime,
) {
}
) {}

/**
* Return the cached value
Expand Down
12 changes: 6 additions & 6 deletions formwork/src/Cms/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ private function loadServices(Container $container): void
->alias('config');

$container->define(ViewFactory::class)
->parameter('methods', fn (Container $container) => $container->call(require SYSTEM_PATH . '/helpers.php'));
->parameter('methods', fn(Container $container) => $container->call(require SYSTEM_PATH . '/helpers.php'));

$container->define(Request::class, fn () => Request::fromGlobals())
$container->define(Request::class, fn() => Request::fromGlobals())
->alias('request');

$container->define(ErrorsController::class)
Expand Down Expand Up @@ -233,13 +233,13 @@ private function loadServices(Container $container): void
->alias('templates');

$container->define(Statistics::class)
->parameter('path', fn (Config $config) => $config->get('system.statistics.path'))
->parameter('translation', fn (Translations $translations) => $translations->getCurrent())
->parameter('path', fn(Config $config) => $config->get('system.statistics.path'))
->parameter('translation', fn(Translations $translations) => $translations->getCurrent())
->alias('statistics');

$container->define(FilesCache::class)
->parameter('path', fn (Config $config) => $config->get('system.cache.path'))
->parameter('defaultTtl', fn (Config $config) => $config->get('system.cache.time'))
->parameter('path', fn(Config $config) => $config->get('system.cache.path'))
->parameter('defaultTtl', fn(Config $config) => $config->get('system.cache.time'))
->alias(AbstractCache::class)
->alias('cache');

Expand Down
2 changes: 1 addition & 1 deletion formwork/src/Cms/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function defaults(): array
{
$defaults = $this->config->getDefaults('site');

return [...$defaults, ...Arr::reject($this->fields()->pluck('default'), fn ($value) => $value === null)];
return [...$defaults, ...Arr::reject($this->fields()->pluck('default'), fn($value) => $value === null)];
}

public function parent(): Page|Site|null
Expand Down
2 changes: 1 addition & 1 deletion formwork/src/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function handleOutput(array $lines): void
$this->climate->br();

$input = $this->climate->input('➜ Enter another port:');
$input->accept(fn (string $response) => ctype_digit($response));
$input->accept(fn(string $response) => ctype_digit($response));

$this->port = (int) $input->prompt();

Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class Config implements ArraySerializable
final public function __construct(
protected array $config = [],
protected array $defaults = [],
) {
}
) {}

/**
* Check if a key exists in the config
Expand Down
4 changes: 1 addition & 3 deletions formwork/src/Config/Exceptions/ConfigResolutionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use RuntimeException;

class ConfigResolutionException extends RuntimeException
{
}
class ConfigResolutionException extends RuntimeException {}
4 changes: 1 addition & 3 deletions formwork/src/Config/Exceptions/UnresolvedConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use RuntimeException;

class UnresolvedConfigException extends RuntimeException
{
}
class UnresolvedConfigException extends RuntimeException {}
8 changes: 4 additions & 4 deletions formwork/src/Data/AbstractCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(array $data = [])
));
}

if ($this->dataType !== null && !Arr::every($data, fn ($value) => Constraint::isOfType($value, $this->dataType, unionTypes: true))) {
if ($this->dataType !== null && !Arr::every($data, fn($value) => Constraint::isOfType($value, $this->dataType, unionTypes: true))) {
throw new LogicException('Typed collections cannot be created from data of different types');
}

Expand Down Expand Up @@ -245,7 +245,7 @@ public function clone(): static
public function deepClone(): static
{
$clone = $this->clone();
$clone->data = Arr::map($clone->data, fn ($value) => is_object($value) ? clone $value : $value);
$clone->data = Arr::map($clone->data, fn($value) => is_object($value) ? clone $value : $value);
return $clone;
}

Expand Down Expand Up @@ -416,7 +416,7 @@ public function filterBy(string $key, mixed $value = true, mixed $default = null
$strict ??= true;
}

return $this->filter(fn ($v, $k) => Constraint::isEqualTo($values[$k], $comparison ??= $value, $strict ??= false));
return $this->filter(fn($v, $k) => Constraint::isEqualTo($values[$k], $comparison ??= $value, $strict ??= false));
}

/**
Expand All @@ -440,7 +440,7 @@ public function sortBy(
public function groupBy(string $key, mixed $default = null): array
{
$values = $this->pluck($key, $default);
return $this->group(fn ($v, $k) => $values[$k]);
return $this->group(fn($v, $k) => $values[$k]);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Data/CollectionDataProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ final class CollectionDataProxy
{
public function __construct(
private AbstractCollection $collection,
) {
}
) {}

public function __get(string $name): Collection
{
Expand Down
4 changes: 1 addition & 3 deletions formwork/src/Exceptions/RecursionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use RuntimeException;

class RecursionException extends RuntimeException
{
}
class RecursionException extends RuntimeException {}
3 changes: 1 addition & 2 deletions formwork/src/Fields/Dynamic/DynamicFieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public function __construct(
protected string $key,
protected string $uncomputedValue,
protected Field $field,
) {
}
) {}

/**
* Create an instance with an already computed value
Expand Down
4 changes: 1 addition & 3 deletions formwork/src/Fields/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Formwork\Data\Exceptions\InvalidValueException;

class ValidationException extends InvalidValueException
{
}
class ValidationException extends InvalidValueException {}
2 changes: 1 addition & 1 deletion formwork/src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ protected function translate(mixed $value): mixed
return $value;
}

$interpolate = fn ($value) => is_string($value) ? Str::interpolate($value, fn ($key) => $this->translation->translate($key)) : $value;
$interpolate = fn($value) => is_string($value) ? Str::interpolate($value, fn($key) => $this->translation->translate($key)) : $value;

if (is_array($value)) {
return Arr::map($value, $interpolate);
Expand Down
4 changes: 2 additions & 2 deletions formwork/src/Fields/FieldCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public function validate(): static
*/
public function isValid(): bool
{
return $this->every(fn ($field) => $field->isValid());
return $this->every(fn($field) => $field->isValid());
}

/**
* Return whether every field in the collection has been validated
*/
public function isValidated(): bool
{
return $this->every(fn ($field) => $field->isValidated());
return $this->every(fn($field) => $field->isValidated());
}

/**
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Fields/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public function __construct(
private Container $container,
private Config $config,
private Translations $translations,
) {
}
) {}

/**
* Create a new Field instance
Expand Down
2 changes: 1 addition & 1 deletion formwork/src/Fields/Layout/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function is(string $key, bool $default = false): bool
*/
public function label(): string
{
return Str::interpolate($this->get('label', ''), fn ($key) => $this->translation->translate($key));
return Str::interpolate($this->get('label', ''), fn($key) => $this->translation->translate($key));
}
}
2 changes: 1 addition & 1 deletion formwork/src/Fields/Layout/SectionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class SectionCollection extends AbstractCollection
*/
public function __construct(array $sections, Translation $translation)
{
parent::__construct(Arr::map($sections, fn ($section) => new Section($section, $translation)));
parent::__construct(Arr::map($sections, fn($section) => new Section($section, $translation)));
}
}
4 changes: 1 addition & 3 deletions formwork/src/Files/Exceptions/FileUriGenerationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use RuntimeException;

class FileUriGenerationException extends RuntimeException
{
}
class FileUriGenerationException extends RuntimeException {}
2 changes: 1 addition & 1 deletion formwork/src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function setScheme(Scheme $scheme): void
private function matchExtensions(array $extensions): bool
{
$mimeTypes = array_map(
static fn (string $extension): string => MimeType::fromExtension($extension),
static fn(string $extension): string => MimeType::fromExtension($extension),
$extensions
);
return in_array($this->mimeType, $mimeTypes, true);
Expand Down
2 changes: 1 addition & 1 deletion formwork/src/Files/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FileCollection extends AbstractCollection
public function __construct(array $data = [])
{
if (!Arr::isAssociative($data)) {
$data = Arr::mapKeys($data, fn ($key, File $file) => $file->name());
$data = Arr::mapKeys($data, fn($key, File $file) => $file->name());
}

parent::__construct($data);
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Files/FileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public function __construct(
private Config $config,
private Schemes $schemes,
private array $associations = [],
) {
}
) {}

/**
* Create a new File instance
Expand Down
3 changes: 1 addition & 2 deletions formwork/src/Files/FileUriGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function __construct(
protected Router $router,
protected Request $request,
protected Site $site,
) {
}
) {}

/**
* Generate URI for the given File
Expand Down
2 changes: 1 addition & 1 deletion formwork/src/Files/Services/FileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
protected Config $config,
protected FileFactory $fileFactory,
) {
$this->allowedMimeTypes = Arr::map($this->config->get('system.files.allowedExtensions'), fn (string $ext) => MimeType::fromExtension($ext));
$this->allowedMimeTypes = Arr::map($this->config->get('system.files.allowedExtensions'), fn(string $ext) => MimeType::fromExtension($ext));
}

/**
Expand Down
Loading

0 comments on commit c8fe11f

Please sign in to comment.