Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rskuipers/php-assumptions
Tool to detect assumptions
https://github.com/rskuipers/php-assumptions
Last synced: 13 days ago
JSON representation
Tool to detect assumptions
- Host: GitHub
- URL: https://github.com/rskuipers/php-assumptions
- Owner: rskuipers
- License: mit
- Created: 2015-08-04T21:08:31.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-15T19:34:25.000Z (over 2 years ago)
- Last Synced: 2024-04-23T15:42:13.317Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 78.1 KB
- Stars: 155
- Watchers: 4
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Assumptions
[![Build Status](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/badges/build.png?b=master)](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/build-status/master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/rskuipers/php-assumptions/?branch=master)## Setup
```sh
$ composer require --dev rskuipers/php-assumptions
```## Introduction
PHP Assumptions is the result of a proof of concept inspired by the "[From assumptions to assertions](http://rskuipers.com/entry/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**:
```php
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**:
```php
if ($user instanceof User) {
$user->logout();
}
```## Tests
This project is built with [PHPUnit](https://github.com/sebastianbergmann/phpunit) and [Prophecy](https://github.com/phpspec/prophecy-phpunit).
In order to run these tests make sure you have dev dependencies installed with composer.Running PHPUnit:
```sh
$ ./vendor/bin/phpunit
```