Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurJCQ committed Jan 22, 2024
1 parent fd3b1b4 commit 0bd38c6
Showing 1 changed file with 56 additions and 9 deletions.
65 changes: 56 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,73 @@

This is the coding style tools config I use everyday on my projects.

## PHPCS
it includes :
- PHPCS for code sniffing.
- PHPStan for static bug finding into code.
- PHPMD for static performance analysis (complexity, unused expressions, optimizing).

PHPCS for code sniffing :
## Installation

Installation with composer :

```bash
composer require etsglobal/php-static-analysis --dev
```

## Usage

### PHPCS

In your project, create a `phpcs.xml` file and fill it up with :

```xml
<?xml version="1.0"?>
<ruleset name="Arty Coding Standard"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd">
<rule ref="./vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml" />
</ruleset>
```

Run it with :
```bash
$ ./vendor/bin/phpcs
$ ./vendor/bin/phpcs src
```

## PHPStan
### PHPStan

PHPStan for static bug finding into code.
In your project, create a `phpstan.neon` file and fill it up with :

```neon
includes:
- vendor/arty/php-coding-standard/lib/phpstan/phpstan.neon
```

Run it with :
```bash
$ ./vendor/bin/phpstan
$ ./vendor/bin/phpstan analyse --level=max src
```

## PHPMD
### PHPMD

PHPMD for static performance analysis (complexity, unused expressions, optimizing).
In your project, create a `pphmd.xml` file and fill it up with :

```xml
<?xml version="1.0"?>
<ruleset name="Arty ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Arty ruleset
</description>

<rule ref="./vendor/etsglobal/php-static-analysis/lib/phpmd/phpmd.xml"/>
</ruleset>
```

Run it with :
```bash
$ ./vendor/bin/phpmd
$ ./vendor/bin/phpmd src text phpmd.xml
```

0 comments on commit 0bd38c6

Please sign in to comment.