mini\Util\InstanceStore class

Documentation

Generic instance store that mirrors WeakMap API but with type validation

Provides a type-safe way to store singleton instances with interface validation. Mirrors PHP's WeakMap API for familiar usage patterns.

Inheritance

Implements: mini\Contracts\MapInterface Traversable IteratorAggregate Countable ArrayAccess

Properties (2)

private array $instances
private string $requiredType

Methods (17)

Documentation missing

Check if a key exists (mirrors WeakMap::offsetExists)

Get an instance by key (mirrors WeakMap::offsetGet)

Set an instance with type validation (mirrors WeakMap::offsetSet)

Remove an instance (mirrors WeakMap::offsetUnset)

Get the number of stored instances

Get iterator for stored instances

Check if key exists (WeakMap-style method)

Get instance by key (WeakMap-style method)

Get instance by member access

Set instance by member access

Set instance with type validation (WeakMap-style method)

Add instance with type validation (throws if key already exists)

Delete instance (WeakMap-style method)

Get all stored keys

Get all stored values

Get the required type for this store

Source

src/Util/InstanceStore.php:21-204