PHPackages                             blackbonjour/stdlib - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. blackbonjour/stdlib

ActiveLibrary[Testing &amp; Quality](/categories/testing)

blackbonjour/stdlib
===================

Standard library for PHP

3.3.1(3y ago)4108.1k↑424.6%11MITPHPPHP ^8.0

Since Jan 30Pushed 3y ago2 watchersCompare

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

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

[![Latest Stable Version](https://camo.githubusercontent.com/92f1ef1381b4962098aa144b6db9ca8100d16ffd8f4b11b3028ceaf58b1c30f1/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b626f6e6a6f75722f7374646c69622f762f737461626c65)](https://packagist.org/packages/blackbonjour/stdlib)[![Total Downloads](https://camo.githubusercontent.com/0a09ca4d5df1ea8ad55a0ba89060706d8c183f66f6d0b649377257f23d6d9a6d/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b626f6e6a6f75722f7374646c69622f646f776e6c6f616473)](https://packagist.org/packages/blackbonjour/stdlib)[![License](https://camo.githubusercontent.com/7216314336ac1c81c8a5d7f740c9215e5a0b5063b2904142ee58bc76ce0237ba/68747470733a2f2f706f7365722e707567782e6f72672f626c61636b626f6e6a6f75722f7374646c69622f6c6963656e7365)](https://packagist.org/packages/blackbonjour/stdlib)

stdlib
======

[](#stdlib)

Standard library for PHP.

This library contains many helping classes for manipulating multibyte strings and handling various types of arrays.

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

[](#installation)

It's recommend that you use [Composer](https://getcomposer.org) to install Stdlib.

```
$ composer require blackbonjour/stdlib
```

This will install Stdlib and all required dependencies. Stdlib requires PHP 7.4 or newer.

Usage
-----

[](#usage)

Following are a few example of what this library is capable of.

### Language

[](#language)

With `StdString` you have a powerful tool for manipulating strings. Many functions are good known from other programming languages such as Java.

```
$string      = new StdString('My vehicle has %d wheels.');
$translation = StdString::format($string, 4);

echo $translation; // My vehicle has 4 wheels.
```

`StdString` is also multibyte compatible.

```
$format      = '"%s" means "%s".';
$translation = StdString::format($format, 'Привет', new StdString('Hello'));

echo $translation; // "Привет" means "Hello".
```

`StdString` instances can be created from string and `Character[]`.

`StdString` also implemented `ArrayAccess`, which allows us to treat `StdString` instances like regular strings.

```
$string = new StdString('FooBar');

echo $string[4]; // a
```

### Utils

[](#utils)

Utils contains classes for easier handling with arrays and assertions.

#### Assert

[](#assert)

With `Assert::empty()` you have the possibility to check multible values for emptiness at once. This method works exactly the same as PHPs internal function `empty()`.

```
var_dump(Assert::empty(null, 0, '', [])); // true
var_dump(Assert::empty(null, 1, 'FooBar', [])); // false
```

For the opposite way use `Assert::notEmpty` to check if all values are not empty.

```
var_dump(Assert::notEmpty(123, 'FooBar', [123])); // true
var_dump(Assert::notEmpty(123, 'FooBar', [])); // false
```

With `Assert::typeOf()` to check if multiple values are of specified types or are instances of specified classes. This method is supposed to react like PHP itself. So if the values are not of specified types or classes, a TypeError exception will be thrown. If that behaviour is not what you want, you can use the method `Assert::validate` instead. That method will return `true` if all values are of specified types or classes, false otherwise.

```
$allowedTypes = [Assert::TYPE_INTEGER, Assert::TYPE_FLOAT];

var_dump(Assert::validate($types, 123, 456.7));
```

#### HashMap

[](#hashmap)

With `HashMap` it is now possible to have arrays with objects as keys.

```
$hashMap = new HashMap;
$hashMap->put(new StdString('FooBar'), ['foo' => 'bar']);

var_dump($hashMap->key() instanceof StdString); // Returns `true`

$hashMap->put(new stdClass, new StdString('NotFooBar'));

foreach ($hashMap as $key => $value) {
    echo StdString::format('%s => %s' . PHP_EOL, gettype($key), gettype($value));
}

/*
 * Output:
 *
 * object => array
 * object => object
 */
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity78

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

Total

23

Last Release

1447d ago

Major Versions

0.5.1 → 1.0.02018-08-01

1.0.1 → 2.0.02018-11-22

2.2.0 → 3.0.02020-07-03

3.3.0 → 4.0.x-dev2022-05-24

PHP version history (7 changes)0.1.0PHP &gt;=7.0

0.4.0PHP &gt;=7.1

2.0.0PHP &gt;=7.2

3.0.0PHP &gt;=7.4

3.2.1PHP ^7.4 || 8.0

3.3.0PHP ^8.1

3.3.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/204c2f409bdf9d8041584a0f0c10480070d49814385df66a8fa895f6e64ae7c8?d=identicon)[BlackBonjour](/maintainers/BlackBonjour)

---

Top Contributors

[![BlackBonjour](https://avatars.githubusercontent.com/u/13346461?v=4)](https://github.com/BlackBonjour "BlackBonjour (115 commits)")

---

Tags

assertionsmanipulationphpstdlibstringutf-8utilutilityphputf-8stringutilitymanipulationassertionmapstdlibutilhashmap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blackbonjour-stdlib/health.svg)

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

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[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)[voku/stringy

A string manipulation library with multibyte support

1783.8M19](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

234.5M14](/packages/statamic-stringy)[danielstjules/sliceable-stringy

Python string slices in PHP

4751.6k1](/packages/danielstjules-sliceable-stringy)[tcb13/substringy

A sub string manipulation library with multibyte support that extends Stringy

1760.6k1](/packages/tcb13-substringy)

PHPackages © 2026

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