Symfony Polyfills provide some features from PHP core and PHP extensions implemented as PHP 5.3 code, so you can use them in your applications regardless of the PHP version being run on your system.

Polyfills allow you to use some PHP 7 functions (e.g. spl_object_id() from PHP 7.2) in your PHP 5 code and some functions from PHP extensions (e.g. mb_strlen() from mbstring) even if you don't have those extensions installed.

Symfony Polyfills are continuously being improved and we recently added two new polyfills for PHP 7.3 and the Ctype extension. PHP 7.3 hasn't been released yet, so Symfony PHP 7.3 Polyfill only includes one function for now: is_countable(), which returns true when the given variable is countable (an array or an instance of Countable, ResourceBundle or SimpleXmlElement).

The Symfony Ctype Polyfill provides the following functions:

1
2
3
4
5
6
7
8
9
10
11
function ctype_alnum($text)
function ctype_alpha($text)
function ctype_cntrl($text)
function ctype_digit($text)
function ctype_graph($text)
function ctype_lower($text)
function ctype_print($text)
function ctype_punct($text)
function ctype_space($text)
function ctype_upper($text)
function ctype_xdigit($text)

Run these commands to install any of the new polyfills in your apps:

1
2
$ composer require symfony/polyfill-php73
$ composer require symfony/polyfill-ctype
Published in #Living on the edge