PHPackages                             angle/falsy - 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. angle/falsy

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

angle/falsy
===========

Falsy helps you manage half-truths with PHP

v1.0.5(7y ago)22.2k1MITPHPPHP ^7.0

Since Jan 18Pushed 7y agoCompare

[ Source](https://github.com/anglesoft/falsy)[ Packagist](https://packagist.org/packages/angle/falsy)[ RSS](/packages/angle-falsy/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (2)Versions (6)Used By (0)

🤥 Helpers for dealing with falsy and truthy values in PHP.
==========================================================

[](#-helpers-for-dealing-with-falsy-and-truthy-values-in-php)

- Tiny library (&lt; 200 lines total, adds 2 functions to the global namespace)
- No dependencies
- Fully tested
- Requires PHP version ^7.0

Functions
---------

[](#functions)

### falsy(...$vars) : bool

[](#falsyvars--bool)

Returns false whenever a variable is falsy.

### truthy(...$vars) : bool

[](#truthyvars--bool)

Returns true only when all variables are truthy (opposite of falsy).

Examples
--------

[](#examples)

If anything is falsy, the function returns true.

```
falsy(true, false, null); // true
truthy(true, false, null); // false
```

If all variables are truthy, the function returns false.

```
falsy(true, 1, [1]); // false
truthy(true, 1, [1]); // true
```

Null strings and empty arrays are falsy.

```
falsy('0', '', [], ['']); // true
truthy('0', '', [], ['']); // false

// Note: (bool) [''] returns true in plain PHP. Falsy interprets it as false, as it should.
```

Arrays are recursively audited.

```
$array = [
    'foo' => false,
    'bar'=> [
        'baz' => false
    ]
];

falsy($array); // true
truthy($array); // false

$array = [
    'foo' => true,
    'bar'=> [
        'baz' => 1
    ]
];

falsy($array); // false
truthy($array); // true
```

Objects are audited on their properties.

```
$object = new stdClass;

falsy($object); // true
truthy($object); // false

$object->foo = false;
$object->bar = null;
$object->baz = 0;

falsy($object); // true
truthy($object); // false

$object->foo = true;
$object->bar = 'string';
$object->baz = 1;

falsy($object); // false
truthy($object); // true
```

Closures are audited on their return value.

```
$void = function () { return; };

falsy($void); // true
truthy($void); // false

$false = function () { return false; };

falsy($false); // true
truthy($false); // false

$string = function () { return 'string'; };

falsy($string); // false
truthy($string); // true

falsy($void, $false, $string); // true
truthy($void, $false, $string); // false
```

Finally, you may pass as many statements as you need.

```
falsy(
    false,
    null,
    0,
    0.0,
    '0',
    [],
    [''], // Php would consider this as being true, but really, is it? No.
    ['' => ''],
    [false, null],
    ['' => '', 0 => ['key' => null, 'foo' => [''], 'empty' => []]], // Array keys are ignored
    new stdClass, // Objects with empty attributes are falsy
    function () { return; }, // Void closures are falsy
    function () { return false; },
    function () { return null; },
    function () { return ''; },
    function () { return 0; },
    function () { return []; },
    function () { return ['']; }
); // true

$object = new stdClass;
$object->foo = 'bar';

truthy(
    true,
    1,
    0.1,
    '1',
    ['foo'],
    ['foo' => 'bar'],
    [true],
    $object,
    function () { return true; },
    function () { return 1; },
    function () { return 0.1; },
    function () { return '1'; },
    function () { return ['foo']; },
    function () { return ['foo' => 'bar']; },
    function () { return [true]; },
    function () use ($object) { return $object; }
); // true
```

Testing
-------

[](#testing)

Run the test suite by executing:

```
    composer install
    ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Contributions are welcomed! Feel free to submit a pull request anytime.

Licence
-------

[](#licence)

MIT License

Copyright © 2019 [Angle Software](https://angle.software)

###  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

Maturity59

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

Total

5

Last Release

2622d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8617801?v=4)[Angle Consulting](/maintainers/angle)[@Angle](https://github.com/Angle)

---

Top Contributors

[![benvilliere](https://avatars.githubusercontent.com/u/22590566?v=4)](https://github.com/benvilliere "benvilliere (18 commits)")

---

Tags

data-structures-algorithmsfalsyphptruthyphphelperstruthyfalsy

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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