boson-php/weak-types
Weak-types helpers for the Boson PHP ecosystem. Install via Composer and use alongside Boson to build desktop apps with configuration, windows, webviews, bindings, scripts, and request interception—see the Boson docs for guides and APIs.
mixed and array overloads align with the package’s goals, but Laravel’s dependency injection and service container may resist weak typing without explicit opt-in. Risk of type conflicts if mixed with strict Laravel constructs (e.g., typed properties, interfaces).Illuminate\Support\Collection (for maps/arrays).Symfony\Component\VarDumper\Cloner (for serialization).array_merge_recursive, json_decode($assoc=true) (for dynamic data).WeakMap::class => WeakMapFactory::class).WeakCache::store() for caching.WeakMap keys may disappear mid-test).WeakMap::disableGC() for tests).var_dump() output.WeakMap as a singleton).Illuminate\Cache could invalidate stored objects unexpectedly.spatie/weak-types)?WeakMap compare to Collection/array in:
WeakMap loses keys, how do we log/alert on this?"WeakMap::from(json_decode($response))).Illuminate\Cache using weak structures.WeakSet to automatically clean up listeners after execution.WeakMap for form rules).array/Collection.WeakMap/WeakSet.// Current
$data = json_decode($response, true);
// Proposed
$weakData = WeakMap::from(json_decode($response));
laravel-weak-types with explicit imports:
use Boson\WeakTypes\WeakMap;
Facade:
WeakCache::store('key', $object); // Internally uses WeakMap
$this->app->bind(WeakMap::class, function () {
return new WeakMap();
});
WeakMap only for caching objects >1MB."if (version_compare(PHP_VERSION, '8.4.0') < 0) {
throw new RuntimeException('Weak types require PHP 8.4+');
}
boson-php packages (e.g., boson).replace or alias to avoid version clashes.spatie/weak-types).How can I help you explore Laravel packages today?