๐Ÿ”ฐ Instant PHP quality checks from your console

Overview

PHP Insights PHP Insights Preview

Build Status Total Downloads Latest Version License

For full documentation, visit phpinsights.com.

PHP Insights was carefully crafted to simplify the analysis of your code directly from your terminal, and is the perfect starting point to analyze the code quality of your PHP projects. It was created by Nuno Maduro, and currently maintained by Jibรฉ Barth, Nuno Maduro, Oliver Nybroe, and Caneco.

๐Ÿš€ Quick start

# First, install:
composer require nunomaduro/phpinsights --dev

# Then, use it:
./vendor/bin/phpinsights

# For Laravel:
First, publish the configuration file:
php artisan vendor:publish --provider="NunoMaduro\PhpInsights\Application\Adapters\Laravel\InsightsServiceProvider"

Then, use it:
php artisan insights

โœจ Features

  • Analysis of code quality and coding style
  • Beautiful overview of code architecture and its complexity
  • Designed to work out-of-the-box with Laravel, Symfony, Yii, Magento, and more
  • Contains built-in checks for making code reliable, loosely coupled, simple, and clean

๐Ÿ’– Support the development

Do you like this project? Support it by donating

PHP Insights is open-sourced software licensed under the MIT license.

Comments
  • SniffDecorator.php is throwing Runtime Exception

    SniffDecorator.php is throwing Runtime Exception

    | Q | A | ---------------- | ----- | Bug report? | yes | Feature request? | no | Library version | 1.14

    I'm getting the following issue when I run the below command:

    vendor/bin/phpinsights --no-interaction --min-quality=90 --min-complexity=80 --min-architecture=80 --min-style=95 --config-path=config/insights.php

    image

    I'm using "nunomaduro/phpinsights": "^1.14"

    My Observation:

    This issue is not there in the version 1.13 but I've seen this issue has been fixed in 1.14 as well but still getting the same issue. Because when install package version with "^" symbol it is always fetching latest package i.e; version 1.14.

    Also, when I see the code in SniffDecorator.php file on git repo 1.14 version I'm not seeing below piece of code

    set_error_handler(static function (): bool {
                throw new \RuntimeException();
            }, E_NOTICE);
    

    But when I download the package into my application using "composer require" command then inside "vendor/nunomaduro" I'm able to see the same lines of code mentioned above. This particular code snippet causing an issue.

    I guess the gip available on git repo might not be properly made.

    Hope you understand the issue and you gonna fix that in current latest branch/tag.

    Thanks

    Using traits in inline classes causes two false positives:

    • SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff
      • Will report an error since there is spacing between the use of the trait and the "import" use list.
    • SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff
      • May report an error if the trait is NOT the last item in the "import" use list.
    use A\SomeTrait;
    use B\SomeOtherImport;
    
    (new class() { use SomeTrait; })->someMethod();