Skip to content

Commit

Permalink
fix: reintroduce error reporting and add typefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Feb 19, 2024
1 parent d85967f commit 7495a13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 2 additions & 3 deletions source/php/Component/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ 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.
Please review data inputted: %s',
print_r($this, true)
),
E_USER_WARNING
); */
);
}

//Store locally
Expand Down Expand Up @@ -268,7 +268,6 @@ private function getClass($implode = true)
return (array) $class;
}


//Return manipulated data array as string
return (string) implode(" ", (array) $class);
}
Expand Down
17 changes: 16 additions & 1 deletion source/php/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 7495a13

Please sign in to comment.