Download the PHP package ayesh/is_countable-polyfill without Composer

On this page you can find all versions of the php package ayesh/is_countable-polyfill. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package is_countable-polyfill

PHP 7.3 is_countable polyfill

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


All versions of is_countable-polyfill with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ayesh/is_countable-polyfill contains the following files

Loading the files please wait ....