From e4f9f178acf2cff4ccf20a0ed408acb43dedd69b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 21 Sep 2023 03:10:39 +0200 Subject: [PATCH] Changelog and readme updates for PHPCSExtra 1.2.0 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 19 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2fffeb6..5a619724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,36 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses _Nothing yet._ +## [1.2.0] - 2023-12-02 + +### Added + +#### Universal + +* :wrench: :books: New `Universal.CodeAnalysis.NoDoubleNegative` sniff to detect double negatives (!!) and advise to use a boolean cast instead. Thanks [@diedexx] for reviewing. [#277] +* :wrench: :books: New `Universal.Operators.ConcatPosition` sniff to enforce that the concatenation operator for multi-line concatenations is in a preferred position, either always at the start of the next line or always at the end of the previous line. [#294] +* :wrench: :bar_chart: :books: New `Universal.PHP.LowercasePHPTag` sniff to enforce that the "PHP" in a PHP open tag is lowercase. Thanks [@fredden] for reviewing. [#276] + +### Changed + +#### NormalizedArrays + +* `NormalizedArrays.Arrays.CommaAfterLast`: the sniff now has two extra error codes to distinguish between multi-line arrays with the last array item on the _same line_ as the array closer vs the last array item being on a line _before_ the array closer. Thanks [@stronk7] for suggesting and patching this. [#283], [#284] + These new error codes allow for selectively excluding that specific situation from triggering the sniff. + The new error codes are `FoundMultiLineCloserSameLine` (for `multiLine="forbid"`) and `MissingMultiLineCloserSameLine` (for `multiLine="enforce"`). + The pre-existing `FoundMultiLine` and `FoundSingleLine` error codes continue to be used for multi-line arrays with the last array item on a different line than the array closer. + +#### Other + +* Various housekeeping. + +[#276]: https://github.com/PHPCSStandards/PHPCSExtra/pull/276 +[#277]: https://github.com/PHPCSStandards/PHPCSExtra/pull/277 +[#283]: https://github.com/PHPCSStandards/PHPCSExtra/issues/283 +[#284]: https://github.com/PHPCSStandards/PHPCSExtra/pull/284 +[#294]: https://github.com/PHPCSStandards/PHPCSExtra/pull/294 + + ## [1.1.2] - 2023-09-21 ### Changed @@ -523,6 +553,7 @@ This initial alpha release contains the following sniffs: [php_version-config]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-php-version [Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/stable...HEAD +[1.2.0]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.2...1.2.0 [1.1.2]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.1...1.1.2 [1.1.1]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.4...1.1.0 @@ -537,5 +568,8 @@ This initial alpha release contains the following sniffs: [@anomiex]: https://github.com/anomiex [@derickr]: https://github.com/derickr +[@diedexx]: https://github.com/diedexx +[@fredden]: https://github.com/fredden [@GaryJones]: https://github.com/GaryJones +[@stronk7]: https://github.com/stronk7 [@szepeviktor]: https://github.com/szepeviktor diff --git a/README.md b/README.md index d984ef0b..01ebceac 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,13 @@ Detects `foreach` control structures which use the same variable for both the ke Note: The fixer will maintain the existing behaviour of the code. This may not be the _intended_ behaviour. +#### `Universal.CodeAnalysis.NoDoubleNegative` :wrench: :books: + +Detects double negation `!!` in code, which is effectively the same as a boolean cast, but with a much higher cognitive load. +Also detects triple negation `!!!`, which is effectively the same as a single negation. + +The sniff has modular error codes to allow for disabling individual checks. The error codes are: `FoundDouble`, `FoundDoubleWithInstanceof` (not auto-fixable) and `FoundTriple`. + #### `Universal.CodeAnalysis.NoEchoSprintf` :wrench: :books: Detects use of the inefficient `echo [v]sprintf(...);` combi. Use `[v]printf()` instead. @@ -361,6 +368,14 @@ Enforce that the names used in a class/enum "implements" statement or an interfa The fixer will separate each name with a comma and one space. If alternative formatting is desired, a sniff which will check and fix the formatting should be added to the ruleset. +#### `Universal.Operators.ConcatPosition` :wrench: :bar_chart: :books: + +Enforce that the concatenation operator for multi-line concatenations is in a preferred position, either always at the start of the next line or always at the end of the previous line. + +* This sniff contains an `allowOnly` property to set the preferred position for the operator. + Accepted values: (string) `"start"` or `"end"`. Defaults to `"start"`. +* Note: mid-line concatenation is still allowed and will not be flagged by this sniff. + #### `Universal.Operators.DisallowLogicalAndOr` :bar_chart: :books: Enforce the use of the boolean `&&` and `||` operators instead of the logical `and`/`or` operators. @@ -392,6 +407,10 @@ Enforce no spaces around the union type and intersection type operators. The available error codes are: `UnionTypeSpacesBefore`, `UnionTypeSpacesAfter`, `IntersectionTypeSpacesBefore`, `IntersectionTypeSpacesAfter`. +#### `Universal.PHP.LowercasePHPTag` :wrench: :bar_chart: :books: + +Enforces that the "PHP" in a PHP open tag is lowercase. + #### `Universal.PHP.OneStatementInShortEchoTag` :wrench: :books: Disallow short open echo tags `