Skip to content

Commit b45fb86

Browse files
committed
refactor: Add #[\Override] attribute to Cms namespace
1 parent fe9df18 commit b45fb86

40 files changed

+139
-0
lines changed

src/Cms/Block.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Kirby\Content\Field;
77
use Kirby\Exception\InvalidArgumentException;
88
use Kirby\Toolkit\Str;
9+
use Override;
910
use Stringable;
1011
use Throwable;
1112

@@ -85,6 +86,7 @@ public function __construct(array $params)
8586
/**
8687
* Converts the object to a string
8788
*/
89+
#[Override]
8890
public function __toString(): string
8991
{
9092
return $this->toHtml();
@@ -129,6 +131,7 @@ public function excerpt(mixed ...$args): string
129131
*
130132
* @throws \Kirby\Exception\InvalidArgumentException
131133
*/
134+
#[Override]
132135
public static function factory(array $params): static
133136
{
134137
return static::model($params['type'] ?? 'default', $params);
@@ -179,6 +182,7 @@ public function type(): string
179182
* The result is being sent to the editor
180183
* via the API in the panel
181184
*/
185+
#[Override]
182186
public function toArray(): array
183187
{
184188
return [

src/Cms/Blocks.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Kirby\Parsley\Schema\Blocks as BlockSchema;
1010
use Kirby\Toolkit\A;
1111
use Kirby\Toolkit\Str;
12+
use Override;
1213
use Throwable;
1314

1415
/**
@@ -36,6 +37,7 @@ class Blocks extends Items
3637
* Return HTML when the collection is
3738
* converted to a string
3839
*/
40+
#[Override]
3941
public function __toString(): string
4042
{
4143
return $this->toHtml();
@@ -55,6 +57,7 @@ public function excerpt(mixed ...$args): string
5557
* Wrapper around the factory to
5658
* catch blocks from layouts
5759
*/
60+
#[Override]
5861
public static function factory(
5962
array|null $items = null,
6063
array $params = []

src/Cms/Collection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Kirby\Toolkit\Collection as BaseCollection;
88
use Kirby\Toolkit\Str;
99
use Kirby\Uuid\Uuid;
10+
use Override;
1011

1112
/**
1213
* The Collection class serves as foundation
@@ -42,6 +43,7 @@ class Collection extends BaseCollection
4243
* which is needed in some collections
4344
* to get the finder methods right
4445
*/
46+
#[Override]
4547
public function __construct(
4648
iterable $objects = [],
4749
protected object|null $parent = null
@@ -51,6 +53,7 @@ public function __construct(
5153
}
5254
}
5355

56+
#[Override]
5457
public function __call(string $key, $arguments)
5558
{
5659
// collection methods
@@ -68,6 +71,7 @@ public function __call(string $key, $arguments)
6871
*
6972
* @param TValue $object
7073
*/
74+
#[Override]
7175
public function __set(string $id, $object): void
7276
{
7377
$this->data[$id] = $object;
@@ -78,6 +82,7 @@ public function __set(string $id, $object): void
7882
* override from the Toolkit Collection is needed to
7983
* make the CMS collections case-sensitive
8084
*/
85+
#[Override]
8186
public function __unset(string $id)
8287
{
8388
unset($this->data[$id]);
@@ -118,6 +123,7 @@ public function add($object): static
118123
* @param string|TValue ...$args
119124
* @return $this
120125
*/
126+
#[Override]
121127
public function append(...$args): static
122128
{
123129
if (count($args) === 1) {
@@ -140,6 +146,7 @@ public function append(...$args): static
140146
*
141147
* @return TValue|null
142148
*/
149+
#[Override]
143150
public function findBy(string $attribute, $value)
144151
{
145152
// $value: cast UUID object to string to allow uses
@@ -159,6 +166,7 @@ public function findBy(string $attribute, $value)
159166
* @param bool $caseInsensitive Ignore upper/lowercase for group names
160167
* @throws \Kirby\Exception\Exception
161168
*/
169+
#[Override]
162170
public function group(
163171
$field,
164172
bool $caseInsensitive = true
@@ -207,6 +215,7 @@ public function group(
207215
*
208216
* @param string|TValue $key
209217
*/
218+
#[Override]
210219
public function has($key): bool
211220
{
212221
if (is_object($key) === true) {
@@ -223,6 +232,7 @@ public function has($key): bool
223232
*
224233
* @param string|TValue $needle
225234
*/
235+
#[Override]
226236
public function indexOf($needle): int|false
227237
{
228238
if (is_string($needle) === true) {
@@ -264,6 +274,7 @@ public function not(string|array|object ...$keys): static
264274
*
265275
* @return $this|static
266276
*/
277+
#[Override]
267278
public function paginate(...$arguments): static
268279
{
269280
$this->pagination = Pagination::for($this, ...$arguments);
@@ -278,6 +289,7 @@ public function paginate(...$arguments): static
278289
/**
279290
* Get the previously added pagination object
280291
*/
292+
#[Override]
281293
public function pagination(): Pagination|null
282294
{
283295
return $this->pagination;
@@ -302,6 +314,7 @@ public function parent(): object|null
302314
* @param string|TValue ...$args
303315
* @return $this
304316
*/
317+
#[Override]
305318
public function prepend(...$args): static
306319
{
307320
if (count($args) === 1) {
@@ -324,6 +337,7 @@ public function prepend(...$args): static
324337
* offset, limit, search and paginate on the collection.
325338
* Any part of the query is optional.
326339
*/
340+
#[Override]
327341
public function query(array $arguments = []): static
328342
{
329343
$paginate = $arguments['paginate'] ?? null;
@@ -355,6 +369,7 @@ public function query(array $arguments = []): static
355369
*
356370
* @param string|TValue $key the name of the key
357371
*/
372+
#[Override]
358373
public function remove(string|object $key): static
359374
{
360375
if (is_object($key) === true) {
@@ -379,6 +394,7 @@ public function search(
379394
* to an array. This can also take a callback
380395
* function to further modify the array result.
381396
*/
397+
#[Override]
382398
public function toArray(Closure|null $map = null): array
383399
{
384400
return parent::toArray(

src/Cms/Event.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Kirby\Content\ImmutableMemoryStorage;
77
use Kirby\Exception\InvalidArgumentException;
88
use Kirby\Toolkit\Controller;
9+
use Override;
910
use Stringable;
1011

1112
/**
@@ -85,6 +86,7 @@ public function __debugInfo(): array
8586
* Makes it possible to simply echo
8687
* or stringify the entire object
8788
*/
89+
#[Override]
8890
public function __toString(): string
8991
{
9092
return $this->toString();

src/Cms/Fieldset.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Kirby\Form\Form;
77
use Kirby\Toolkit\I18n;
88
use Kirby\Toolkit\Str;
9+
use Override;
910

1011
/**
1112
* Represents a single Fieldset
@@ -210,6 +211,7 @@ public function type(): string
210211
return $this->type;
211212
}
212213

214+
#[Override]
213215
public function toArray(): array
214216
{
215217
return [

src/Cms/Fieldsets.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Kirby\Toolkit\A;
77
use Kirby\Toolkit\I18n;
88
use Kirby\Toolkit\Str;
9+
use Override;
910

1011
/**
1112
* A collection of fieldsets
@@ -75,6 +76,7 @@ protected static function createFieldsets(array $params): array
7576
];
7677
}
7778

79+
#[Override]
7880
public static function factory(
7981
array|null $items = null,
8082
array $params = []
@@ -105,6 +107,7 @@ public function groups(): array
105107
return $this->options['groups'] ?? [];
106108
}
107109

110+
#[Override]
108111
public function toArray(Closure|null $map = null): array
109112
{
110113
return A::map(

src/Cms/File.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Kirby\Filesystem\IsFile;
1010
use Kirby\Panel\File as Panel;
1111
use Kirby\Toolkit\Str;
12+
use Override;
1213

1314
/**
1415
* The `$file` object provides a set
@@ -147,6 +148,7 @@ public function apiUrl(bool $relative = false): string
147148
/**
148149
* Returns the FileBlueprint object for the file
149150
*/
151+
#[Override]
150152
public function blueprint(): FileBlueprint
151153
{
152154
return $this->blueprint ??= FileBlueprint::factory(
@@ -160,6 +162,7 @@ public function blueprint(): FileBlueprint
160162
* Returns an array with all blueprints that are available for the file
161163
* by comparing files sections and files fields of the parent model
162164
*/
165+
#[Override]
163166
public function blueprints(string|null $inSection = null): array
164167
{
165168
// get cached results for the current file model
@@ -230,6 +233,7 @@ public function blueprints(string|null $inSection = null): array
230233
* other content.
231234
* @unstable
232235
*/
236+
#[Override]
233237
public function contentFileData(
234238
array $data,
235239
string|null $languageCode = null
@@ -296,6 +300,7 @@ public function html(array $attr = []): string
296300
/**
297301
* Returns the id
298302
*/
303+
#[Override]
299304
public function id(): string
300305
{
301306
if (
@@ -466,6 +471,7 @@ public function page(): Page|null
466471
/**
467472
* Returns the panel info object
468473
*/
474+
#[Override]
469475
public function panel(): Panel
470476
{
471477
return new Panel($this);
@@ -522,6 +528,7 @@ public function permissions(): FilePermissions
522528
/**
523529
* Returns the absolute root to the file
524530
*/
531+
#[Override]
525532
public function root(): string|null
526533
{
527534
return $this->root ??= $this->parent()->root() . '/' . $this->filename();
@@ -562,6 +569,7 @@ protected function siblingsCollection(): Files
562569
/**
563570
* Returns the parent Site object
564571
*/
572+
#[Override]
565573
public function site(): Site
566574
{
567575
if ($this->parent() instanceof Site) {
@@ -592,6 +600,7 @@ public function templateSiblings(bool $self = true): Files
592600
* by injecting the information from
593601
* the asset.
594602
*/
603+
#[Override]
595604
public function toArray(): array
596605
{
597606
return [

src/Cms/FilePermissions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Kirby\Cms;
44

5+
use Override;
6+
57
/**
68
* FilePermissions
79
*
@@ -18,6 +20,7 @@ class FilePermissions extends ModelPermissions
1820
/**
1921
* Used to cache once determined permissions in memory
2022
*/
23+
#[Override]
2124
protected static function cacheKey(ModelWithContent|Language $model): string
2225
{
2326
return $model->template() ?? '__none__';

src/Cms/FilePicker.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Kirby\Cms;
44

55
use Kirby\Exception\InvalidArgumentException;
6+
use Override;
67

78
/**
89
* The FilePicker class helps to
@@ -20,6 +21,7 @@ class FilePicker extends Picker
2021
/**
2122
* Extends the basic defaults
2223
*/
24+
#[Override]
2325
public function defaults(): array
2426
{
2527
return [
@@ -33,6 +35,7 @@ public function defaults(): array
3335
*
3436
* @throws \Kirby\Exception\InvalidArgumentException
3537
*/
38+
#[Override]
3639
public function items(): Files|null
3740
{
3841
$model = $this->options['model'];

src/Cms/Files.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Kirby\Exception\NotFoundException;
88
use Kirby\Filesystem\F;
99
use Kirby\Uuid\HasUuids;
10+
use Override;
1011
use Throwable;
1112

1213
/**
@@ -48,6 +49,7 @@ class Files extends Collection
4849
* @return $this
4950
* @throws \Kirby\Exception\InvalidArgumentException When no `File` or `Files` object or an ID of an existing file is passed
5051
*/
52+
#[Override]
5153
public function add($object): static
5254
{
5355
// add a files collection

0 commit comments

Comments
 (0)