PHPackages                             dave1010/it-should - 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. dave1010/it-should

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

dave1010/it-should
==================

IT: Inline Test for PHP

00PHPCI passing

Since Dec 1Pushed 7mo agoCompare

[ Source](https://github.com/dave1010/it)[ Packagist](https://packagist.org/packages/dave1010/it-should)[ RSS](/packages/dave1010-it-should/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

IT
==

[](#it)

IT: Inline Test for PHP, designed for PHP 8 5.

Install
-------

[](#install)

```
composer require --dev dave1010/it-should
```

Usage
-----

[](#usage)

### Console command

[](#console-command)

Run inline tests under one or more files/directories:

```
./vendor/bin/it src
```

Run `./vendor/bin/it help` for available options.

### Writing tests

[](#writing-tests)

Write tests inline on functions and methods with the `\IT\Should` annotation.

```
#[\IT\Should(return: 4, given: [2, 2])]
function add(int $a, int $b): int {
    return $a + $b;
}
```

Use the `given` parameter to pass the arguments that should be provided to your function or method when executing the inline test.

For methods, IT will instantiate a new object when the method is non-static (without handling constructor arguments). You can override this by providing a callable in the optional `with` parameter to create the system under test:

```
class Incrementer
{
    public function __construct(private int $step)
    {
    }

    #[\IT\Should(return: 2, given: [1], with: static function () { return new Incrementer(1); })]
    public function add(int $value): int
    {
        return $value + $this->step;
    }
}
```

Any callable is accepted here, whether a static closure (possible in PHP 8.5 attributes) or a class factory method.

### Running tests

[](#running-tests)

```
./vendor/bin/it src
```

IT will look at all the functions and classes/methods in `src` that have the `\IT\Should`attributes, then call each one, checking the output is as expected.

Development
-----------

[](#development)

For contributors working on this repository, the console command lives at `bin/it`, *Not* in `vendor`. Run `composer install` after cloning to generate the local `vendor/autoload.php` so `bin/it` and the bundled `examples` work without additional setup.

The examples and CI workflow currently run against PHP 8.5; you can mirror this locally with:

```
php bin/it examples
```

Architecture
------------

[](#architecture)

Main interfaces:

- Locator (finds inline tests in code, via reflection).
- Executor (runs the tests and captures results).
- Comparator (compares actual vs expected, producing human-friendly diffs).
- Reporter (outputs results, exit with non-zero if any failure).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance45

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50682?v=4)[Dave Hulbert](/maintainers/dave1010)[@dave1010](https://github.com/dave1010)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/dave1010-it-should/health.svg)

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

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

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