Update Composer packages

This commit is contained in:
Paul Nicoué 2022-12-19 14:56:05 +01:00
parent 0320235f6c
commit a8b68fb61b
378 changed files with 28466 additions and 28852 deletions

View file

@ -2,6 +2,7 @@
namespace Kirby\Form;
use Closure;
use Exception;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\A;
@ -86,7 +87,7 @@ class Field extends Component
{
if (
isset($this->options['api']) === true &&
is_a($this->options['api'], 'Closure') === true
$this->options['api'] instanceof Closure
) {
return $this->options['api']->call($this);
}
@ -112,7 +113,7 @@ class Field extends Component
return null;
}
if (is_a($save, 'Closure') === true) {
if ($save instanceof Closure) {
return $save->call($this, $value);
}
@ -472,7 +473,7 @@ class Field extends Component
continue;
}
if (is_a($validation, 'Closure') === true) {
if ($validation instanceof Closure) {
try {
$validation->call($this, $this->value());
} catch (Exception $e) {

View file

@ -57,7 +57,7 @@ class BlocksField extends FieldClass
$block['content'] = $this->form($fields[$type], $block['content'])->$to();
$result[] = $block;
} catch (Throwable $e) {
} catch (Throwable) {
$result[] = $block;
// skip invalid blocks
@ -87,7 +87,7 @@ class BlocksField extends FieldClass
return $this->fieldsets;
}
public function fieldsetGroups(): ?array
public function fieldsetGroups(): array|null
{
$fieldsetGroups = $this->fieldsets()->groups();
return empty($fieldsetGroups) === true ? null : $fieldsetGroups;
@ -253,8 +253,9 @@ class BlocksField extends FieldClass
$blockType = $block['type'];
try {
$blockFields = $fields[$blockType] ?? $this->fields($blockType) ?? [];
} catch (Throwable $e) {
$fieldset = $this->fieldset($blockType);
$blockFields = $fields[$blockType] ?? $fieldset->fields() ?? [];
} catch (Throwable) {
// skip invalid blocks
continue;
}
@ -271,7 +272,9 @@ class BlocksField extends FieldClass
throw new InvalidArgumentException([
'key' => 'blocks.validation',
'data' => [
'index' => $index,
'field' => $field->label(),
'fieldset' => $fieldset->name(),
'index' => $index
]
]);
}

View file

@ -56,7 +56,7 @@ class LayoutField extends BlocksField
]);
}
public function layouts(): ?array
public function layouts(): array|null
{
return $this->layouts;
}
@ -200,8 +200,9 @@ class LayoutField extends BlocksField
$blockType = $block['type'];
try {
$fieldset = $this->fieldset($blockType);
$blockFields = $fields[$blockType] ?? $this->fields($blockType) ?? [];
} catch (Throwable $e) {
} catch (Throwable) {
// skip invalid blocks
continue;
}
@ -219,6 +220,8 @@ class LayoutField extends BlocksField
'key' => 'layout.validation.block',
'data' => [
'blockIndex' => $blockIndex,
'field' => $field->label(),
'fieldset' => $fieldset->name(),
'layoutIndex' => $layoutIndex
]
]);

View file

