PHPackages                             mf/stringify - 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. mf/stringify

ActiveLibrary

mf/stringify
============

Simple and tiny class (function) to stringify anything in PHP.

7.0.0(2y ago)112.3k↓11.1%MITPHPPHP ^8.2

Since Nov 14Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (6)Versions (12)Used By (0)

Stringify
=========

[](#stringify)

[![Latest Stable Version](https://camo.githubusercontent.com/830af5b3ba4fbc38dfd737399f35a1cec6daca879f096225323efc46ced12ae5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d662f737472696e676966792e737667)](https://packagist.org/packages/mf/stringify)[![Tests and linting](https://github.com/MortalFlesh/stringify/actions/workflows/tests.yaml/badge.svg)](https://github.com/MortalFlesh/stringify/actions/workflows/tests.yaml)[![Coverage Status](https://camo.githubusercontent.com/e095c9a744f0151dd7e520442fe86a02677e4e960bcb8cc2ac62714af7c7abaf/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4d6f7274616c466c6573682f737472696e676966792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/MortalFlesh/stringify?branch=master)

Simple and tiny class (function) to stringify anything in PHP.

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

[](#installation)

```
composer require mf/stringify
```

Usage
-----

[](#usage)

### By class and static method

[](#by-class-and-static-method)

```
use MF\Stringify\Stringify;

echo Stringify::stringify([1, 2, 3]);   // "[1, 2, 3]"
```

### By standalone function

[](#by-standalone-function)

```
use function MF\Stringify\stringify;

echo stringify([1, 2, 3]);   // "[1, 2, 3]"
```

```
$result = array_map(stringify(...), [1, 'two']); // ['1', '"two"']
```

### Sprintf bonus

[](#sprintf-bonus)

> with a new `%A` placeholder for `stringify` function

```
use function MF\Stringify\sprintf;

echo sprintf('Hello %A!', 'world');     // Hello "world"!
echo sprintf('Hello %A!', ['world']);   // Hello ["world"]!
```

Example
-------

[](#example)

*NOTE: values longer than 100 chars is shrinked to 100 chars with `...` suffix*

For easier examples, let's use a standalone function

TypePHPResult (*string*)NULL`stringify(null);``null`bool`stringify(true);``true`bool`stringify(false);``false`string`stringify('');``""`string`stringify('Some string');``"Some string"`int`stringify(42);``42`float`stringify(3.14);``3.14`array`stringify([1, 2, 3]);``[1, 2, 3]`array`stringify(['foo' => 'bar']);``["foo" => "bar"]`array`stringify(['person' => ['name' => 'Peter Parker'], 'alterego' => 'spider-man']);``["person" => ["name" => "Peter Parker"], "alterego" => "spider-man"]`object`stringify(new \Foo\Bar());``Foo\Bar`object`stringify(new \DateTime());``DateTime { 2018-11-15T10:20:30+00:00 }`object`stringify(Seq::range('1..4'));``MF\Collection\Immutable\Seq [1, 2, 3, 4]`Changelog
---------

[](#changelog)

For latest changes see [CHANGELOG.md](CHANGELOG.md) file. We follow [Semantic Versioning](https://semver.org/).

Contributing and development
----------------------------

[](#contributing-and-development)

### Install dependencies

[](#install-dependencies)

```
composer install
```

### Run tests

[](#run-tests)

For each pull-request, unit tests as well as static analysis and codestyle checks must pass.

To run all those checks execute:

```
composer all
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 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 ~232 days

Recently: every ~245 days

Total

9

Last Release

887d ago

Major Versions

2.0.0 → 3.0.02019-12-02

3.0.0 → 4.0.02021-04-06

4.0.0 → 5.0.02021-04-06

5.1.0 → 6.0.02023-12-13

6.0.0 → 7.0.02023-12-13

PHP version history (6 changes)1.0.0PHP ^7.1

3.0.0PHP ^7.2

4.0.0PHP ^7.4

5.0.0PHP ^8.0

6.0.0PHP ^8.1

7.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bdf0b9957c08a48e70a52fce74fc4f1add30b12d442450d5e2b48854fc98b21?d=identicon)[MortalFlesh](/maintainers/MortalFlesh)

---

Top Contributors

[![MortalFlesh](https://avatars.githubusercontent.com/u/6317184?v=4)](https://github.com/MortalFlesh "MortalFlesh (37 commits)")

---

Tags

stringify

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mf-stringify/health.svg)

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

PHPackages © 2026

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