/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Support/RebindsCallbacksToSelf.php
34 строки
860 B
Ollie Read
Improve custom driver binding (#59614)
13 апр 2026, 17:52
Не верифицирован
13 апр 2026, 17:52
7602559
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace Illuminate\Support; use Closure; use ReflectionFunction; trait RebindsCallbacksToSelf { /** * Binds the provided callback to the class instance. * * @throws \ReflectionException */ protected function bindCallbackToSelf(Closure $callback): ?Closure { $reflector = new ReflectionFunction($callback); // We only want to rebind anonymous functions. if ($reflector->isAnonymous()) { if ($reflector->isStatic()) { // Static functions are bound without $this. $callback = $callback->bindTo(null, static::class); } else { // Non-static functions are bound to $this. $callback = $callback->bindTo($this, static::class); } } return $callback; } }