PHPackages                             phan/var\_representation\_polyfill - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phan/var\_representation\_polyfill

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phan/var\_representation\_polyfill
==================================

Polyfill for var\_representation: convert a variable to a string in a way that fixes the shortcomings of var\_export

0.1.4(3mo ago)033.6k↑18.6%2MITPHPPHP ^7.2.0|^8.0.0

Since Jun 26Pushed 3mo agoCompare

[ Source](https://github.com/phan/var_representation_polyfill)[ Packagist](https://packagist.org/packages/phan/var_representation_polyfill)[ RSS](/packages/phan-var-representation-polyfill/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (2)

var\_representation\_polyfill
=============================

[](#var_representation_polyfill)

[var\_representation\_polyfill](https://github.com/phan/var_representation_polyfill) is a polyfill for [https://pecl.php.net/var\_representation](https://pecl.php.net/var_representation)

This provides a polyfill for the function `var_representation(mixed $value, int $flags = 0): string`, which converts a variable to a string in a way that fixes the shortcomings of `var_export()`

See [the var\_representation PECL documentation](https://github.com/TysonAndre/var_representation) for more details

Forked from [https://github.com/TysonAndre/var\_representation\_polyfill](https://github.com/TysonAndre/var_representation_polyfill) for PHP 8.5 support.

Installation
------------

[](#installation)

```
composer require phan/var_representation_polyfill

```

Usage
-----

[](#usage)

```
// uses short arrays, and omits array keys if array_is_list() would be true
php > echo var_representation(['a','b']);
[
  'a',
  'b',
]

// can dump everything on one line.
php > echo var_representation(['a', 'b', 'c'], VAR_REPRESENTATION_SINGLE_LINE);
['a', 'b', 'c']

php > echo var_representation("uses double quotes: \$\"'\\\n");
"uses double quotes: \$\"'\\\n"

// Can disable the escaping of control characters as of polyfill version 0.1.0
// (e.g. if the return value needs to be escaped again)
php > echo var_representation("has\nnewlines", VAR_REPRESENTATION_UNESCAPED);
'has
newlines'
php > echo json_encode("uses single quotes:\0\r\n\$\"'\\");
"uses single quotes:\u0000\r\n$\"'\\"
php > echo json_encode(var_representation("uses single quotes:\0\r\n\$\"'\\",
                                          VAR_REPRESENTATION_UNESCAPED));
"'uses single quotes:\u0000\r\n$\"\\'\\\\'"
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance79

Regular maintenance activity

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~279 days

Recently: every ~407 days

Total

7

Last Release

110d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/164ba466d4ade219aaf2fa0b4559086c737e59ae64928746c183082dea15c240?d=identicon)[Sergii Dolgushev](/maintainers/Sergii%20Dolgushev)

![](https://www.gravatar.com/avatar/04c4b64e4b0528a79749a79b300ef81c093cbdaeb733b2b2c2a39b4352fa19a3?d=identicon)[rlerdorf](/maintainers/rlerdorf)

![](https://www.gravatar.com/avatar/7af32b9958d7f744a727359a630572cdcffccf7492f086e132a2ba36ecc6564a?d=identicon)[Daimona](/maintainers/Daimona)

---

Top Contributors

[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (30 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (4 commits)")

---

Tags

var\_exportvar\_representation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phan-var-representation-polyfill/health.svg)

```
[![Health](https://phpackages.com/badges/phan-var-representation-polyfill/health.svg)](https://phpackages.com/packages/phan-var-representation-polyfill)
```

###  Alternatives

[brick/varexporter

A powerful alternative to var\_export(), which can export closures and objects without \_\_set\_state()

19429.7M72](/packages/brick-varexporter)[tysonandre/var_representation_polyfill

Polyfill for var\_representation: convert a variable to a string in a way that fixes the shortcomings of var\_export

146.4M](/packages/tysonandre-var-representation-polyfill)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
