From 3bd087da8169a9e5b907655bef06025d270dd7a2 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 7 Sep 2020 20:53:54 +0300 Subject: [PATCH] refactor(entries-fields): update code according to coding doctrine coding standard --- src/flextype/Foundation/Entries/Fields/CreatedAtField.php | 4 ++-- src/flextype/Foundation/Entries/Fields/CreatedByField.php | 2 +- src/flextype/Foundation/Entries/Fields/IdField.php | 2 +- src/flextype/Foundation/Entries/Fields/ModifiedAtField.php | 2 +- src/flextype/Foundation/Entries/Fields/ParsersField.php | 4 ++-- .../Foundation/Entries/Fields/PublishedAtField.php | 4 ++-- .../Foundation/Entries/Fields/PublishedByField.php | 2 +- src/flextype/Foundation/Entries/Fields/RoutableField.php | 4 ++-- src/flextype/Foundation/Entries/Fields/SlugField.php | 7 +++---- src/flextype/Foundation/Entries/Fields/UuidField.php | 2 +- src/flextype/Foundation/Entries/Fields/VisibilityField.php | 4 ++-- 11 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/flextype/Foundation/Entries/Fields/CreatedAtField.php b/src/flextype/Foundation/Entries/Fields/CreatedAtField.php index e21e582f..972d3b15 100644 --- a/src/flextype/Foundation/Entries/Fields/CreatedAtField.php +++ b/src/flextype/Foundation/Entries/Fields/CreatedAtField.php @@ -10,13 +10,13 @@ declare(strict_types=1); use Flextype\Component\Filesystem\Filesystem; if (flextype('registry')->get('flextype.settings.entries.fields.created_at.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { flextype('entries')->storage['fetch_single']['data']['created_at'] = isset(flextype('entries')->storage['fetch_single']['data']['created_at']) ? (int) strtotime(flextype('entries')->storage['fetch_single']['data']['created_at']) : (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id'])); }); - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['created_at'])) { flextype('entries')->storage['create']['data']['created_at'] = flextype('entries')->storage['create']['data']['created_at']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/CreatedByField.php b/src/flextype/Foundation/Entries/Fields/CreatedByField.php index 59c81b84..bb73ab67 100644 --- a/src/flextype/Foundation/Entries/Fields/CreatedByField.php +++ b/src/flextype/Foundation/Entries/Fields/CreatedByField.php @@ -8,7 +8,7 @@ declare(strict_types=1); */ if (flextype('registry')->get('flextype.settings.entries.fields.created_by.enabled')) { - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['created_by'])) { flextype('entries')->storage['create']['data']['created_by'] = flextype('entries')->storage['create']['data']['created_by']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/IdField.php b/src/flextype/Foundation/Entries/Fields/IdField.php index a3203448..fad7ade6 100644 --- a/src/flextype/Foundation/Entries/Fields/IdField.php +++ b/src/flextype/Foundation/Entries/Fields/IdField.php @@ -8,7 +8,7 @@ declare(strict_types=1); */ if (flextype('registry')->get('flextype.settings.entries.fields.id.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { flextype('entries')->storage['fetch_single']['data']['id'] = isset(flextype('entries')->storage['fetch_single']['data']['id']) ? (string) flextype('entries')->storage['fetch_single']['data']['id'] : (string) ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/'); }); } diff --git a/src/flextype/Foundation/Entries/Fields/ModifiedAtField.php b/src/flextype/Foundation/Entries/Fields/ModifiedAtField.php index c10ea5a5..fb0acf2a 100644 --- a/src/flextype/Foundation/Entries/Fields/ModifiedAtField.php +++ b/src/flextype/Foundation/Entries/Fields/ModifiedAtField.php @@ -10,7 +10,7 @@ declare(strict_types=1); use Flextype\Component\Filesystem\Filesystem; if (flextype('registry')->get('flextype.settings.entries.fields.modified_at.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { flextype('entries')->storage['fetch_single']['data']['modified_at'] = (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id'])); }); } diff --git a/src/flextype/Foundation/Entries/Fields/ParsersField.php b/src/flextype/Foundation/Entries/Fields/ParsersField.php index adae36c2..27126933 100644 --- a/src/flextype/Foundation/Entries/Fields/ParsersField.php +++ b/src/flextype/Foundation/Entries/Fields/ParsersField.php @@ -10,12 +10,12 @@ declare(strict_types=1); use Flextype\Component\Arrays\Arrays; if (flextype('registry')->get('flextype.settings.entries.fields.parsers.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { processParsersField(); }); } -function processParsersField() : void +function processParsersField(): void { $cache = flextype('entries')->storage['fetch_single']['data']['cache']['enabled'] ?? flextype('registry')->get('flextype.settings.cache.enabled'); diff --git a/src/flextype/Foundation/Entries/Fields/PublishedAtField.php b/src/flextype/Foundation/Entries/Fields/PublishedAtField.php index 6f2f506f..a6466c74 100644 --- a/src/flextype/Foundation/Entries/Fields/PublishedAtField.php +++ b/src/flextype/Foundation/Entries/Fields/PublishedAtField.php @@ -10,13 +10,13 @@ declare(strict_types=1); use Flextype\Component\Filesystem\Filesystem; if (flextype('registry')->get('flextype.settings.entries.fields.published_at.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { flextype('entries')->storage['fetch_single']['data']['published_at'] = isset(flextype('entries')->storage['fetch_single']['data']['published_at']) ? (int) strtotime(flextype('entries')->storage['fetch_single']['data']['published_at']) : (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->storage['fetch_single']['id'])); }); - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['published_at'])) { flextype('entries')->storage['create']['data']['published_at'] = flextype('entries')->storage['create']['data']['published_at']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/PublishedByField.php b/src/flextype/Foundation/Entries/Fields/PublishedByField.php index 86ca4425..ff21abe3 100644 --- a/src/flextype/Foundation/Entries/Fields/PublishedByField.php +++ b/src/flextype/Foundation/Entries/Fields/PublishedByField.php @@ -8,7 +8,7 @@ declare(strict_types=1); */ if (flextype('registry')->get('flextype.settings.entries.fields.published_by.enabled')) { - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['published_by'])) { flextype('entries')->storage['create']['data']['published_by'] = flextype('entries')->storage['create']['data']['published_by']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/RoutableField.php b/src/flextype/Foundation/Entries/Fields/RoutableField.php index f21afc84..f9f5424d 100644 --- a/src/flextype/Foundation/Entries/Fields/RoutableField.php +++ b/src/flextype/Foundation/Entries/Fields/RoutableField.php @@ -9,13 +9,13 @@ declare(strict_types=1); if (flextype('registry')->get('flextype.settings.entries.fields.routable.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { flextype('entries')->storage['fetch_single']['data']['routable'] = isset(flextype('entries')->storage['fetch_single']['data']['routable']) ? (bool) flextype('entries')->storage['fetch_single']['data']['routable'] : true; }); - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['routable']) && is_bool(flextype('entries')->storage['create']['data']['routable'])) { flextype('entries')->storage['create']['data']['routable'] = flextype('entries')->storage['create']['data']['routable']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/SlugField.php b/src/flextype/Foundation/Entries/Fields/SlugField.php index c256a752..f208344f 100644 --- a/src/flextype/Foundation/Entries/Fields/SlugField.php +++ b/src/flextype/Foundation/Entries/Fields/SlugField.php @@ -8,9 +8,8 @@ declare(strict_types=1); */ if (flextype('registry')->get('flextype.settings.entries.fields.slug.enabled')) { - flextype('emitter')->addListener('onEntryAfterInitialized', static function () : void { - - $parts = explode('/', ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/')); - flextype('entries')->storage['fetch_single']['data']['slug'] = isset(flextype('entries')->storage['fetch_single']['data']['slug']) ? (string) flextype('entries')->storage['fetch_single']['data']['slug']: (string) end($parts); + flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void { + $parts = explode('/', ltrim(rtrim(flextype('entries')->storage['fetch_single']['id'], '/'), '/')); + flextype('entries')->storage['fetch_single']['data']['slug'] = isset(flextype('entries')->storage['fetch_single']['data']['slug']) ? (string) flextype('entries')->storage['fetch_single']['data']['slug'] : (string) end($parts); }); } diff --git a/src/flextype/Foundation/Entries/Fields/UuidField.php b/src/flextype/Foundation/Entries/Fields/UuidField.php index c5aca6a1..aeaddad2 100644 --- a/src/flextype/Foundation/Entries/Fields/UuidField.php +++ b/src/flextype/Foundation/Entries/Fields/UuidField.php @@ -10,7 +10,7 @@ declare(strict_types=1); use Ramsey\Uuid\Uuid; if (flextype('registry')->get('flextype.settings.entries.fields.uuid.enabled')) { - flextype('emitter')->addListener('onEntryCreate', static function () : void { + flextype('emitter')->addListener('onEntryCreate', static function (): void { if (isset(flextype('entries')->storage['create']['data']['uuid'])) { flextype('entries')->storage['create']['data']['uuid'] = flextype('entries')->storage['create']['data']['uuid']; } else { diff --git a/src/flextype/Foundation/Entries/Fields/VisibilityField.php b/src/flextype/Foundation/Entries/Fields/VisibilityField.php index a0c612ac..48c2fc63 100644 --- a/src/flextype/Foundation/Entries/Fields/VisibilityField.php +++ b/src/flextype/Foundation/Entries/Fields/VisibilityField.php @@ -14,7 +14,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.visibility.enabl 'visible' => 'visible', ]; - flextype('emitter')->addListener('onEntryAfterInitialized', static function () use ($visibility) : void { + flextype('emitter')->addListener('onEntryAfterInitialized', static function () use ($visibility): void { if (isset(flextype('entries')->storage['fetch_single']['data']['visibility']) && in_array(flextype('entries')->storage['fetch_single']['data']['visibility'], $visibility)) { flextype('entries')->storage['fetch_single']['data']['visibility'] = (string) $visibility[flextype('entries')->storage['fetch_single']['data']['visibility']]; } else { @@ -22,7 +22,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.visibility.enabl } }); - flextype('emitter')->addListener('onEntryCreate', static function () use ($visibility) : void { + flextype('emitter')->addListener('onEntryCreate', static function () use ($visibility): void { if (isset(flextype('entries')->storage['create']['data']['visibility']) && in_array(flextype('entries')->storage['create']['data']['visibility'], $visibility)) { flextype('entries')->storage['create']['data']['visibility'] = flextype('entries')->storage['create']['data']['visibility']; } else {