johnatas-x / php-assumptions
Static code analysis tool to detect weak assumptions
0.9.0
2025-02-07 13:44 UTC
Requires
- league/climate: ^3.1
- nikic/php-parser: ^5.0
Requires (Dev)
- phpspec/prophecy: ~1.0
- phpunit/phpunit: ^5.6
This package is auto-updated.
Last update: 2025-02-07 13:45:31 UTC
README
This project is a fixed drop-in replacement for rskuipers/php-assumptions
Note
PHP 8.x compatibility is WIP.
Setup
$ composer require --dev johnatas-x/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