定制 minvws/icore-php-typearray 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

minvws/icore-php-typearray

最新稳定版本:v1.0.0

Composer 安装命令:

composer require minvws/icore-php-typearray

包简介

Typed Array

README 文档

README

Simple wrapper around property-accessor to fetch elements in a typed way. This package is created because I was fiddling around with a lot of json-arrays that were not typed and phpstan had a big issue with that.

So, instead of having mixed[] $myarray, we can use TypeArray, and fetch elements with:

$arr = new TypeArray(['foo' => 'string', 'bar' => 4 ]);

$arr->getString('[foo]');  // always returns a string
$arr->getString('[notexists]', 'defaultval');   // Returns default val when not found

$arr->getInt('[bar]');  // returns int(4)
$arr->getInt('[foo]');  // Returns InvalidTypeException as this element is a string, not an int

See symfony propertyaccess component for the path syntax used.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2025-06-27