Skip to content

Instantly share code, notes, and snippets.

@sany2k8
Last active August 29, 2017 11:16
Show Gist options
  • Select an option

  • Save sany2k8/6fbccd7b84244010284e9ed693d6539b to your computer and use it in GitHub Desktop.

Select an option

Save sany2k8/6fbccd7b84244010284e9ed693d6539b to your computer and use it in GitHub Desktop.

PHP assumption

PHP assumption is a static code analysis tool doing checks for weak assumptions. It helps us to convert our weak assumptions to assertions

Update System:

sudo apt-get update

Install the curl utility:

sudo apt-get install curl

Download the installer:

sudo curl -s https://getcomposer.org/installer | php

Move the composer.phar file:

sudo mv composer.phar /usr/local/bin/composer

Check composer installation:

composer

Create a directory on your server for this project:

sudo mkdir /var/www/html/vrs_project

Move to that directory:

cd /var/www/html/vrs_project

Then setup php assumption:

composer require --dev rskuipers/php-assumptions

For more info. about composer installation and usage : [https://www.1and1.com/cloud-community/learn/application/php/install-and-use-php-composer-on-ubuntu-1604/]

How to run assumption tool from terminal:

/var/www/html/rentalhomes_fullsolr/vendor$ bin/phpa /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php

RESULTS:


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| file                                                                           | line | message                                                                                                          |
============================================================================================================================================================================================================
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 11   | if($keyword)                                                                                                     |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 16   | if($search_by_property_id == true)                                                                               |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 24   | if( !$keyword )                                                                                                  |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 59   | if(SiteConfig::ajaxCache == false && isset($data['result']) && !empty($data['result']))                          |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 120  | if($search_cache_bucket){                                                                                        |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 150  | if($additions)                                                                                                   |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 156  | if($submitted_list)                                                                                              |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 180  | if($favorite == 3)                                                                                               |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 184  | elseif($favorite == 2)                                                                                           |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 231  | if($isMapDragged)                                                                                                |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 301  | if( !$keyword )                                                                                                  |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 318  | if(SiteConfig::ajaxCache == false && $cacheEnable)                                                               |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 318  | if(SiteConfig::ajaxCache == false && $cacheEnable)                                                               |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 328  | if($add_keyword)                                                                                                 |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 370  | $result["refresh_type"] = (isset($_REQUEST['page']) && $_REQUEST['page'] != 1) ? "refresh" : "";                 |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 371  | $result["stays_home"] = (isset($_REQUEST['stays_home']) && $_REQUEST['stays_home'] != 1) ? "stays_home" : false; |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 429  | if($items){                                                                                                      |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 453  | if($lat != 0){                                                                                                   |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 471  | if($search){                                                                                                     |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 473  | if($geo_results){                                                                                                |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 532  | if($listing_properties){                                                                                         |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 607  | if ( Yii::app()->params['enabled_im_reconciliation'] == 1 && is_array($im_data) )                                |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 667  | if($keyword && $date_start && $date_end){                                                                        |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| /var/www/html/rentalhomes_fullsolr/protected/controllers/ListingController.php | 697  | if($cb_url){                                                                                                     |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

24 out of 101 boolean expressions are assumptions (24%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment