Skip to content

Commit 39f1395

Browse files
committed
Initial version
0 parents  commit 39f1395

6 files changed

Lines changed: 498 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

FigLabCodingStandard/ruleset.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="FigLabCodingStandard">
3+
<description>The FIGLAB coding standard for Laravel applications.</description>
4+
5+
<!-- Use colors in output -->
6+
<arg name="colors"/>
7+
8+
<!-- Show progress of the run -->
9+
<arg value="p"/>
10+
11+
<!-- Show sniff codes in all reports -->
12+
<arg value="s"/>
13+
14+
<!-- Wider report display -->
15+
<arg name="report-width" value="160"/>
16+
17+
<!-- Include all rules from the IxDF Coding Standard -->
18+
<rule ref="IxDFCodingStandard"/>
19+
20+
<!-- Custom rules -->
21+
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable">
22+
<exclude-pattern>*/*.blade.php</exclude-pattern>
23+
<exclude-pattern>./tests*</exclude-pattern>
24+
</rule>
25+
26+
<rule ref="Generic.Files.LineLength">
27+
<exclude-pattern>*/*.blade.php</exclude-pattern>
28+
<exclude-pattern>./config/*.php</exclude-pattern>
29+
<exclude-pattern>./database/*.php</exclude-pattern>
30+
<exclude-pattern>./lang/*.php</exclude-pattern>
31+
<exclude-pattern>./routes/*.php</exclude-pattern>
32+
<exclude-pattern>./tests/*.php</exclude-pattern>
33+
34+
<properties>
35+
<property name="lineLimit" value="160"/>
36+
<property name="absoluteLineLimit" value="200"/>
37+
<property name="ignoreComments" value="true"/>
38+
</properties>
39+
</rule>
40+
41+
<!-- We are not using static closures -->
42+
<rule ref="SlevomatCodingStandard.Functions.StaticClosure.ClosureNotStatic">
43+
<exclude-pattern>./</exclude-pattern>
44+
</rule>
45+
46+
<rule ref="IxDFCodingStandard.Laravel.NonExistingBladeTemplate">
47+
<exclude-pattern>./</exclude-pattern>
48+
</rule>
49+
50+
<!-- We are not yet ready to commit to classes to be final. -->
51+
<rule ref="SlevomatCodingStandard.Classes.RequireAbstractOrFinal.ClassNeitherAbstractNorFinal">
52+
<exclude-pattern>./</exclude-pattern>
53+
</rule>
54+
55+
<!-- Only allow in providers, used mostly in Filament providers. -->
56+
<rule ref="SlevomatCodingStandard.Functions.DisallowNamedArguments.DisallowedNamedArgument">
57+
<exclude-pattern>./bootstrap/*.php</exclude-pattern>
58+
<exclude-pattern>*/*Provider.php</exclude-pattern>
59+
</rule>
60+
61+
<!-- Only allow in providers, because boot() and register() methods are sometimes empty. -->
62+
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction">
63+
<exclude-pattern>*/*Provider.php</exclude-pattern>
64+
</rule>
65+
66+
<!-- We will allow some level of complexity in providers, because some of them come from 3rd party packages. -->
67+
<rule ref="SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh">
68+
<exclude-pattern>*/*Provider.php</exclude-pattern>
69+
</rule>
70+
</ruleset>

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 FIGLAB
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# FIGLAB Coding Standard
2+
3+
PHPCS coding-standard for Laravel applications and packages. Based on the awesome [IxDF Coding Standard](https://github.com/InteractionDesignFoundation/coding-standard/).
4+
5+
## Installation
6+
7+
1. Install the package via composer by running:
8+
```shell
9+
composer require --dev figlab/coding-standard
10+
```
11+
12+
2. Add composer scripts into your `composer.json`:
13+
```json
14+
"scripts": {
15+
"cs:check": "phpcs -p -s --colors --report-full --report-summary",
16+
"cs:fix": "phpcbf -p --colors"
17+
}
18+
```
19+
20+
3. Create file `phpcs.xml` on base path of your repository with content
21+
```xml
22+
<?xml version="1.0"?>
23+
<ruleset name="My Coding Standard">
24+
<!-- Include all rules from the IxDF Coding Standard -->
25+
<rule ref="FigLabCodingStandard"/>
26+
27+
<!-- Paths to check -->
28+
<file>app</file>
29+
<file>config</file>
30+
<file>database</file>
31+
<file>lang</file>
32+
<file>routes</file>
33+
<file>tests</file>
34+
</ruleset>
35+
```
36+
37+
## Usage
38+
39+
- To run checks only:
40+
41+
```shell
42+
composer cs:check
43+
```
44+
45+
- To automatically fix CS issues:
46+
47+
```shell
48+
composer cs:fix
49+
```

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "figlab/coding-standard",
3+
"description": "PHPCS coding-standard for Laravel applications.",
4+
"license": "MIT",
5+
"type": "phpcodesniffer-standard",
6+
"require": {
7+
"php": "^8.2",
8+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
9+
"slevomat/coding-standard": "^8.14",
10+
"squizlabs/php_codesniffer": "^3.9",
11+
"interaction-design-foundation/coding-standard": "^0.2.3"
12+
},
13+
"autoload": {
14+
"psr-4": {
15+
"FigLabCodingStandard\\": "FigLabCodingStandard"
16+
}
17+
},
18+
"minimum-stability": "dev",
19+
"prefer-stable": true,
20+
"config": {
21+
"allow-plugins": {
22+
"dealerdirect/phpcodesniffer-composer-installer": true
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)