Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,45 @@

[![Downloads](https://img.shields.io/packagist/dt/symplify/coding-standard.svg?style=flat-square)](https://packagist.org/packages/symplify/coding-standard/stats)

Set of rules for PHP_CodeSniffer and PHP-CS-Fixer used by Symplify projects.
Coding standard rules for clean, consistent, and readable PHP code. No configuration needed—just install and let it handle the rest.

**They run best with [EasyCodingStandard](https://github.com/symplify/easy-coding-standard)**.
They run best with [ECS](https://github.com/symplify/easy-coding-standard).

<br>

## Install

```bash
composer require symplify/coding-standard --dev
composer require symplify/easy-coding-standard --dev
composer require phpecs/phpecs --dev
```

1. Run with [ECS](https://github.com/symplify/easy-coding-standard):
1. Register in ECS config:

```diff
# ecs.php
```php
# ecs.php
use Symplify\EasyCodingStandard\Config\ECSConfig;
+use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
+ $ecsConfig->sets([SetList::SYMPLIFY]);
return ECSConfig::configure()
->withSets([SetList::SYMPLIFY]);
```


2. And run:

```bash
# dry-run without changes
vendor/bin/ecs


# apply changes
vendor/bin/ecs --fix
```

<br>

<!-- ruledoc-start -->
# 12 Rules Overview
# 12 Rules to Keep Your Code Clean

## ArrayListItemNewlineFixer

Expand Down Expand Up @@ -255,5 +266,3 @@ Promoted property should be on standalone line
```

<br>

<!-- ruledoc-end -->
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
"require": {
"php": ">=8.2",
"nette/utils": "^4.0",
"friendsofphp/php-cs-fixer": "^3.59",
"friendsofphp/php-cs-fixer": "^3.73.1",
"symplify/rule-doc-generator-contracts": "^11.2"
},
"require-dev": {
"symplify/easy-coding-standard": "^12.3",
"squizlabs/php_codesniffer": "^3.10.1",
"phpunit/phpunit": "^10.5",
"symplify/rule-doc-generator": "^12.2.2",
"symplify/easy-coding-standard": "^12.5",
"squizlabs/php_codesniffer": "^3.12",
"phpunit/phpunit": "^11.5",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.11",
"rector/rector": "^1.1",
"symplify/phpstan-extensions": "^11.4",
"tomasvotruba/class-leak": "^0.2",
"phpstan/phpstan": "^2.1",
"rector/rector": "^2.0",
"symplify/phpstan-extensions": "^12.0",
"tomasvotruba/class-leak": "^2.0",
"tracy/tracy": "^2.10"
},
"autoload": {
Expand All @@ -38,8 +37,7 @@
"scripts": {
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
"rector": "vendor/bin/rector process --dry-run --ansi",
"docs": "vendor/bin/rule-doc-generator generate src --readme --ansi"
"phpstan": "vendor/bin/phpstan analyse --ansi",
"rector": "vendor/bin/rector process --dry-run --ansi"
}
}
226 changes: 0 additions & 226 deletions docs/rules_overview.md

This file was deleted.

8 changes: 5 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
parameters:
level: 8

errorFormat: symplify

paths:
- src
- config
Expand All @@ -24,7 +26,7 @@ parameters:
# unused generics
- '#Class (.*?) implements generic interface PhpCsFixer\\Fixer\\ConfigurableFixerInterface but does not specify its types\: TFixerInputConfig, TFixerComputedConfig#'

# false positive
# conditional check to allow various php versions
-
message: '#Parameter \#1 \$sequence of method PhpCsFixer\\Tokenizer\\Tokens\:\:findSequence\(\) expects non\-empty\-array<int, array\{0\: int, 1\?\: string\}\|PhpCsFixer\\Tokenizer\\Token\|string>, array<PhpCsFixer\\Tokenizer\\Token> given#'
path: src/Fixer/Strict/BlankLineAfterStrictTypesFixer.php
message: '#Comparison operation ">\=" between int<80200, 80499> and (.*?) is always true#'
path: src/TokenAnalyzer/DocblockRelatedParamNamesResolver.php
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
return RectorConfig::configure()
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
->withPhpSets()
->withRootFiles()
->withPreparedSets(codeQuality: true, codingStyle: true, naming: true, earlyReturn: true, privatization: true)
->withImportNames(removeUnusedImports: true)
->withSkip([
Expand Down
Loading