PHPackages                             conceptbyte/null-object - 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. conceptbyte/null-object

ActivePackage

conceptbyte/null-object
=======================

A Null Object for PHP.

v1.0.0(9y ago)538MITPHPPHP &gt;=5.5.9

Since Jul 25Pushed 9y ago2 watchersCompare

[ Source](https://github.com/conceptbyte/null-object)[ Packagist](https://packagist.org/packages/conceptbyte/null-object)[ RSS](/packages/conceptbyte-null-object/feed)WikiDiscussions master Synced 2mo ago

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

Null Object for PHP
===================

[](#null-object-for-php)

Allows the user to call the null object which handles all calls silently and returns sensible defaults. The returned object can be type cast to return the following values:

- String - ""
- Integer - 0
- Float or Real - 0.0
- Array - \[\]
- Boolean - False

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

[](#installation)

Run the following to install:

`composer require conceptbyte/null-object`

Usage
-----

[](#usage)

The null object can be created in one of the following methods:

- Named constructor: `NullObject::create()`
- Helper function: `no()`

Both will return an instance of the class. Calls to any methods or members on this class will return the defaults as mentioned in the section above.

Example
-------

[](#example)

```
(string) NullObject::create()->xyz; // ""
(bool) NullObject::create()->abc(); // false
(int) no()->xyz; // 0
(float) no()->abc(); // 0.0
```

Quirks
------

[](#quirks)

PHP does not allow modifying the behaviour of casting a class to boolean. A simple hack is to use the SimpleXMLElement class which can return false when passed an empty XML tag.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3582d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d1b378098cc6e86d56dee9c2854fd422cca62bbcf38dc4289d31ac096d0ff3c?d=identicon)[rajdeeptarat](/maintainers/rajdeeptarat)

---

Top Contributors

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

---

Tags

nullnullobjectphpnullnull-objectnull object pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/conceptbyte-null-object/health.svg)

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

###  Alternatives

[kartik-v/bootstrap-checkbox-x

An extended checkbox plugin for bootstrap with three states and additional styles.

921.0M1](/packages/kartik-v-bootstrap-checkbox-x)[kartik-v/yii2-checkbox-x

Extended checkbox widget for bootstrap with three states and additional styles.

26987.3k11](/packages/kartik-v-yii2-checkbox-x)[mpyw/null-auth

Null Guard for Laravel. Designed for Middleware-based authentication and testing.

18112.3k](/packages/mpyw-null-auth)[xiyusullos/nullable

chain calls on object whatever the object is null or not

152.2k](/packages/xiyusullos-nullable)

PHPackages © 2026

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