From aec9f94399423aa3553af47f6457e3901968c7c2 Mon Sep 17 00:00:00 2001 From: Chris Blanquera Date: Sat, 25 Jun 2022 19:23:54 +0800 Subject: [PATCH] cleaner php9 update --- admin/AdminPackage.php | 10 +++++----- admin/assets/script/_fields.js | 4 +--- admin/controller/collection.php | 10 +++++----- admin/controller/field.php | 2 +- admin/controller/fieldset.php | 26 +++++++++++++------------- admin/controller/language.php | 14 +++++++------- admin/controller/object.php | 16 ++++++++-------- admin/controller/package.php | 28 ++++++++++++++-------------- admin/controller/schema.php | 22 +++++++++++----------- admin/controller/settings.php | 2 +- admin/controller/view.php | 2 +- api/app/controller.php | 2 +- api/boot/body.php | 2 +- api/boot/rest.php | 2 +- api/developer/controller/docs.php | 16 ++++++++-------- api/dialog/controller.php | 4 ++-- auth/AuthPackage.php | 2 +- auth/controller/2fa.php | 4 ++-- auth/controller/admin.php | 16 ++++++++-------- auth/controller/forgot.php | 4 ++-- auth/controller/password.php | 2 +- auth/controller/signin.php | 4 ++-- auth/controller/signup.php | 2 +- auth/controller/verify.php | 2 +- auth/events.php | 2 +- captcha/events.php | 12 ++++++------ composer.json | 10 +++++----- field/Textarea/Textarea.php | 2 +- format/String/Capitalize.php | 2 +- format/String/CharLength.php | 2 +- format/String/Lowercase.php | 2 +- format/String/Uppercase.php | 2 +- format/String/WordLength.php | 6 +++--- handlebars/helpers.php | 6 +++--- history/controller.php | 2 +- install/controller.php | 18 +++++++++--------- package.php | 2 +- role/boot/permitted.php | 2 +- storm/events/storm/schema.php | 16 ++++++++-------- storm/events/storm/table.php | 8 ++++---- storm/events/system/schema.php | 4 ++-- website/boot/page.php | 2 +- 42 files changed, 148 insertions(+), 150 deletions(-) diff --git a/admin/AdminPackage.php b/admin/AdminPackage.php index aec05ae..d718eea 100644 --- a/admin/AdminPackage.php +++ b/admin/AdminPackage.php @@ -122,12 +122,12 @@ public function error( $path = $request->getPath('string'); //if not an admin path if ($path !== static::ROOT_PATH - && strpos((string) $path, static::ROOT_PATH . '/') !== 0 + && strpos($path, static::ROOT_PATH . '/') !== 0 ) { return; } - $debug = strpos((string) $path, static::ROOT_SPA . '/') === false ? 'page': 'spa'; + $debug = strpos($path, static::ROOT_SPA . '/') === false ? 'page': 'spa'; //if it was a call for an actual file if (preg_match('/\.[a-zA-Z0-9]{1,4}$/', $path)) { @@ -136,7 +136,7 @@ public function error( //if this is not an html page $type = $response->getHeaders('Content-Type'); - if (strpos((string) $type, 'html') === false) { + if (strpos($type, 'html') === false) { //don't make it pretty return $this->errorDebug($request, $response, $error, $debug); } @@ -346,7 +346,7 @@ protected function errorDebug( //shorten file $data['short_file'] = basename($data['file']); - if (strpos((string) $data['file'], INCEPT_CWD) === 0) { + if (strpos($data['file'], INCEPT_CWD) === 0) { $data['short_file'] = substr($data['file'], strlen(INCEPT_CWD)); } @@ -373,7 +373,7 @@ protected function errorDebug( //shorten file $trace['short_file'] = basename($trace['file']); - if (strpos((string) $data['file'], INCEPT_CWD) === 0) { + if (strpos($data['file'], INCEPT_CWD) === 0) { $trace['short_file'] = substr($trace['file'], strlen(INCEPT_CWD) + 1); } diff --git a/admin/assets/script/_fields.js b/admin/assets/script/_fields.js index 3597cb7..42ca548 100644 --- a/admin/assets/script/_fields.js +++ b/admin/assets/script/_fields.js @@ -525,8 +525,7 @@ //INITITALIZERS var initTag = function (filter) { $('a.remove', filter).click(function () { - console.log(filter[0]) - filter.remove(); + filter.remove(); }); $('a.move-up', filter).click(function () { @@ -1558,7 +1557,6 @@ }); if ($(target).data('use-select2')) { - console.log(target) $(target).select2(); } } diff --git a/admin/controller/collection.php b/admin/controller/collection.php index 34c6514..13a4bc8 100644 --- a/admin/controller/collection.php +++ b/admin/controller/collection.php @@ -56,7 +56,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/collection'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -136,7 +136,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/collection'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -230,7 +230,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/collection'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -373,7 +373,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -571,7 +571,7 @@ $data['title'] = $schema->getPlural('plural'); $template = dirname(__DIR__) . '/template/collection'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/field.php b/admin/controller/field.php index f42febf..2bdac63 100644 --- a/admin/controller/field.php +++ b/admin/controller/field.php @@ -207,7 +207,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/field'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/fieldset.php b/admin/controller/fieldset.php index c7591fb..28c97d1 100644 --- a/admin/controller/fieldset.php +++ b/admin/controller/fieldset.php @@ -53,7 +53,7 @@ $data['title'] = $this('lang')->translate('Fieldsets'); $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -113,7 +113,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -180,7 +180,7 @@ $data = $request->getPost(); //if detail has no value make it null - if (isset($data['detail']) && !trim((string) $data['detail'])) { + if (isset($data['detail']) && !trim($data['detail'])) { $data['detail'] = null; } @@ -238,7 +238,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -302,7 +302,7 @@ //----------------------------// // 2. Process Data $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -469,7 +469,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -496,7 +496,7 @@ //get the content $fieldset = $request->getStage('fieldset'); //get the type - $type = substr($fieldset, 5, strpos((string) $fieldset, ';base64') - 5); + $type = substr($fieldset, 5, strpos($fieldset, ';base64') - 5); //invalid file? if ($type !== 'application/json' && $type !== 'application/zip') { @@ -505,7 +505,7 @@ //decode the content $content = base64_decode( - substr($fieldset, strpos((string) $fieldset, ';base64,') + 8) + substr($fieldset, strpos($fieldset, ';base64,') + 8) ); //json file? @@ -587,7 +587,7 @@ //root or not under fieldset? if ($filename === 'fieldset/' - || strpos((string) $filename, 'fieldset/') === false + || strpos($filename, 'fieldset/') === false ) { continue; } @@ -682,7 +682,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -755,7 +755,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -838,7 +838,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/fieldset'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -868,7 +868,7 @@ $data = $request->getPost(); //if detail has no value make it null - if (isset($data['detail']) && !trim((string) $data['detail'])) { + if (isset($data['detail']) && !trim($data['detail'])) { $data['detail'] = null; } diff --git a/admin/controller/language.php b/admin/controller/language.php index b70db57..b721fc8 100644 --- a/admin/controller/language.php +++ b/admin/controller/language.php @@ -35,7 +35,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/language'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -110,7 +110,7 @@ //loop through the keys found foreach ($keys as $key) { //if blank key - if (!trim((string) $key)) { + if (!trim($key)) { //skip continue; } @@ -143,7 +143,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/language'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -172,7 +172,7 @@ //----------------------------// // 2. Validate Data - if (!isset($data['filename']) || !trim((string) $data['filename'])) { + if (!isset($data['filename']) || !trim($data['filename'])) { return $response->setError(true, 'Language code is required'); } @@ -292,7 +292,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/language'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -322,7 +322,7 @@ //----------------------------// // 2. Validate Data - if (!isset($data['filename']) || !trim((string) $data['filename'])) { + if (!isset($data['filename']) || !trim($data['filename'])) { return $response->setError(true, 'Language code is required'); } @@ -393,7 +393,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/object.php b/admin/controller/object.php index 2cfcee5..6ecf6d1 100644 --- a/admin/controller/object.php +++ b/admin/controller/object.php @@ -90,7 +90,7 @@ $data['title'] = $schema->getPlural('plural'); $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -310,7 +310,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -500,7 +500,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir((string) $response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -796,7 +796,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -910,7 +910,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -1060,7 +1060,7 @@ } $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -1186,7 +1186,7 @@ } $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -1359,7 +1359,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/package.php b/admin/controller/package.php index cb0a11b..f950047 100644 --- a/admin/controller/package.php +++ b/admin/controller/package.php @@ -33,8 +33,8 @@ $rows = $this('config')->get('packages'); foreach ($rows as $name => $row) { - if (($data['filter'] === 'default' && strpos((string) $name, 'inceptphp/') !== 0) - || ($data['filter'] === 'custom' && strpos((string) $name, 'inceptphp/') === 0) + if (($data['filter'] === 'default' && strpos($name, 'inceptphp/') !== 0) + || ($data['filter'] === 'custom' && strpos($name, 'inceptphp/') === 0) ) { continue; } @@ -45,11 +45,11 @@ } else { $path = null; //if it starts with / like /foo/bar - if (strpos((string) $name, '/') === 0) { + if (strpos($name, '/') === 0) { //it's a root package $path = INCEPT_CWD . $name; //if theres a slash like foo/bar - } else if (strpos((string) $name, '/') !== false) { + } else if (strpos($name, '/') !== false) { //it's vendor package $path = sprintf('%s/vendor/%s', INCEPT_CWD, $name); } @@ -95,7 +95,7 @@ $data['title'] = $this('lang')->translate('Packages'); $template = dirname(__DIR__) . '/template/package'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -152,11 +152,11 @@ } else { $path = null; //if it starts with / like /foo/bar - if (strpos((string) $name, '/') === 0) { + if (strpos($name, '/') === 0) { //it's a root package $path = INCEPT_CWD . $name; //if theres a slash like foo/bar - } else if (strpos((string) $name, '/') !== false) { + } else if (strpos($name, '/') !== false) { //it's vendor package $path = sprintf('%s/vendor/%s', INCEPT_CWD, $name); } @@ -208,7 +208,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -273,11 +273,11 @@ } else { $path = null; //if it starts with / like /foo/bar - if (strpos((string) $name, '/') === 0) { + if (strpos($name, '/') === 0) { //it's a root package $path = INCEPT_CWD . $name; //if theres a slash like foo/bar - } else if (strpos((string) $name, '/') !== false) { + } else if (strpos($name, '/') !== false) { //it's vendor package $path = sprintf('%s/vendor/%s', INCEPT_CWD, $name); } @@ -329,7 +329,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -394,11 +394,11 @@ } else { $path = null; //if it starts with / like /foo/bar - if (strpos((string) $name, '/') === 0) { + if (strpos($name, '/') === 0) { //it's a root package $path = INCEPT_CWD . $name; //if theres a slash like foo/bar - } else if (strpos((string) $name, '/') !== false) { + } else if (strpos($name, '/') !== false) { //it's vendor package $path = sprintf('%s/vendor/%s', INCEPT_CWD, $name); } @@ -450,7 +450,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/object'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/schema.php b/admin/controller/schema.php index 578c302..6692988 100644 --- a/admin/controller/schema.php +++ b/admin/controller/schema.php @@ -55,7 +55,7 @@ if (isset($data['rows']) && is_array($data['rows'])) { foreach ($data['rows'] as $row) { $group = 'Custom'; - if (isset($row['group']) && trim((string) $row['group'])) { + if (isset($row['group']) && trim($row['group'])) { $group = $row['group']; } @@ -71,7 +71,7 @@ $data['title'] = $this('lang')->translate('Schemas'); $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -133,7 +133,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -201,7 +201,7 @@ $data = $request->getPost(); //if detail has no value make it null - if (isset($data['detail']) && !trim((string) $data['detail'])) { + if (isset($data['detail']) && !trim($data['detail'])) { $data['detail'] = null; } @@ -259,7 +259,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -323,7 +323,7 @@ //----------------------------// // 2. Process Data $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -490,7 +490,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -703,7 +703,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -776,7 +776,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -859,7 +859,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/schema'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -890,7 +890,7 @@ $data = $request->getPost(); //if detail has no value make it null - if (isset($data['detail']) && !trim((string) $data['detail'])) { + if (isset($data['detail']) && !trim($data['detail'])) { $data['detail'] = null; } diff --git a/admin/controller/settings.php b/admin/controller/settings.php index 58484e1..3d08cc8 100644 --- a/admin/controller/settings.php +++ b/admin/controller/settings.php @@ -26,7 +26,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/settings'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/admin/controller/view.php b/admin/controller/view.php index ecb44a1..8008f09 100644 --- a/admin/controller/view.php +++ b/admin/controller/view.php @@ -75,7 +75,7 @@ //----------------------------// // 2. Render Template $template = dirname(__DIR__) . '/template/view'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/api/app/controller.php b/api/app/controller.php index 0f037cf..b70f7b8 100644 --- a/api/app/controller.php +++ b/api/app/controller.php @@ -80,7 +80,7 @@ //----------------------------// // 2. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/api/boot/body.php b/api/boot/body.php index 33a621b..b004c70 100644 --- a/api/boot/body.php +++ b/api/boot/body.php @@ -21,7 +21,7 @@ * @param ResponseInterface $response */ return function(RequestInterface $request, ResponseInterface $response) { - if (!trim((string) $request->get('body'))) { + if (!trim($request->get('body'))) { return; } diff --git a/api/boot/rest.php b/api/boot/rest.php index cbd8efc..c4a8374 100644 --- a/api/boot/rest.php +++ b/api/boot/rest.php @@ -20,7 +20,7 @@ $http = $this('http'); $emitter = $this('event'); - $path = $request->getPath('string'); + $path = (string) $request->getPath('string'); //normalize the pat if (substr($path, -1) !== '/') { $path .= '/'; diff --git a/api/developer/controller/docs.php b/api/developer/controller/docs.php index 7fead2a..f5bd103 100644 --- a/api/developer/controller/docs.php +++ b/api/developer/controller/docs.php @@ -33,7 +33,7 @@ //----------------------------// // 3. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -103,7 +103,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -178,7 +178,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -252,7 +252,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -326,7 +326,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -400,7 +400,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -474,7 +474,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -552,7 +552,7 @@ //----------------------------// // 4. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/api/dialog/controller.php b/api/dialog/controller.php index f09f46c..5237d45 100644 --- a/api/dialog/controller.php +++ b/api/dialog/controller.php @@ -102,7 +102,7 @@ //----------------------------// // 3. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -244,7 +244,7 @@ //----------------------------// // 3. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/AuthPackage.php b/auth/AuthPackage.php index db65c94..9acf660 100644 --- a/auth/AuthPackage.php +++ b/auth/AuthPackage.php @@ -136,7 +136,7 @@ public function slugger(string $string, string $suffix = null): string $slug = preg_replace('~[^-\w\+]+~', '', $slug); // trim - $slug = trim((string) $slug, '-'); + $slug = trim($slug, '-'); // remove duplicate - $slug = preg_replace('~-+~', '-', $slug); diff --git a/auth/controller/2fa.php b/auth/controller/2fa.php index d0166f3..84a70bf 100644 --- a/auth/controller/2fa.php +++ b/auth/controller/2fa.php @@ -94,7 +94,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -276,7 +276,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/controller/admin.php b/auth/controller/admin.php index b61f88c..e9a346e 100644 --- a/auth/controller/admin.php +++ b/auth/controller/admin.php @@ -67,7 +67,7 @@ //----------------------------// // 3. Render Template $template = dirname(__DIR__) . '/template/admin'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -120,7 +120,7 @@ //----------------------------// // 3. Validate Data foreach ($data['services'] as $i => $service) { - if (!isset($service['name']) || !trim((string) $service['name'])) { + if (!isset($service['name']) || !trim($service['name'])) { $response->invalidate('service', $i, 'name', 'Name is required'); } @@ -128,23 +128,23 @@ $response->invalidate('service', $i, 'active', 'Active is required'); } - if (!isset($service['client_id']) || !trim((string) $service['client_id'])) { + if (!isset($service['client_id']) || !trim($service['client_id'])) { $response->invalidate('service', $i, 'client_id', 'Client ID is required'); } - if (!isset($service['client_secret']) || !trim((string) $service['client_secret'])) { + if (!isset($service['client_secret']) || !trim($service['client_secret'])) { $response->invalidate('service', $i, 'client_secret', 'Client Secret is required'); } - if (!isset($service['url_authorize']) || !trim((string) $service['url_authorize'])) { + if (!isset($service['url_authorize']) || !trim($service['url_authorize'])) { $response->invalidate('service', $i, 'url_authorize', 'Authorize URL is required'); } - if (!isset($service['url_access_token']) || !trim((string) $service['url_access_token'])) { + if (!isset($service['url_access_token']) || !trim($service['url_access_token'])) { $response->invalidate('service', $i, 'url_access_token', 'Access Token URL is required'); } - if (!isset($service['url_resource']) || !trim((string) $service['url_resource'])) { + if (!isset($service['url_resource']) || !trim($service['url_resource'])) { $response->invalidate('service', $i, 'url_resource', 'Resource URL is required'); } } @@ -212,7 +212,7 @@ ) { //if profile id, or profile name if (is_numeric($request->getStage('profile_id')) - || !trim((string) $request->getStage('__profile')) + || !trim($request->getStage('__profile')) ) { return; } diff --git a/auth/controller/forgot.php b/auth/controller/forgot.php index 519af30..37f9b00 100644 --- a/auth/controller/forgot.php +++ b/auth/controller/forgot.php @@ -75,7 +75,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -426,7 +426,7 @@ //----------------------------// // 6. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/controller/password.php b/auth/controller/password.php index 814de4a..f0cc89a 100644 --- a/auth/controller/password.php +++ b/auth/controller/password.php @@ -70,7 +70,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/controller/signin.php b/auth/controller/signin.php index a118e8e..0cf6438 100644 --- a/auth/controller/signin.php +++ b/auth/controller/signin.php @@ -86,8 +86,8 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { - $template = $response->get('page', 'template_root'); + if (is_dir($response->get('page', 'template_root') ?? '')) { + $template = (string) $response->get('page', 'template_root'); } $body = $handlebars diff --git a/auth/controller/signup.php b/auth/controller/signup.php index 5042672..c007319 100644 --- a/auth/controller/signup.php +++ b/auth/controller/signup.php @@ -87,7 +87,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/controller/verify.php b/auth/controller/verify.php index c2f984b..2b3d0b5 100644 --- a/auth/controller/verify.php +++ b/auth/controller/verify.php @@ -80,7 +80,7 @@ //----------------------------// // 5. Render Template $template = dirname(__DIR__) . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/auth/events.php b/auth/events.php index c21bd49..c9cf277 100644 --- a/auth/events.php +++ b/auth/events.php @@ -95,7 +95,7 @@ //----------------------------// // 2. Validate Data - if (!isset($data['auth_slug']) || !trim((string) $data['auth_slug'])) { + if (!isset($data['auth_slug']) || !trim($data['auth_slug'])) { $response->invalidate('auth_slug', 'Cannot be empty'); } diff --git a/captcha/events.php b/captcha/events.php index 107fbae..6b36237 100644 --- a/captcha/events.php +++ b/captcha/events.php @@ -26,9 +26,9 @@ //if no config if (!$config || !isset($config['token'], $config['secret'], $config['host']) - || !trim((string) $config['token']) - || !trim((string) $config['secret']) - || !trim((string) $config['host']) + || !trim($config['token']) + || !trim($config['secret']) + || !trim($config['host']) || $config['host'] === '' || $config['token'] === '' || $config['secret'] === '' @@ -58,9 +58,9 @@ //if no config if (!$config || !isset($config['token'], $config['secret'], $config['host']) - || !trim((string) $config['token']) - || !trim((string) $config['secret']) - || !trim((string) $config['host']) + || !trim($config['token']) + || !trim($config['secret']) + || !trim($config['host']) || $config['host'] === '' || $config['token'] === '' || $config['secret'] === '' diff --git a/composer.json b/composer.json index 0116299..7ec39a5 100644 --- a/composer.json +++ b/composer.json @@ -5,13 +5,13 @@ "minimum-stability": "dev", "license": "LGPL-2.1-or-later", "require-dev": { - "phpunit/phpunit": "~9.5.4", - "squizlabs/php_codesniffer": "~3.5.8", - "php-coveralls/php-coveralls": "~2.4.3" + "php-coveralls/php-coveralls": "2.5.2", + "phpunit/phpunit": "9.5.21", + "squizlabs/php_codesniffer": "3.7.1" }, "require": { - "inceptphp/framework": "0.1.8", - "phpugph/storm": "1.0.2", + "inceptphp/framework": "0.1.9", + "phpugph/storm": "1.0.3", "swiftmailer/swiftmailer": "6.2.7", "dejan7/httpquest": "0.3.0", "robthree/twofactorauth": "1.8.2", diff --git a/field/Textarea/Textarea.php b/field/Textarea/Textarea.php index c1f70bf..4ed0184 100644 --- a/field/Textarea/Textarea.php +++ b/field/Textarea/Textarea.php @@ -101,7 +101,7 @@ public function render( file_get_contents(__DIR__ . '/template/field/textarea.html') ); - $value = str_replace('', '<\/textarea>', $value); + $value = str_replace('', '<\/textarea>', $value ?? ''); return $template([ 'name' => $this->name, diff --git a/format/String/Capitalize.php b/format/String/Capitalize.php index 546467d..346b2e7 100644 --- a/format/String/Capitalize.php +++ b/format/String/Capitalize.php @@ -51,6 +51,6 @@ public function format( array $row = [] ): ?string { - return ucwords($value); + return ucwords($value ?? ''); } } diff --git a/format/String/CharLength.php b/format/String/CharLength.php index 7e68138..4cbbb2b 100644 --- a/format/String/CharLength.php +++ b/format/String/CharLength.php @@ -53,7 +53,7 @@ public function format( array $row = [] ): ?string { - return substr($value, 0, $this->parameters[0]); + return substr($value ?? '', 0, $this->parameters[0] ?? ''); } /** diff --git a/format/String/Lowercase.php b/format/String/Lowercase.php index 8263d99..0061bcf 100644 --- a/format/String/Lowercase.php +++ b/format/String/Lowercase.php @@ -50,6 +50,6 @@ public function format( string $name = null, array $row = [] ): ?string { - return strtolower($value); + return strtolower($value ?? ''); } } diff --git a/format/String/Uppercase.php b/format/String/Uppercase.php index 5faec43..55c0cd7 100644 --- a/format/String/Uppercase.php +++ b/format/String/Uppercase.php @@ -51,6 +51,6 @@ public function format( array $row = [] ): ?string { - return strtoupper($value); + return strtoupper($value ?? ''); } } diff --git a/format/String/WordLength.php b/format/String/WordLength.php index 4d8476d..d1df7a5 100644 --- a/format/String/WordLength.php +++ b/format/String/WordLength.php @@ -54,10 +54,10 @@ public function format( ): ?string { $length = $this->parameters[0]; - if (str_word_count($value, 0) > $length) { - $words = str_word_count($value, 2); + if (str_word_count($value ?? '', 0) > $length) { + $words = str_word_count($value ?? '', 2); $position = array_keys($words); - $value = substr($value, 0, $position[$length]); + $value = substr($value ?? '', 0, $position[$length]); } return $value; diff --git a/handlebars/helpers.php b/handlebars/helpers.php index 7b902e0..cf26aa8 100644 --- a/handlebars/helpers.php +++ b/handlebars/helpers.php @@ -367,7 +367,7 @@ } } - return incept('lang')->translate((string) $key, ...$args); + return incept('lang')->translate($key, ...$args); }) /** @@ -389,7 +389,7 @@ continue; } - if (!trim((string) $abbreviation['timezone_id'])) { + if (!trim($abbreviation['timezone_id'] ?? '')) { continue; } @@ -1121,7 +1121,7 @@ array $variables ): string { $template = incept('handlebars')->compile($template); - return trim((string) $template($variables)); + return trim($template($variables)); }) /** diff --git a/history/controller.php b/history/controller.php index 3f8f2f8..29e0bce 100644 --- a/history/controller.php +++ b/history/controller.php @@ -163,7 +163,7 @@ //----------------------------// // 2. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/install/controller.php b/install/controller.php index 68b0306..edcf351 100644 --- a/install/controller.php +++ b/install/controller.php @@ -81,7 +81,7 @@ //----------------------------// // 2. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -189,7 +189,7 @@ //----------------------------// // 3. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -269,34 +269,34 @@ //if theres a host if (isset($config['host'])) { $host = explode(':', $config['host']); - if (isset($host[0]) && trim((string) $host[0])) { + if (isset($host[0]) && trim($host[0])) { $data['host'] = $host[0]; } - if (isset($host[1]) && trim((string) $host[1])) { + if (isset($host[1]) && trim($host[1])) { $data['port'] = $host[1]; } } //if theres a name - if (isset($config['name']) && trim((string) $config['name'])) { + if (isset($config['name']) && trim($config['name'])) { $data['name'] = $config['name']; } //if theres a user - if (isset($config['user']) && trim((string) $config['user'])) { + if (isset($config['user']) && trim($config['user'])) { $data['user'] = $config['user']; } //if theres a pass - if (isset($config['pass']) && trim((string) $config['pass'])) { + if (isset($config['pass']) && trim($config['pass'])) { $data['pass'] = $config['pass']; } //----------------------------// // 2. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } @@ -419,7 +419,7 @@ //----------------------------// // 2. Render Template $template = __DIR__ . '/template'; - if (is_dir($response->get('page', 'template_root'))) { + if (is_dir($response->get('page', 'template_root') ?? '')) { $template = $response->get('page', 'template_root'); } diff --git a/package.php b/package.php index b9dce11..78b9eaa 100644 --- a/package.php +++ b/package.php @@ -261,7 +261,7 @@ //scan through each file in the schema folder foreach (scandir($schema) as $file) { //if it's not a php file - if(substr((string) $file, -4) !== '.php') { + if(substr($file, -4) !== '.php') { //skip continue; } diff --git a/role/boot/permitted.php b/role/boot/permitted.php index 4839604..d8f6912 100644 --- a/role/boot/permitted.php +++ b/role/boot/permitted.php @@ -44,7 +44,7 @@ $home = $this('config')->get('settings', 'home') ?? '/'; //at least allow the home page - if (!trim((string) $request->getPath('string')) + if (!trim($request->getPath('string')) || $request->getPath('string') === $home ) { return true; diff --git a/storm/events/storm/schema.php b/storm/events/storm/schema.php index 109f8cb..7bc19fa 100644 --- a/storm/events/storm/schema.php +++ b/storm/events/storm/schema.php @@ -36,7 +36,7 @@ // 2. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } @@ -181,7 +181,7 @@ //----------------------------// // 4. Process Data try { - $resource->query((string) $query); + $resource->query($query); } catch (SqlException $e) { return $response->setError(true, $e->getMessage()); } @@ -225,7 +225,7 @@ // 2. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } @@ -255,7 +255,7 @@ $query = $resource->getCreateQuery($table); foreach ($primary as $column) { - if (!trim((string) $column)) { + if (!trim($column)) { continue; } @@ -331,7 +331,7 @@ } try { - $resource->query((string) $query); + $resource->query($query); } catch (SqlException $e) { return $response->setError(true, $e->getMessage()); } @@ -363,7 +363,7 @@ // 2. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } @@ -414,11 +414,11 @@ // 2. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } - if (!trim((string) $name)) { + if (!trim($name)) { $errors['name'] = 'Name is required'; } diff --git a/storm/events/storm/table.php b/storm/events/storm/table.php index 5e02a75..2809e4d 100644 --- a/storm/events/storm/table.php +++ b/storm/events/storm/table.php @@ -42,7 +42,7 @@ //----------------------------// // 3. Validate Data //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $response->invalidate('table', 'Table is required'); } @@ -132,7 +132,7 @@ // 3. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } @@ -250,7 +250,7 @@ // 3. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $errors['table'] = 'Table is required'; } @@ -380,7 +380,7 @@ // 3. Validate Data $errors = []; //we need at least a table - if (!trim((string) $table)) { + if (!trim($table)) { $response->invalidate('table', 'Table is required'); } diff --git a/storm/events/system/schema.php b/storm/events/system/schema.php index aeab41e..3168e0a 100644 --- a/storm/events/system/schema.php +++ b/storm/events/system/schema.php @@ -211,7 +211,7 @@ } else if (!isset($field['default']) || ( !is_numeric($field['default']) - && !trim((string) $field['default']) + && !trim($field['default']) ) ) { $columns[$name]['null'] = true; @@ -224,7 +224,7 @@ } if (isset($field['default'])) { - if (is_numeric($field['default']) || trim((string) $field['default'])) { + if (is_numeric($field['default']) || trim($field['default'])) { $columns[$name]['default'] = $field['default']; } else if (is_bool($field['default'])) { $columns[$name]['default'] = $field['default'] ? 1: 0; diff --git a/website/boot/page.php b/website/boot/page.php index 4044fcd..6055080 100644 --- a/website/boot/page.php +++ b/website/boot/page.php @@ -69,7 +69,7 @@ } //trigger page event - if (trim($page['page_event'])) { + if (trim($page['page_event'] ?? '')) { //make a payload $payload = $this->makePayload(); if ($page['page_parameters']) {