kylekatarnls / business-time

Carbon mixin to handle business days and opening hours
MIT License
296 stars 14 forks source link

$schedule->isOpen(now()) throw Cannot bind an instance to a static closure #64

Closed ziming closed 1 year ago

ziming commented 1 year ago

I got this PHP Warning: Cannot bind an instance to a static closure in /vendor/nesbot/carbon/src/Carbon/Traits/Date.php on line 2542

My code that trigger it is:

$schedule = Schedule::create([
    'monday'            => ['09:00-12:00', '13:00-18:00'],
    'tuesday'           => ['09:00-12:00', '13:00-18:00'],
    'wednesday'         => [],
    'thursday'          => ['09:00-12:00', '13:00-18:00'],
    'friday'            => ['09:00-12:00', '13:00-20:00'],
    'holidaysAreClosed' => true,
    'holidays'          => [
        'region' => 'us-ny',
        'with'   => [
            'labor-day'               => null,
            'company-special-holiday' => '04-07',
        ],
    ],
]);

$schedule->isOpen(Carbon::now());

Then I got

PHP Warning: Cannot bind an instance to a static closure in /vendor/nesbot/carbon/src/Carbon/Traits/Date.php on line 2542
false // correct

So it does work but warning keep happen

kylekatarnls commented 1 year ago

Hello, you likely have a set_error_handler that does not respect the error_reporting (and so @ operator) or a library doing that. The handler must have:

if (!(error_reporting() & $errno)) {
    return false;
}

at the beginning of the function.

ziming commented 1 year ago

Ah okay thanks!