PHPackages                             coalesce/coalesce - 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. coalesce/coalesce

ActiveLibrary

coalesce/coalesce
=================

v0.3(10y ago)21.1kPHP

Since Jul 7Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (5)Used By (0)

`coalesce` &amp; `coalescy`
===========================

[](#coalesce--coalescy)

Two "coalescy" php functions to used while waiting for the `??` operator :

- `coalesce` : simple null coalesce function for PHP
- `coalescy` : like `coalesce`, but returns the first not falsy value.

And two functions to get a potentially undefined element without throwing `E_NOTICE`

- `val` : returns an array element or null if the index is undefined
- `prop` : returns an object property or null if the index is undefined

### Installation

[](#installation)

```
composer require coalesce/coalesce

```

### Usage

[](#usage)

```
$arr = [ 'foo' => 4, 'bar' => '' ];

// coalesce
coalesce($arr); // returns $arr
coalesce(false, $arr['foo']); // returns false
coalesce($arr['bar']); // returns ''
coalesce(null, '0', 42); // returns '0'
coalesce($arr['foobar']); // returns null (caution: this will throw a notice)
coalesce(0, $arr); // returns 0

// coalescy
coalescy($arr); // returns $arr
coalescy(false, $arr['foo']); // returns 4
coalescy($arr['bar']); // returns null
coalescy(null, '0', 42); // returns 42
coalescy($arr['foobar']); // returns null (caution: this will throw a notice)
coalescy(0, $arr); // returns $arr

// To avoid notices, you can use val :
val($arr, 'bar'); // returns '' ($arr['bar'])
val($arr, 'foobar'); // returns null (without throwing a notice)
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

3

Last Release

3967d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/203f3ce6c6180231469043d9ee214e371d880cf6527c29e9b7416921f92b03ba?d=identicon)[dorian-marchal](/maintainers/dorian-marchal)

---

Top Contributors

[![dorian-marchal](https://avatars.githubusercontent.com/u/6225979?v=4)](https://github.com/dorian-marchal "dorian-marchal (10 commits)")

### Embed Badge

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

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

PHPackages © 2026

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