All Projects → PHPWatch → Is_countable Polyfill

PHPWatch / Is_countable Polyfill

Licence: other
A trivial but working polyfill for PHP 7.3 is_countable function. Supports PHP versions >= 5.3

Labels

Projects that are alternatives of or similar to Is countable Polyfill

Unfetch
🐕 Bare minimum 500b fetch polyfill.
Stars: ✭ 5,239 (+32643.75%)
Mutual labels:  polyfill
Sticky State
StickyState is a high performant module making native position:sticky statefull and polyfilling the missing sticky browser feature
Stars: ✭ 692 (+4225%)
Mutual labels:  polyfill
Url Search Params
Simple polyfill for URLSearchParams standard
Stars: ✭ 765 (+4681.25%)
Mutual labels:  polyfill
Bootstrap Ie7
Bootstrap 3 CSS for IE7
Stars: ✭ 578 (+3512.5%)
Mutual labels:  polyfill
Jsbi
JSBI is a pure-JavaScript implementation of the official ECMAScript BigInt proposal.
Stars: ✭ 663 (+4043.75%)
Mutual labels:  polyfill
Fetch
A window.fetch JavaScript polyfill.
Stars: ✭ 25,118 (+156887.5%)
Mutual labels:  polyfill
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+3437.5%)
Mutual labels:  polyfill
Polyfill Php80
This component provides functions unavailable in releases prior to PHP 8.0.
Stars: ✭ 798 (+4887.5%)
Mutual labels:  polyfill
Create React Context
Polyfill for the proposed React context API
Stars: ✭ 689 (+4206.25%)
Mutual labels:  polyfill
Clipboard Polyfill
📋 Simple copying on the web, with maximum browser compatibility.
Stars: ✭ 748 (+4575%)
Mutual labels:  polyfill
Polyfill Service
Automatic polyfill service.
Stars: ✭ 5,585 (+34806.25%)
Mutual labels:  polyfill
Text Encoding
Polyfill for the Encoding Living Standard's API
Stars: ✭ 629 (+3831.25%)
Mutual labels:  polyfill
Native Promise Only
A polyfill for native ES6 Promises as close as possible (no extensions) to the strict spec definitions.
Stars: ✭ 708 (+4325%)
Mutual labels:  polyfill
Css Paint Polyfill
CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.
Stars: ✭ 575 (+3493.75%)
Mutual labels:  polyfill
Ie11customproperties
CSS variables (Custom Properties) polyfill for IE11
Stars: ✭ 765 (+4681.25%)
Mutual labels:  polyfill
Gray
Make an image grayscale in all browsers
Stars: ✭ 568 (+3450%)
Mutual labels:  polyfill
Polyfill Intl Grapheme
This component provides a partial, native PHP implementation of the Grapheme functions from the Intl extension.
Stars: ✭ 690 (+4212.5%)
Mutual labels:  polyfill
Scroll Into View If Needed
Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"
Stars: ✭ 811 (+4968.75%)
Mutual labels:  polyfill
Docker Host
A docker sidecar container to forward all traffic to local docker host or any other host
Stars: ✭ 769 (+4706.25%)
Mutual labels:  polyfill
Hyperform
Capture form validation back from the browser
Stars: ✭ 729 (+4456.25%)
Mutual labels:  polyfill

PHP 7.3 is_countable polyfill

A trivial yet functional polyfill for PHP 7.3 is_countable() function.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].