Skip to content

Commit 88edfbc

Browse files
committed
New custom rules added from external sources
1 parent 018c6f9 commit 88edfbc

File tree

4 files changed

+243
-3
lines changed

4 files changed

+243
-3
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to `laravel-phpcs` will be documented in this file
44

5+
## 1.6.0 - 2022-05-20
6+
7+
- [Custom sniffs](https://github.com/slevomat/coding-standard) have been added to improve the Laravel standard.
8+
- Added `SlevomatCodingStandard.Namespaces.UnusedUses` to avoid unused uses.
9+
- Added `SlevomatCodingStandard.Namespaces.UseFromSameNamespace` to avoid uses from same namespace.
10+
- Added `SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses` for the imports to be sorted alphabetically.
11+
- Added `SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation` to enforces fully qualified names of classes and interfaces in phpDocs.
12+
- Added `SlevomatCodingStandard.PHP.UselessSemicolon` to avoid useless semicolons.
13+
- Added `SlevomatCodingStandard.Classes.MethodSpacing` to check that there is a blank line between the methods.
14+
- Added `SlevomatCodingStandard.Functions.ArrowFunctionDeclaration` to check that the number of spaces after and before the arrow is correct.
15+
- Added `SlevomatCodingStandard.Files.TypeNameMatchesFileName` to check that the type name matches the file name.
16+
517
## 1.5.0 - 2022-04-05
618

719
- Added `Generic.NamingConventions.CamelCapsFunctionName` to avoid function names with `snake_case`

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"phpcs",
88
"php",
99
"coding-style",
10+
"coding sniffer",
1011
"coding-standard"
1112
],
1213
"homepage": "https://github.com/mreduar/laravel-phpcs",
@@ -21,6 +22,7 @@
2122
],
2223
"require": {
2324
"php": "^7.4|^8.0",
25+
"slevomat/coding-standard": "^7.2",
2426
"squizlabs/php_codesniffer": "^3.6"
2527
},
2628
"autoload": {
@@ -29,7 +31,10 @@
2931
}
3032
},
3133
"config": {
32-
"sort-packages": true
34+
"sort-packages": true,
35+
"allow-plugins": {
36+
"dealerdirect/phpcodesniffer-composer-installer": true
37+
}
3338
},
3439
"extra": {
3540
"laravel": {

composer.lock

Lines changed: 181 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Laravel Standards">
2+
<ruleset name="Laravel Standards" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
33
<description>PHP Codesniffer ruleset to follow Laravel's coding style</description>
44
<rule ref="Generic.Classes.DuplicateClassName">
55
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedIf"/>
@@ -137,6 +137,49 @@
137137
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
138138
<rule ref="Zend.Files.ClosingTag"/>
139139

140+
<!-- Custom Sniffs -->
141+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
142+
<properties>
143+
<property name="searchAnnotations" value="true"/>
144+
</properties>
145+
</rule>
146+
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
147+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
148+
<properties>
149+
<property name="caseSensitive" value="true"/>
150+
</properties>
151+
</rule>
152+
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
153+
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
154+
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing">
155+
<properties>
156+
<property name="minLinesCount" value="1"/>
157+
<property name="maxLinesCount" value="1"/>
158+
</properties>
159+
</rule>
160+
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
161+
<properties>
162+
<property name="spacesCountAfterKeyword" value="1"/>
163+
<property name="spacesCountBeforeArrow" value="1"/>
164+
<property name="spacesCountAfterArrow" value="1"/>
165+
<property name="allowMultiLine" value="true"/>
166+
</properties>
167+
</rule>
168+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
169+
<properties>
170+
<property name="rootNamespaces" type="array">
171+
<element key="app" value="App"/>
172+
<element key="database/factories" value="Database\Factories"/>
173+
<element key="database/seeders" value="Database\Seeders"/>
174+
<element key="tests" value="Tests"/>
175+
</property>
176+
</properties>
177+
</rule>
178+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
179+
<exclude-pattern>/database/schema/*</exclude-pattern>
180+
<exclude-pattern>/database/migrations/*</exclude-pattern>
181+
</rule>
182+
140183
<!-- <file>app</file>
141184
<file>config</file>
142185
<file>public</file>

0 commit comments

Comments
 (0)