diff --git a/CHANGELOG.md b/CHANGELOG.md index e111186..698a605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.5.0 - UNRELEASED +### Notes +- Risky mode is enabled by default + The `logical_operators` rule is considered risky as operators `and` and `&&` + have different precedence and in rare cases the logic of existing code could change. + In order to run those correctly by default, the risky flag is default enabled for our config. + +### Added +- `logical_operators`: Disallow `and` and `or` operator in favor of `&&` and `||`. + ## 1.4.0 — 2025-07-19 ### Added * `no_whitespace_in_blank_line`: Remove trailing whitespace at the end of blank lines diff --git a/src/Config.php b/src/Config.php index beb5854..a37568c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -8,14 +8,15 @@ use PhpCsFixerCustomFixers; class Config extends Base { - public function __construct($name = 'default') { + public function __construct($name = 'default', bool $allowRisky = true) { parent::__construct($name); $this->setIndent("\t"); $this->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()); + $this->setRiskyAllowed($allowRisky); } public function getRules() : array { - return [ + $rules = [ '@PSR1' => true, '@PSR2' => true, 'align_multiline_comment' => true, @@ -84,5 +85,11 @@ public function getRules() : array { 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true, ]; + + if ($this->getRiskyAllowed()) { + $rules['logical_operators'] = true; + } + + return $rules; } }