rskuipers/php-assumptions

Static code analysis tool to detect weak assumptions

Maintainers

👁 rskuipers

Package info

github.com/rskuipers/php-assumptions

pkg:composer/rskuipers/php-assumptions

Statistics

Installs: 308 274

Dependents: 17

Suggesters: 1

Stars: 164

Open Issues: 9

0.9.1 2025-03-22 15:15 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 06591c2b7f66969e02b54508a8c7576a759c0e9d

  • Rick Kuipers <io.woop@rskuipers.com>

This package is auto-updated.

Last update: 2026-06-22 18:28:13 UTC


README

👁 Build Status
👁 Scrutinizer Code Quality
👁 Code Coverage

Setup

$ composer require --dev rskuipers/php-assumptions

Introduction

PHP Assumptions is the result of a proof of concept inspired by the "From assumptions to assertions" blog post. It's a static code analysis tool doing checks for weak assumptions.

This is an example of an assumption:

if ($user !== null) {
 $user->logout();
}

Running bin/phpa on this file would yield the following output:

----------------------------------------------
| file | line | message |
==============================================
| example.php | 3 | if ($user !== null) { |
----------------------------------------------

1 out of 1 boolean expressions are assumptions (100%)

This is an example of an assertion:

if ($user instanceof User) {
 $user->logout();
}

Tests

This project is built with PHPUnit and Prophecy. In order to run these tests make sure you have dev dependencies installed with composer.

Running PHPUnit:

$ ./vendor/bin/phpunit