Skip to content

strictify/lazy

Repository files navigation

Type Coverage

Add laziness to data evaluation

Requirements

PHP ^8.0

Installation

composer require strictify/lazy

Usage:

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();

Full static analysis; psalm will always know the correct type.

More real cases soon.

About

Add laziness to data evaluation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages