├── .gitignore
├── LICENSE
├── README.md
├── composer.json
├── composer.lock
├── docs
└── CONTRIBUTING.md
└── phpcs.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor/
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 PatricNox (https://github.com/patricnox)
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PHP CodeSniffer rules for Laravel coding style (PSR-2 variant)
2 |
3 | [](LICENSE.md)
4 | [](/compare)
5 | 
6 |
7 | > Authored by fossbarrow IO
8 |
9 |
10 | [php codesniffer ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset) for laravel projects.
11 |
12 | ## Requirements
13 |
14 | - https://github.com/squizlabs/PHP_CodeSniffer
15 |
16 | ## Table of contents
17 |
18 | - [How to install](#install)
19 | - [Enabling the rules](#enabling-the-rules)
20 | - [Sniffing code](#sniffing-code)
21 | - [Sniffing code in PHPStorm](#sniffing-code-in-phpstorm)
22 | - [License](#license)
23 | - [Contributing](#contributing)
24 | - [Credits](#credits)
25 |
26 | ## Installation
27 | Install the ruleset by
28 |
29 | 1. Copy the `phpcs.xml` file into your project root with phpcs installed.
30 |
31 | ## Usage
32 |
33 | ### Enabling the rules
34 |
35 | > Only neccesary if you installed as a package using composer!
36 |
37 | Add it to your project `phpcs.xml` or `phpcs.xml.dist` ruleset:
38 |
39 | ```xml
40 |
41 |
42 |
43 |
44 | ./app
45 | ./config
46 | ./resources
47 | ./routes
48 | ./tests
49 |
50 |
51 |
52 | ```
53 |
54 | ### Sniffing code
55 | Use php CodeSniffer commands, pointed towards your xml file, to sniff the code
56 | using the new ruleset.
57 |
58 | > vendor/bin/phpcs
59 | > vendor/bin/phpcbf
60 |
61 | #### Sniffing code in PHPStorm
62 |
63 | See [PHP Code Sniffer in PhpStorm](https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm) on how to set up CodeSniffer in PHPStorm.
64 |
65 | --------------------------------------------------------------------------------
66 |
67 |
68 | ## Contributing
69 |
70 | All changes that makes the sniffer more accurate towards _Laravel_'s coding standard
71 | is always highly appreciated and welcome.
72 |
73 | Please see [CONTRIBUTING](docs/CONTRIBUTING.md) for more details.
74 |
75 | ## Credits
76 |
77 | - [PatricNox](https://github.com/PatricNox)
78 | - [All Contributors](../../contributors)
79 |
80 | ## License
81 |
82 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
83 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fossbarrow/laravel-phpcs",
3 | "description": "phpcs ruleset for laravel projects",
4 | "type": "phpcs-ruleset",
5 | "require-dev": {
6 | "php": "^7.4",
7 | "squizlabs/php_codesniffer": "^3.5.5"
8 | },
9 | "license": "MIT",
10 | "authors": [
11 | {
12 | "name": "patricnox",
13 | "email": "hello@patricnox.info"
14 | }
15 | ],
16 | "minimum-stability": "stable"
17 | }
18 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "393187ab75a2f2a2c0040505c4f87e26",
8 | "packages": [],
9 | "packages-dev": [
10 | {
11 | "name": "squizlabs/php_codesniffer",
12 | "version": "3.6.0",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
16 | "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
21 | "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "ext-simplexml": "*",
26 | "ext-tokenizer": "*",
27 | "ext-xmlwriter": "*",
28 | "php": ">=5.4.0"
29 | },
30 | "require-dev": {
31 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
32 | },
33 | "bin": [
34 | "bin/phpcs",
35 | "bin/phpcbf"
36 | ],
37 | "type": "library",
38 | "extra": {
39 | "branch-alias": {
40 | "dev-master": "3.x-dev"
41 | }
42 | },
43 | "notification-url": "https://packagist.org/downloads/",
44 | "license": [
45 | "BSD-3-Clause"
46 | ],
47 | "authors": [
48 | {
49 | "name": "Greg Sherwood",
50 | "role": "lead"
51 | }
52 | ],
53 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
54 | "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
55 | "keywords": [
56 | "phpcs",
57 | "standards"
58 | ],
59 | "support": {
60 | "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
61 | "source": "https://github.com/squizlabs/PHP_CodeSniffer",
62 | "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
63 | },
64 | "time": "2021-04-09T00:54:41+00:00"
65 | }
66 | ],
67 | "aliases": [],
68 | "minimum-stability": "stable",
69 | "stability-flags": [],
70 | "prefer-stable": false,
71 | "prefer-lowest": false,
72 | "platform": [],
73 | "platform-dev": {
74 | "php": "^7.4"
75 | },
76 | "plugin-api-version": "2.0.0"
77 | }
78 |
--------------------------------------------------------------------------------
/docs/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # CONTRIBUTING
2 |
3 | All changes that makes the sniffer more accurate towards _Laravel_'s coding standard
4 | is always highly appreciated and welcome.
5 |
6 | ## WHAT IS LARAVEL'S CODING STANDARD?
7 |
8 | Laravel is using their own variant of modified PSR-12. To dig deeper, look at Laravel source code and try to make rules that covers their standard.
9 |
10 | ## PULL-REQUESTS
11 |
12 | Merged pull-requests will be squashed, meaning you don't have to bother writing
13 | proper commit messages.
14 |
15 | ## CRITERIA
16 |
17 | Please do **always** include some kind of proof that supports your change to the
18 | ruleset.
19 |
--------------------------------------------------------------------------------
/phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | PSR-2 The Laravel conventions
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | /app/Http/Resources/*\.php
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | *.php
70 |
71 |
72 | database/*
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | app
123 | config
124 | public
125 | resources
126 | routes
127 | tests
128 |
129 | */.phpstorm.meta.php
130 | */_ide_helper.php
131 | */database/*
132 | */cache/*
133 | */*.js
134 | */*.css
135 | */*.xml
136 | */*.blade.php
137 | */autoload.php
138 | */storage/*
139 | */docs/*
140 | */vendor/*
141 | */migrations/*
142 | */config/*
143 | */public/index.php
144 | */*.blade.php
145 | */Console/Kernel.php
146 | */Exceptions/Handler.php
147 | */Http/Kernel.php
148 | */Providers/*
149 | */resources/lang/*
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------