承接 pader/weak-array 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pader/weak-array

最新稳定版本:1.0.1

Composer 安装命令:

composer require pader/weak-array

包简介

Array weak reference with value.

README 文档

README

An ArrayAccess implement let you can storage a weak reference object in array by any key type.

This like an temporary cache, help you to reuse same object when it's still use in other place, and will auto unset the item when all reference is destruct.

Install

Require php version >= 8.0.0

composer require pader/weak-array

Simple example:

$hello = new stdClass;
$hello->value = 'hello';
$world = new stdClass;
$world->value = 'world';

$arr = new WeakArray();
$arr[] = $hello;
$arr['foo'] = $world;

var_dump($arr[0]);
var_dump($arr['foo']);

unset($hello);

var_dump($arr[0]); //Should be null
var_dump($arr['foo']);

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-07