@ -2,6 +2,7 @@
namespace Kirby\Form;
use Closure;
use Exception;
use Kirby\Cms\App;
use Kirby\Cms\HasSiblings;
@ -162,7 +163,7 @@ abstract class FieldClass
/**
* @return string|null
*/
public function after(): ?string
public function after(): string|null
{
return $this->stringTemplate($this->after);
}
@ -186,7 +187,7 @@ abstract class FieldClass
/**
* @return string|null
*/
public function before(): ?string
public function before(): string|null
{
return $this->stringTemplate($this->before);
}
@ -259,7 +260,7 @@ abstract class FieldClass
*
* @return string|null
*/
public function help(): ?string
public function help(): string|null
{
if (empty($this->help) === false) {
$help = $this->stringTemplate($this->help);
@ -274,7 +275,7 @@ abstract class FieldClass
* @param string|array|null $param
* @return string|null
*/
protected function i18n($param = null): ?string
protected function i18n($param = null): string|null
{
return empty($param) === false ? I18n::translate($param, $param) : null;
}
@ -284,7 +285,7 @@ abstract class FieldClass
*
* @return string|null
*/
public function icon(): ?string
public function icon(): string|null
{
return $this->icon;
}
@ -457,7 +458,7 @@ abstract class FieldClass
*
* @return string|null
*/
public function placeholder(): ?string
public function placeholder(): string|null
{
return $this->stringTemplate($this->placeholder);
}
@ -578,7 +579,7 @@ abstract class FieldClass
* @param string|null $icon
* @return void
*/
protected function setIcon(?string $icon = null)
protected function setIcon(string|null $icon = null)
{
$this->icon = $icon;
}
@ -684,7 +685,7 @@ abstract class FieldClass
* @param string|null $string
* @return string|null
*/
protected function stringTemplate(?string $string = null): ?string
protected function stringTemplate(string|null $string = null): string|null
{
if ($string !== null) {
return $this->model->toString($string);
@ -767,7 +768,7 @@ abstract class FieldClass
continue;
}
if (is_a($validation, 'Closure') === true) {
if ($validation instanceof Closure) {
try {
$validation->call($this, $value);
} catch (Exception $e) {
@ -816,7 +817,7 @@ abstract class FieldClass
{
try {
return Data::decode($value, 'json');
} catch (Throwable $e) {
} catch (Throwable) {
return [];
}
}
@ -858,7 +859,7 @@ abstract class FieldClass
*
* @return array|null
*/
public function when(): ?array
public function when(): array|null
{
return $this->when;
}

View file

@ -2,6 +2,7 @@
namespace Kirby\Form;
use Closure;
use Kirby\Cms\App;
use Kirby\Cms\Model;
use Kirby\Data\Data;
@ -108,9 +109,7 @@ class Form
$input = array_merge($values, $input);
foreach ($input as $key => $value) {
if (isset($this->values[$key]) === false) {
$this->values[$key] = $value;
}
$this->values[$key] ??= $value;
}
}
}
@ -260,7 +259,7 @@ class Form
// convert closures to values
foreach ($values as $key => $value) {
if (is_a($value, 'Closure') === true) {
if ($value instanceof Closure) {
$values[$key] = $value($original[$key] ?? null);
}
}
@ -316,7 +315,7 @@ class Form
* @param string|null $language
* @return array
*/
protected static function prepareFieldsForLanguage(array $fields, ?string $language = null): array
protected static function prepareFieldsForLanguage(array $fields, string|null $language = null): array
{
$kirby = App::instance(null, true);

View file

@ -11,7 +11,7 @@ trait EmptyState
$this->empty = $this->i18n($empty);
}
public function empty(): ?string
public function empty(): string|null
{
return $this->stringTemplate($this->empty);
}

View file

@ -6,7 +6,7 @@ trait Max
{
protected $max;
public function max(): ?int
public function max(): int|null
{
return $this->max;
}

View file

@ -6,7 +6,7 @@ trait Min
{
protected $min;
public function min(): ?int
public function min(): int|null
{
return $this->min;
}

View file

@ -16,6 +16,8 @@ use Kirby\Toolkit\I18n;
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*
* @deprecated 3.8.0 Use `Kirby\Option\Options` instead
*/
class Options
{
@ -87,7 +89,7 @@ class Options
// add the model by the proper alias
foreach (static::aliases() as $className => $alias) {
if (is_a($model, $className) === true) {
if ($model instanceof $className) {
$data[$alias] = $model;
}
}
@ -105,30 +107,23 @@ class Options
*/
public static function factory($options, array $props = [], $model = null): array
{
switch ($options) {
case 'api':
$options = static::api($props['api'], $model);
break;
case 'query':
$options = static::query($props['query'], $model);
break;
case 'children':
case 'grandChildren':
case 'siblings':
case 'index':
case 'files':
case 'images':
case 'documents':
case 'videos':
case 'audio':
case 'code':
case 'archives':
$options = static::query('page.' . $options, $model);
break;
case 'pages':
$options = static::query('site.index', $model);
break;
}
$options = match ($options) {
'api' => static::api($props['api'], $model),
'query' => static::query($props['query'], $model),
'pages' => static::query('site.index', $model),
'children',
'grandChildren',
'siblings',
'index',
'files',
'images',
'documents',
'videos',
'audio',
'code',
'archives' => static::query('page.' . $options, $model),
default => $options
};
if (is_array($options) === false) {
return [];

View file

@ -7,8 +7,8 @@ use Kirby\Exception\Exception;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Http\Remote;
use Kirby\Http\Url;
use Kirby\Query\Query;
use Kirby\Toolkit\Properties;
use Kirby\Toolkit\Query;
use Kirby\Toolkit\Str;
/**
@ -20,6 +20,8 @@ use Kirby\Toolkit\Str;
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*
* @deprecated 3.8.0 Use `Kirby\Option\OptionsApi` instead
*/
class OptionsApi
{
@ -132,7 +134,7 @@ class OptionsApi
throw new InvalidArgumentException('Invalid options format');
}
$result = (new Query($this->fetch(), Nest::create($data)))->result();
$result = (new Query($this->fetch()))->resolve(Nest::create($data));
$options = [];
foreach ($result as $item) {
@ -161,7 +163,7 @@ class OptionsApi
* @param string|null $fetch
* @return $this
*/
protected function setFetch(?string $fetch = null)
protected function setFetch(string|null $fetch = null)
{
$this->fetch = $fetch;
return $this;
@ -181,7 +183,7 @@ class OptionsApi
* @param string $text
* @return $this
*/
protected function setText(?string $text = null)
protected function setText(string|null $text = null)
{
$this->text = $text;
return $this;
@ -201,7 +203,7 @@ class OptionsApi
* @param string|null $value
* @return $this
*/
protected function setValue(?string $value = null)
protected function setValue(string|null $value = null)
{
$this->value = $value;
return $this;

View file

@ -5,10 +5,10 @@ namespace Kirby\Form;
use Kirby\Cms\Field;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Exception\NotFoundException;
use Kirby\Query\Query;
use Kirby\Toolkit\Collection;
use Kirby\Toolkit\Obj;
use Kirby\Toolkit\Properties;
use Kirby\Toolkit\Query;
use Kirby\Toolkit\Str;
/**
@ -22,6 +22,8 @@ use Kirby\Toolkit\Str;
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*
* @deprecated 3.8.0 Use `Kirby\Option\OptionsQuery` instead
*/
class OptionsQuery
{
@ -115,8 +117,8 @@ class OptionsQuery
}
$data = $this->data();
$query = new Query($this->query(), $data);
$result = $query->result();
$query = new Query($this->query());
$result = $query->resolve($data);
$result = $this->resultToCollection($result);
$options = [];
@ -154,7 +156,7 @@ class OptionsQuery
// slow but precise resolving
foreach ($this->aliases as $className => $alias) {
if (is_a($object, $className) === true) {
if ($object instanceof $className) {
return $alias;
}
}
@ -181,7 +183,7 @@ class OptionsQuery
$result = new Collection($result);
}
if (is_a($result, 'Kirby\Toolkit\Collection') === false) {
if ($result instanceof Collection === false) {
throw new InvalidArgumentException('Invalid query result data');
}
@ -192,7 +194,7 @@ class OptionsQuery
* @param array|null $aliases
* @return $this
*/
protected function setAliases(?array $aliases = null)
protected function setAliases(array|null $aliases = null)
{
$this->aliases = $aliases;
return $this;