PHPackages                             icecave/repr - 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. icecave/repr

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

icecave/repr
============

A library for generating string representations of any value, inspired by Python's reprlib library.

4.0.0(5y ago)277.1M—8.4%14MITPHPPHP &gt;=7.2CI failing

Since Jan 11Pushed 5y ago2 watchersCompare

[ Source](https://github.com/icecave/repr)[ Packagist](https://packagist.org/packages/icecave/repr)[ Docs](https://github.com/icecave/repr)[ RSS](/packages/icecave-repr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (4)

Repr
====

[](#repr)

[![Build Status](https://camo.githubusercontent.com/92f2cda2247c417ebcd80d44926166360cb04b3e46c7404fe976876bff87000f/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f696365636176652f726570722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/icecave/repr)[![Code Coverage](https://camo.githubusercontent.com/850de456c5249bff3cd0395b49875737aee0dd59629cf0045dc6dc42189cac4d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f696365636176652f726570722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/icecave/repr)[![Latest Version](https://camo.githubusercontent.com/e7f65b349326000e3051898c26b062e4e65c7e6fcaf10e63fa7421e171d598c2/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696365636176652f726570722e7376673f7374796c653d666c61742d737175617265266c6162656c3d73656d766572)](https://semver.org)

**Repr** provides a way to generate informational string representations of any value, inspired by Python's [reprlib](http://docs.python.org/release/3.1.5/library/reprlib.html) library.

```
composer require icecave/repr

```

Example
-------

[](#example)

Use the `Repr::repr()` method to obtain a string representation for any type.

```
use Icecave\Repr\Repr;

echo Repr::repr([1, 2, 3]);
```

The output from the example above is:

```
[1, 2, 3]

```

### Arrays

[](#arrays)

Arrays are represented using PHP 5.4 style short array notation. By default a maximum of 3 elements are shown along with a count of any additional elements. Nested arrays are represented up to 3 levels deep by default, with any arrays nested deeper than this showing only the element count.

### Numeric Values

[](#numeric-values)

Numbers are represented naturally, floating point values will always display a decimal point even if representing a whole number.

### Strings

[](#strings)

Strings are represented enclosed in double quotes up to a default maximum length of 50 characters. Any control characters are shown as escape sequences.

### Objects

[](#objects)

Objects are represented as a class name and SPL object hash enclosed in angle brackets. If the object has a `__toString`method, the result of this is shown after the class name according to the rules of string representations specified above.

If an object implements [RepresentableInterface](src/Icecave/Repr/RepresentableInterface.php), the result of its stringRepresentation() method is used instead.

### Resources

[](#resources)

Resources are represented as a resource type and ID enclosed in angle brackets. Stream resources will also display the stream mode.

### Other Types

[](#other-types)

All other types are represented by the result of [var\_export()](http://php.net/manual/en/function.var-export.php) in lowercase.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~556 days

Total

6

Last Release

2093d ago

Major Versions

1.0.1 → 2.0.02019-05-27

2.0.1 → 3.0.02020-08-25

3.0.0 → 4.0.02020-08-25

PHP version history (4 changes)1.0.0PHP &gt;=5.3.0

1.0.1PHP &gt;=5.3

2.0.0PHP &gt;=7.1

3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/93a71bd75fcd51efee464532dbdd54927cd00e938805998c76e0a804d38fa3fb?d=identicon)[jmalloc](/maintainers/jmalloc)

---

Top Contributors

[![jmalloc](https://avatars.githubusercontent.com/u/761536?v=4)](https://github.com/jmalloc "jmalloc (58 commits)")

---

Tags

stringreadablehumanrepresentationrepr

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/icecave-repr/health.svg)

```
[![Health](https://phpackages.com/badges/icecave-repr/health.svg)](https://phpackages.com/packages/icecave-repr)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[react/stream

Event-driven readable and writable streams for non-blocking I/O in ReactPHP

689126.8M194](/packages/react-stream)[coduo/php-to-string

Simple library that converts PHP value into strings

27112.7M10](/packages/coduo-php-to-string)[danielstjules/php-pretty-datetime

Generates human-readable strings for PHP DateTime objects

5791.9k](/packages/danielstjules-php-pretty-datetime)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)

PHPackages © 2026

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