ayesh/is_countable-polyfill
最新稳定版本:v1.0.9
Composer 安装命令:
composer require ayesh/is_countable-polyfill
包简介
A trivial but working polyfill for PHP 7.3 is_countable function. Supports PHP versions >= 5.3
README 文档
README
A trivial yet functional polyfill for PHP 7.3 is_countable() function.
This polyfill is now archived and is marked as abandoned. PHP 7.3 is quite old, and it is highly recommended to simply upgrade to PHP 8 or later, which should leave no reason to use this polyfill. Thank you for using/considering this polyfill.
Installation
You can use composer to install this polyfill:
composer require ayesh/is_countable-polyfill
Tests
PHPUnit is used as the test framework. Some of the tested variables are
directly taken from the commit that added is_countable to PHP source.
FAQ (or questions I think someone would ask)
Why use this library when I could simply copy-paste the snippet from the RFC?
¯\_(ツ)_/¯
PHP 5.2 compatibility
You can even use this simple compat for any PHP version that you'd ever run into. For 5.2 or older versions, please just stop using polyfills and just upgrade your PHP version.
I get Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d error
This is because you called count() function on a variable that cannot be
counted. If you want to check if a given variable is "positive", you should
be using empty() contruct instead of count().
PHP 7.3 comes with an is_countable function that helps to mitigate such
warnings by checking if the variable is countable first. For those who
don't have PHP 7.3 yet, this polyfill will add the same functionality in
user-land code.
Can I remove this package when I upgrade to PHP 7.3 or later?
Yes. If you require PHP 7.3 or later as the minimum supported PHP version, you do not need to use this package. To remove it:
composer remove ayesh/is_countable-polyfill
ayesh/is_countable-polyfill 适用场景与选型建议
ayesh/is_countable-polyfill 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 134.23k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2018 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「compatibility」 「port」 「compat」 「portable」 「polyfill」 「shim」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ayesh/is_countable-polyfill 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ayesh/is_countable-polyfill 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ayesh/is_countable-polyfill 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Joomla Compat Package
Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string
Polyfill for the New Relic PHP extension
Compatibility layer for emulating enumerations in PHP < 8.1 and native enumerations in PHP >= 8.1
PHP polyfill for the Apache Functions. The aim is to provides functions as the PHP way in order to get them available even if PHP is not running as an Apache module.
SSO Client Library for Laravel
统计信息
- 总下载量: 134.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-22