hanaboso/php-check-utils

Utils for php development - CodeSniffer, PhpStan, PhpUnit, PhpStorm

1.6.4 2024-06-19 16:47 UTC

README

Build Status PHPStan Downloads

Installation

  • Download package via composer
composer require --dev hanaboso/php-check-utils

CodeSniffer

./vendor/bin/phpcs --standard=./ruleset.xml -p src/ tests/
  • ruleset.xml for app
<?xml version="1.0"?>
<ruleset name="HANABOSO CODE STYLE">
    <rule ref="./vendor/hanaboso/php-check-utils/ruleset.xml"/>
    <rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
        <properties>
            <property name="rootNamespaces" type="array" value="
                src=>MyBundle, 
                tests=>Tests 
            "/>
        </properties>
    </rule>
</ruleset>

CodeFixer

./vendor/bin/phpcbf --standard=./ruleset.xml -p src/ tests/

PhpStan

./vendor/bin/phpstan analyse -c phpstan.neon -l 8 src/ tests/
  • phpstan.neon for app
includes:
    - vendor/hanaboso/php-check-utils/phpstan.neon # hanaboso rules
parameters
    excludes_analyse:
    ignoreErrors:
    symfony:
        container_xml_path: %rootDir%/../../../var/cache/dev/srcDevDebugProjectContainer.xml

CodeCoverage

  • run Coverage.sh
./vendor/hanaboso/php-check-utils/bin/coverage.sh 100

PhpStorm - Code Style

  • Import code style XML file from ./vendor/hanaboso/php-check-utils/phpstorm.xml to PhpStorm
  • Open import window
File -> Settings -> Code Style -> PHP -> Import Scheme -> Intellij IDEA code style XML