dev-master 2024-03-30 15:06 UTC

This package is auto-updated.

Last update: 2024-09-30 16:08:29 UTC


README

Type Coverage

为数据评估添加惰性

需求

PHP ^8.0

安装

composer require strictify/lazy

用法

use Strictify\Lazy\LazyValue;

function someSlowFunction() {
    sleep(5);
    
    return 42;
}

// assigning the value does nothing
$lazy = new LazyValue(fn() => someSlowFunction());

// waits 5 seconds, returns 42
$lazy->getValue();

// immediately returns 42
$lazy->getValue();

完整静态分析;psalm 总是知道正确的类型。

更多实际案例即将推出。