Skip to content

if no exceptions are specified, php spams warnings about 'Invalid argument supplied for foreach()' #28

Open
@kn00tcn

Description

@kn00tcn

are these two blocks causing php warnings?

foreach ($this->exceptions as $key => $value) {
    $this->exceptions[$key] = array_filter($value, function ($element) {
        return (trim($element) !== '');
    });
}
foreach ($this->exceptions as $ex_day => $ex_hours) {
    if (strtotime($ex_day) === $today) {
        // Today is an exception, use alternate hours instead
        $hours_today = $ex_hours;
    }
}

wrapping them with if ($this->exceptions) seems to stop the warnings, not sure if isset should be used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions