From c16b0595828656be648de50f544ca68f3ed4fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:40:07 +0100 Subject: [PATCH 1/7] enh: Force short array syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index c6b229a..0ff0a0c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -18,6 +18,7 @@ public function getRules() : array { '@PSR2' => true, 'align_multiline_comment' => true, 'array_indentation' => true, + 'array_syntax' => true, 'binary_operator_spaces' => [ 'default' => 'single_space', ], From d9cd7a3c5bd9c79bd6773893545e51bba3b785e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:46:08 +0100 Subject: [PATCH 2/7] enh: Forbid yoda style comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index 0ff0a0c..f4cd71e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -58,6 +58,7 @@ public function getRules() : array { 'visibility_required' => [ 'elements' => ['property', 'method', 'const'] ], + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], ]; } } From 1dedda46249eccf1f6f5e006e39b8f563b441fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:50:24 +0100 Subject: [PATCH 3/7] enh: Set type as nullable when default value is null (needed for PHP 8.4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index f4cd71e..3ea8a9c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -46,6 +46,7 @@ public function getRules() : array { 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_unused_imports' => true, + 'nullable_type_declaration_for_default_null_value' => true, 'ordered_imports' => [ 'imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha' From 2fce407db243ee29842d6504a4655eb1a7850747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:57:55 +0100 Subject: [PATCH 4/7] enh: Remove namespace from class FQDN if there is a use statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index 3ea8a9c..9dfa70c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -31,6 +31,7 @@ public function getRules() : array { 'elseif' => true, 'encoding' => true, 'full_opening_tag' => true, + 'fully_qualified_strict_types' => ['leading_backslash_in_global_namespace' => true], 'function_declaration' => [ 'closure_function_spacing' => 'one', ], From 718011703879c001c2f515768d73976ade342e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:59:01 +0100 Subject: [PATCH 5/7] enh: Remove leading slash in use statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index 9dfa70c..5491264 100644 --- a/src/Config.php +++ b/src/Config.php @@ -42,6 +42,7 @@ public function getRules() : array { 'on_multiline' => 'ignore', ], 'no_closing_tag' => true, + 'no_leading_import_slash' => true, 'no_spaces_after_function_name' => true, 'no_spaces_inside_parenthesis' => true, 'no_trailing_whitespace' => true, From a60ff69f2adfd5d9872ab2c2b132e721edfcec8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 30 Jan 2024 16:59:41 +0100 Subject: [PATCH 6/7] enh: Force short syntax for list as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config.php b/src/Config.php index 5491264..058fd71 100644 --- a/src/Config.php +++ b/src/Config.php @@ -37,6 +37,7 @@ public function getRules() : array { ], 'indentation_type' => true, 'line_ending' => true, + 'list_syntax' => true, 'lowercase_keywords' => true, 'method_argument_space' => [ 'on_multiline' => 'ignore', From c178f60e5015d663201214f0e52a4cfe5e19edd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 1 Feb 2024 10:47:12 +0100 Subject: [PATCH 7/7] chore: Add missing entries to changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88758a3..6e794a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,29 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.2.0 - 2024-02-01 +### Added +- `array_syntax`: Force short syntax for array +- `list_syntax`: Same for list +- `fully_qualified_strict_types`: Remove namespace from classname when there is a `use` statement, and add missing backslash for global namespace +- `no_leading_import_slash`: Remove leading slash from `use` statement +- `nullable_type_declaration_for_default_null_value`: Add missing `?` on type declaration for parameters defaulting to `null`. This will most likely be needed to avoid warnings in PHP 8.4. +- `yoda_style`: forbid yoda style comparision. This replaces `null === $a` by `$a === null`. + +## 1.1.1 - 2023-06-23 +### Changed +* feat: use php-cs-fixer/shim by @kesselb in https://github.com/nextcloud/coding-standard/pull/13 + +## 1.1.0 - 2023-04-13 +### Changed +* Order imports alphabetically by @come-nc in https://github.com/nextcloud/coding-standard/pull/10 +* fix(rules): Replace deprecated braces rules by @nickvergessen in https://github.com/nextcloud/coding-standard/pull/12 + +## 1.0.0 – 2021-11-10 +### Breaking change +* Update php-cs-fixer to 3.x +* See https://github.com/nextcloud/coding-standard#upgrade-from-v0x-to-v10 for instructions. + ## 0.5.0 – 2021-01-11 ### Added - New rule: short list syntax