diff --git a/source/php/Component/BaseController.php b/source/php/Component/BaseController.php index 9804572a..f755d74a 100644 --- a/source/php/Component/BaseController.php +++ b/source/php/Component/BaseController.php @@ -216,7 +216,7 @@ private function validClassList($classList): bool private function getClass($implode = true) { if (!$this->validClassList($this->data['classList'])) { - /* trigger_error( + trigger_error( sprintf( 'The parameter classList is not allowed to contain spaces or include empty strings. Multiple classes may be separated by entering a array of items. @@ -224,7 +224,7 @@ private function getClass($implode = true) print_r($this, true) ), E_USER_WARNING - ); */ + ); } //Store locally @@ -268,7 +268,6 @@ private function getClass($implode = true) return (array) $class; } - //Return manipulated data array as string return (string) implode(" ", (array) $class); } diff --git a/source/php/Register.php b/source/php/Register.php index 6407d45d..f1ec7350 100644 --- a/source/php/Register.php +++ b/source/php/Register.php @@ -202,13 +202,22 @@ function ($view) use ($component) { } } + /** + * Handle typing errors for the given view data and arguments types. + * + * @param array|object $viewData The view data to check for typing errors. + * @param array|object|false $argsTypes The expected argument types for each key in the view data. + * @param string $componentSlug The slug of the component being checked. + * @return void + */ public function handleTypingsErrors($viewData, $argsTypes = false, $componentSlug) { + if (empty((array) $argsTypes) || (empty($viewData) && !is_array($viewData))) { return; } foreach ($viewData as $key => $value) { - if (isset($argsTypes->{$key})) { + if (is_object($argsTypes) && isset($argsTypes->{$key})) { $types = explode('|', $argsTypes->{$key}); if (!in_array(gettype($value), $types)) { @@ -220,6 +229,12 @@ public function handleTypingsErrors($viewData, $argsTypes = false, $componentSlu } } + /** + * Triggers a user warning error with the specified message. + * + * @param string $message The error message. + * @return void + */ private function triggerError($message = "") { trigger_error($message, E_USER_WARNING); }