PHPackages                             nulpunkt/php-stub - 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. nulpunkt/php-stub

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

nulpunkt/php-stub
=================

Small stubbing library for making dumb colaborators.

0.3.0(11y ago)213.7k2MITPHPPHP &gt;=5.3.0

Since Oct 4Pushed 11y ago1 watchersCompare

[ Source](https://github.com/nulpunkt/php-stub)[ Packagist](https://packagist.org/packages/nulpunkt/php-stub)[ Docs](http://github.com/nulpunkt/php-stub)[ RSS](/packages/nulpunkt-php-stub/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

php-stub [![Build Status](https://camo.githubusercontent.com/9748d3437e5da98f8e0f5f6cb6060e9e05023da3019a7825eed2469367132faf/68747470733a2f2f7472617669732d63692e6f72672f6e756c70756e6b742f7068702d737475622e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/nulpunkt/php-stub)
===========================================================================================================================================================================================================================================================================================

[](#php-stub-)

A library for making colaborators, meant for testing.

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

[](#installation)

Use composer to require:

```
"nulpunkt/php-stub": "dev-master"

```

Examples
--------

[](#examples)

```
use Nulpunkt\PhpStub\Stub;

// A standard Stub
$stub = new Stub([
    'answer' => 42,
    'callMe' => function($a) { return $a; } # Anything which is a callable
]);
$stub->foo = 'bar';
$stub->myMethod = function() { return 50; };
echo $stub->answer(); # => 42
echo $stub->answer; # => 42
echo $stub->callMe('maybe'); # => 'maybe'
echo $stub->foo; # => 'bar'
echo $stub->myMethod(); # => 50
echo $stub->lol()->hey(); # => $stub

// Different configurations
$stub = new Stub([], ['chainable' => false]);
echo $stub->lol(); # => null

// We can throw exceptions on missing functions
$stub = new Stub([], ['throw' => true]);
echo $stub->lol(); # throws a RuntimeException

$stub = new Stub(
	[],
	['throw' => true, 'exceptionclass' => 'InvalidArgumentException', 'exceptionmessage' => 'Bad function call']
);
echo $stub->lol(); # throws an InvalidArgumentException with message "Bad function call"
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% 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 ~133 days

Total

4

Last Release

4204d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

0.3.0PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc8b29e9123328c25c83cf2cba2bd3a06c0897c77cedf74ef22c63408e39be10?d=identicon)[nulpunkt](/maintainers/nulpunkt)

---

Top Contributors

[![nulpunkt](https://avatars.githubusercontent.com/u/1875948?v=4)](https://github.com/nulpunkt "nulpunkt (13 commits)")[![sergeylukin](https://avatars.githubusercontent.com/u/720339?v=4)](https://github.com/sergeylukin "sergeylukin (6 commits)")

---

Tags

stubs

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/nulpunkt-php-stub/health.svg)

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

###  Alternatives

[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k27.7M68](/packages/jetbrains-phpstorm-stubs)[phalcon/ide-stubs

The most complete Phalcon Framework IDE stubs library which enables autocompletion in modern IDEs.

1623.1M121](/packages/phalcon-ide-stubs)[bazilio/yii2-stubs-generator

Yii2 component stubs generator for Yii::$app

146720.4k1](/packages/bazilio-yii2-stubs-generator)[bpocallaghan/generators

Custom Laravel File Generators with config and publishable stubs.

11965.8k3](/packages/bpocallaghan-generators)

PHPackages © 2026

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