From 9686e9a4aee539401f97f1caed502adc1fc18924 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Wed, 28 Feb 2018 06:06:56 -0300 Subject: [PATCH 1/4] Add superfluous suffixes sniffes --- composer.json | 2 +- lib/Doctrine/ruleset.xml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bfd0eb83..9f3123d4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "php": "^7.1", "squizlabs/php_codesniffer": "^3.2", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.2", - "slevomat/coding-standard": "^4.4.0" + "slevomat/coding-standard": "dev-master" }, "extra": { "branch-alias": { diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index 6f6226d5..c2863c0b 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -93,6 +93,12 @@ + + + + + + From 82abd7d8c23d5d2f67f62bae60ee2c1dc4f5e274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 25 Feb 2018 22:29:40 +0100 Subject: [PATCH 2/4] Add rules about exception types naming You always know an exception is an exception when catching it or throwing it, so the Exception suffix is useless, but hard to avoid when you need to group exceptions together, which is why it should be present in abstract exception names. See http://mnapoli.fr/approaching-coding-style-rationally/#the-exception-suffix --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef5b8e6c..b94943ed 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ exceptions/differences/extensions (:white_check_mark: are the implemented sniffs - Keep the nesting of control structures per method as small as possible - Prefer early exit over nesting conditions or using else +- :white_check_mark: Concrete exception class names should not be suffixed with `Exception` +- :white_check_mark: Abstract exception class names and exception interface names should be suffixed with `Exception` - :white_check_mark: Align equals (`=`) signs in assignments - :white_check_mark: Add spaces around a concatenation operator `$foo = 'Hello ' . 'World!';` - :white_check_mark: Add spaces between assignment, control and return statements From 92ccb8a833c79b14b7739ae224ad50bddac4eaee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 28 Feb 2018 19:37:42 +0100 Subject: [PATCH 3/4] Document forbidden suffixes and prefixes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b94943ed..e036a85f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ exceptions/differences/extensions (:white_check_mark: are the implemented sniffs - Keep the nesting of control structures per method as small as possible - Prefer early exit over nesting conditions or using else +- :white_check_mark: Abstract classes should not be prefixed with `Abstract` +- :white_check_mark: Interfaces should not be suffixed with `Interface` - :white_check_mark: Concrete exception class names should not be suffixed with `Exception` - :white_check_mark: Abstract exception class names and exception interface names should be suffixed with `Exception` - :white_check_mark: Align equals (`=`) signs in assignments From 9af0a8c077fe5da839f2bdd50ba2faadda1b144c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 2 Mar 2018 17:31:28 +0100 Subject: [PATCH 4/4] Require ^4.5.0 We need the new sniffs. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f3123d4..9118064f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "php": "^7.1", "squizlabs/php_codesniffer": "^3.2", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.2", - "slevomat/coding-standard": "dev-master" + "slevomat/coding-standard": "^4.5.0" }, "extra": { "branch-alias": {