Skip to content

Commit

Permalink
Fix deprecated null type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Nov 23, 2024
1 parent abeb351 commit 11e746c
Show file tree
Hide file tree
Showing 130 changed files with 349 additions and 346 deletions.
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'nullable_type_declaration' => ['syntax' => 'union'],
'nullable_type_declaration_for_default_null_value' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'ordered_types' => ['sort_algorithm' => 'none', 'null_adjustment' => 'always_last'],
// 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], // adds params in the wrong order
'phpdoc_align' => ['align' => 'left'],
'phpdoc_indent' => true,
Expand Down
4 changes: 2 additions & 2 deletions config/areas/site/searches.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'pages' => [
'label' => I18n::translate('pages'),
'icon' => 'page',
'query' => function (string $query = null, int $limit, int $page) {
'query' => function (string|null $query = null, int $limit, int $page) {
$kirby = App::instance();
$pages = $kirby->site()
->index(true)
Expand All @@ -31,7 +31,7 @@
'files' => [
'label' => I18n::translate('files'),
'icon' => 'image',
'query' => function (string $query = null, int $limit, int $page) {
'query' => function (string|null $query = null, int $limit, int $page) {
$kirby = App::instance();
$files = $kirby->site()
->index(true)
Expand Down
2 changes: 1 addition & 1 deletion config/areas/users/searches.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'users' => [
'label' => I18n::translate('users'),
'icon' => 'users',
'query' => function (string $query = null, int $limit, int $page) {
'query' => function (string|null $query = null, int $limit, int $page) {
$kirby = App::instance();
$users = $kirby->users()
->search($query)
Expand Down
10 changes: 5 additions & 5 deletions config/components.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
*/
'markdown' => function (
App $kirby,
string $text = null,
string|null $text = null,
array $options = []
): string {
static $markdown;
Expand Down Expand Up @@ -230,15 +230,15 @@
$scoring['score'] += 16 * $score;
$scoring['hits'] += 1;

// check for exact beginning matches
// check for exact beginning matches
} elseif (
$options['words'] === false &&
Str::startsWith($lowerValue, $query) === true
) {
$scoring['score'] += 8 * $score;
$scoring['hits'] += 1;

// check for exact query matches
// check for exact query matches
} elseif ($matches = preg_match_all('!' . $exact . '!ui', $value, $r)) {
$scoring['score'] += 2 * $score;
$scoring['hits'] += $matches;
Expand Down Expand Up @@ -270,7 +270,7 @@
*/
'smartypants' => function (
App $kirby,
string $text = null,
string|null $text = null,
array $options = []
): string {
static $smartypants;
Expand Down Expand Up @@ -354,7 +354,7 @@
*/
'url' => function (
App $kirby,
string $path = null,
string|null $path = null,
$options = null
): string {
$language = null;
Expand Down
4 changes: 2 additions & 2 deletions config/fields/checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
/**
* Maximum number of checked boxes
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
* Minimum number of checked boxes
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
'value' => function ($value = null) {
Expand Down
6 changes: 3 additions & 3 deletions config/fields/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Default date when a new page/file/user gets created
*/
'default' => function (string $default = null): string {
'default' => function (string|null $default = null): string {
return $this->toDatetime($default) ?? '';
},

Expand All @@ -46,13 +46,13 @@
/**
* Latest date, which can be selected/saved (Y-m-d)
*/
'max' => function (string $max = null): string|null {
'max' => function (string|null $max = null): string|null {
return Date::optional($max);
},
/**
* Earliest date, which can be selected/saved (Y-m-d)
*/
'min' => function (string $min = null): string|null {
'min' => function (string|null $min = null): string|null {
return Date::optional($min);
},

Expand Down
2 changes: 1 addition & 1 deletion config/fields/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* Change the design of the info box
*/
'theme' => function (string $theme = null) {
'theme' => function (string|null $theme = null) {
return $theme;
}
],
Expand Down
2 changes: 1 addition & 1 deletion config/fields/mixins/datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Defines a custom format that is used when the field is saved
*/
'format' => function (string $format = null) {
'format' => function (string|null $format = null) {
return $format;
}
],
Expand Down
10 changes: 5 additions & 5 deletions config/fields/mixins/picker.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Info text for each item
*/
'info' => function (string $info = null) {
'info' => function (string|null $info = null) {
return $info;
},

Expand All @@ -37,14 +37,14 @@
/**
* The minimum number of required selected
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},

/**
* The maximum number of allowed selected
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},

Expand All @@ -58,7 +58,7 @@
/**
* Query for the items to be included in the picker
*/
'query' => function (string $query = null) {
'query' => function (string|null $query = null) {
return $query;
},

Expand Down Expand Up @@ -86,7 +86,7 @@
/**
* Main text for each item
*/
'text' => function (string $text = null) {
'text' => function (string|null $text = null) {
return $text;
},
],
Expand Down
2 changes: 1 addition & 1 deletion config/fields/mixins/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
return $map($file, $parent);
});
},
'uploadParent' => function (string $parentQuery = null) {
'uploadParent' => function (string|null $parentQuery = null) {
$parent = $this->model();

if ($parentQuery) {
Expand Down
4 changes: 2 additions & 2 deletions config/fields/number.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
/**
* The lowest allowed number
*/
'min' => function (float $min = null) {
'min' => function (float|null $min = null) {
return $min;
},
/**
* The highest allowed number
*/
'max' => function (float $max = null) {
'max' => function (float|null $max = null) {
return $max;
},
/**
Expand Down
2 changes: 1 addition & 1 deletion config/fields/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Optional query to select a specific set of pages
*/
'query' => function (string $query = null) {
'query' => function (string|null $query = null) {
return $query;
},

Expand Down
2 changes: 1 addition & 1 deletion config/fields/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Custom icon to replace the arrow down.
*/
'icon' => function (string $icon = null) {
'icon' => function (string|null $icon = null) {
return $icon;
},
/**
Expand Down
4 changes: 2 additions & 2 deletions config/fields/slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
/**
* Set prefix for the help text
*/
'path' => function (string $path = null) {
'path' => function (string|null $path = null) {
return $path;
},

/**
* Name of another field that should be used to
* automatically update this field's value
*/
'sync' => function (string $sync = null) {
'sync' => function (string|null $sync = null) {
return $sync;
},

Expand Down
14 changes: 7 additions & 7 deletions config/fields/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/**
* Set the default rows for the structure
*/
'default' => function (array $default = null) {
'default' => function (array|null $default = null) {
return $default;
},

Expand All @@ -58,38 +58,38 @@
/**
* The number of entries that will be displayed on a single page. Afterwards pagination kicks in.
*/
'limit' => function (int $limit = null) {
'limit' => function (int|null $limit = null) {
return $limit;
},
/**
* Maximum allowed entries in the structure. Afterwards the "Add" button will be switched off.
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
* Minimum required entries in the structure
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* Toggles adding to the top or bottom of the list
*/
'prepend' => function (bool $prepend = null) {
'prepend' => function (bool|null $prepend = null) {
return $prepend;
},
/**
* Toggles drag & drop sorting
*/
'sortable' => function (bool $sortable = null) {
'sortable' => function (bool|null $sortable = null) {
return $sortable;
},
/**
* Sorts the entries by the given field and order (i.e. `title desc`)
* Drag & drop is disabled in this case
*/
'sortBy' => function (string $sort = null) {
'sortBy' => function (string|null $sort = null) {
return $sort;
}
],
Expand Down
6 changes: 3 additions & 3 deletions config/fields/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
/**
* Minimum number of required entries/tags
*/
'min' => function (int $min = null) {
'min' => function (int|null $min = null) {
return $min;
},
/**
* Maximum number of allowed entries/tags
*/
'max' => function (int $max = null) {
'max' => function (int|null $max = null) {
return $max;
},
/**
Expand Down Expand Up @@ -93,7 +93,7 @@
return $value;
}
],
'save' => function (array $value = null): string {
'save' => function (array|null $value = null): string {
return A::join(
$value,
$this->separator() . ' '
Expand Down
8 changes: 4 additions & 4 deletions config/fields/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@
/**
* Sets the font family (sans or monospace)
*/
'font' => function (string $font = null) {
'font' => function (string|null $font = null) {
return $font === 'monospace' ? 'monospace' : 'sans-serif';
},

/**
* Maximum number of allowed characters
*/
'maxlength' => function (int $maxlength = null) {
'maxlength' => function (int|null $maxlength = null) {
return $maxlength;
},

/**
* Minimum number of required characters
*/
'minlength' => function (int $minlength = null) {
'minlength' => function (int|null $minlength = null) {
return $minlength;
},

/**
* A regular expression, which will be used to validate the input
*/
'pattern' => function (string $pattern = null) {
'pattern' => function (string|null $pattern = null) {
return $pattern;
},

Expand Down
Loading

0 comments on commit 11e746c

Please sign in to comment.