eclipxe/generic-collections
Composer 安装命令:
composer require eclipxe/generic-collections
包简介
Library to mimics generic collections
关键字:
README 文档
README
Generic Collections PHP Library is a PHP 5.6+ that mimics the Java Collections Framework.
As PHP does not have Generics this library will always implements type checks.
Don't worry, anyways you can always use the mixed type
For concrete classes uses a constructor approach:
// collection = new Collection<Foo>(); $collection = new Collection(Foo::class);
For your own classes you could extend the abstract class and implement the appropiated type methods, by example:
class Foos extends Collection { public function __construct(array $elements) { parent::__construct(Foo::class, $elements); } }
Installation
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to
your project's composer.json:
composer require eclipxe/generic-collections
List of classes
Basic classes:
- Collection: A collection represents a group of elements of the same type.
- Set: A collection that only allows unique elements
- Queue: Collection for holding elements (FIFO)
- Deque: Double Ended Queue
Classes that implement \ArrayAccess
- Map: A mapping from keys to values.
- List: A collection that can be accessed by their integer index and search elements on the list.
Additional classes:
- Stack: Collection for holding elements (LIFO)
-
ShapeTypedStruct: Structure with typed values (also with\ArrayAccess)
All classes have these additional options:
- allow null elements/values
- allow only unique elements/values
- comparison equal (make equality comparisons between members instead of identical comparisons)
About
This library is inspired by the Java Collections Framework and PHP ramsey/collection library.
I see significant changes with ramsey's package, as I didn't want to introduce heavy changes to his API I decide to create my own approach.
I had also take a deep search on Packagist but couldn't find a library that ensure type checking on members.
Yes, my mistake, the repository username is eclipxe13/ and the packagist name is eclipxe/.
Compatibility
This class will be compatible according to PHP Supported versions, Security Support. This means that it will offer compatibility with PHP 5.6+ until 2018-12-31.
The support for version 5.5+ is not included since this PHP version will end 2016-06-10 and that is lower than the release of first version of this library.
Not taking particular efforts to make this library compatible with hhvm, hhvm have Generics support included
and also has a collection library. I have seen differences on how hack language implement traits (like the
ability to use abstracts methods) that are not compatible. Also I've seen a problem on hhvm 3.6.6
(the one is using Travis CI)implementation of SplDoubleLinkedList that are not present on version 3.12.1.
Documentation and examples
WIP. Be patient please.
Contributing
Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in the TODO and CHANGELOG files.
Copyright and License
The eclipxe/generic-collections library is copyright © Carlos C Soto and licensed for use under the MIT License (MIT). Please see LICENSE for more information.
eclipxe/generic-collections 适用场景与选型建议
eclipxe/generic-collections 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.9k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「collections」 「generics」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eclipxe/generic-collections 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eclipxe/generic-collections 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eclipxe/generic-collections 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generic, object-oriented Vector, Map, and Set collections with immutable and mutable variants
This package provides type-safe extension of the laravel collection, forcing a single type of object.
An extension for Doctrine2 DBAL allowing usage of generic types
Doctrine Collections adapter for Rekapager pagination library
PHP Generics library
The helpers allows you to easy use DATE. Change format, add/sub day, diff date, get quarter - all this is available in this library.
统计信息
- 总下载量: 6.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-27