Git Product home page Git Product logo

polyfill's Introduction

Symfony Polyfill

This project backports features found in latest PHP versions. It also provides compatibility PHP implementations for some extensions and functions. You should use it when portability across PHP versions and extensions is desired.

Polyfills are provided for:

  • the mbstring and iconv extensions;
  • the Normalizer class and the grapheme_* functions;
  • the utf8_encode and utf8_decode functions from the xml extension;
  • the Collator, NumberFormatter, Locale and IntlDateFormatter classes;
  • the intl_error_name, intl_get_error_code, intl_get_error_message and intl_is_failure functions;
  • the hex2bin function, the CallbackFilterIterator, RecursiveCallbackFilterIterator and SessionHandlerInterface classes introduced in PHP 5.4;
  • the array_column, boolval, json_last_error_msg and hash_pbkdf2 functions introduced in PHP 5.5;
  • the password_hash and password_* related functions introduced in PHP 5.5, provided by the ircmaxell/password-compat package;
  • the hash_equals and ldap_escape functions introduced in PHP 5.6;
  • the *Error classes, the error_clear_last, preg_replace_callback_array and intdiv functions introduced in PHP 7.0;
  • the random_bytes and random_int functions introduced in PHP 7.0, provided by the paragonie/random_compat package;
  • a Binary utility class to be used when compatibility with mbstring.func_overload is required.

It is strongly recommended to upgrade your PHP version and/or install the missing extensions when possible. This polyfill should be used only when there is no better choice or when portability is a requirement.

Compatibility notes

To write portable code between PHP5 and PHP7, some care must be taken:

  • \*Error exceptions must by caught before \Exception;
  • after calling error_clear_last(), the result of $e = error_get_last() must be verified using isset($e['message'][0]) instead of null === $e.

Design

This package is designed for low overhead and high quality polyfilling.

It adds only a few lightweight require to the bootstrapping process of your applications for all polyfills. Implementations are then loaded on-demand when they are needed during code execution.

Polyfills are unit-tested alongside with their native implementation so that feature and behavior parity can be proven and enforced on the long run.

polyfill's People

Contributors

nicolas-grekas avatar keradus avatar fabpot avatar

Stargazers

Dustin Dawes avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.