Closure class
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
소개
익명 함수를 나타내는 데 사용되는 클래스입니다.
익명 함수는 이 유형의 객체를 생성합니다. 이 클래스에는 생성된 익명 함수를 추가로 제어할 수 있는 메서드가 있습니다.
여기에 나열된 메서드 외에도 이 클래스에는 __invoke
메서드도 있습니다. 이 메서드는 함수를 호출하는 데 사용되지 않으므로 calling magic을 구현하는 다른 클래스와의 일관성을 위한 것입니다.
인터페이스 개요
final class Closure {
/* Methods */
private __construct()
public static bind(Closure $closure, ?object $newThis, object|string|null $newScope = "static"): ?Closure
public bindTo(?object $newThis, object|string|null $newScope = "static"): ?Closure
public call(object $newThis, mixed ...$args): mixed
public static fromCallable(callable $callback): Closure
}
목차
- Closure::__construct — Constructor that disallows instantiation
- Closure::bind — Duplicates a closure with a specific bound object and class scope
- Closure::bindTo — Duplicates the closure with a new bound object and class scope
- Closure::call — Binds and calls the closure
- Closure::fromCallable — Converts a callable into a closure