Initial commit & release

master 1.0.0
Gertjan Krol 2022-08-20 00:50:26 +02:00
commit 5e99f1f313
20 changed files with 2254 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/.idea/
/vendor/
composer.lock
*cache*
*.log
*.tmp

31
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,31 @@
stages:
- prepare
- test
prepare:composer-install:
stage: prepare
tags:
- prepare
image: composer:2.4
script:
- echo "Start composer install"
- composer install --no-scripts --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader
artifacts:
expire_in: 1h
paths:
- composer.lock
- vendor/
interruptible: true
test:composer-security-check:
stage: test
tags:
- test
needs:
- job: prepare:composer-install
artifacts: true
image: composer:2.4
script:
- echo "Start package security check"
- composer security-checker
interruptible: true

7
CHANGELOG.md Normal file
View File

@ -0,0 +1,7 @@
# Changelog
All notable changes to this package will be documented in this file
## Unreleased
## 1.0.0 - 2022-08-20
- Initial release [major]

53
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,53 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Requirements
- **Follow the [Crawl Coding Standard](https://git.gertjankrol.nl/crawl/coding-standard)** - Basically run `composer style` before committing/pushing.
- **Add tests!**
- **Document any change in behaviour** - Make sure the `CHANGELOG.md`, `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) Author
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

55
README.md Normal file
View File

@ -0,0 +1,55 @@
# crawl/coding-standard
[![Latest Version on Packagist](https://img.shields.io/packagist/v/crawl/coding-standard.svg?style=flat-square)](https://packagist.org/packages/crawl/coding-standard)
[![Total Downloads](https://img.shields.io/packagist/dt/crawl/coding-standard.svg?style=flat-square)](https://packagist.org/packages/crawl/coding-standard)
This package provides rule sets for the Crawl Coding Standard.\
It requires `squizlabs/php_codesniffer` and some extensions (see [composer.json](composer.json)).
## Installation
You can install the package via composer (you should only need it for development):
```bash
composer require crawl/coding-standard --dev
```
## Usage
Depending on your project, copy `phpcs-laravel.xml` or `phpcs-package.xml` from `config/` to your project.\
**Note:** don't forget to update `Package\Namespace` when using `phpcs-package.xml`.
You can then run PHP Code Sniffer/Beautifier:
```bash
$ vendor/bin/phpcs --standard=./path/to/copied/phpcs.xml
$ vendor/bin/phpcbf --standard=./path/to/copied/phpcs.xml
```
For easier usage, add the following to `scripts` in your project's `composer.json`:
```json
...
"scripts": {
"style": "vendor/bin/phpcs --standard=./path/to/copied/phpcs.xml",
"fix-style": "vendor/bin/phpcbf --standard=./path/to/copied/phpcs.xml",
}.
...
```
You can then use `composer style` to run the sniffer, and `composer fix-style` to run the beautifier.
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email security@gkcld.net instead of using the issue tracker.
## Authors
- [Gertjan Krol](https://git.gertjankrol.nl/gertjan)
## License
The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

39
composer.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "crawl/coding-standard",
"description": "The Crawl Coding Standard",
"keywords": [
"crawl",
"coding standard",
"code sniffer",
"code quality"
],
"homepage": "https://git.gertjankrol.nl/crawl/coding-standard",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Gertjan Krol",
"email": "hello@gertjankrol.nl"
}
],
"require": {
"php": "^8.1",
"phpcompatibility/php-compatibility": "^9.3",
"sirbrillig/phpcs-variable-analysis": "^2.11",
"slevomat/coding-standard": "^7.2",
"squizlabs/php_codesniffer": "^3.7"
},
"require-dev": {
"enlightn/security-checker": "^1.10"
},
"scripts": {
"security-checker": "vendor/bin/security-checker security:check composer.lock"
},
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

28
config/phpcs-laravel.xml Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-L-1">
<description>Crawl Coding Standard for Laravel projects</description>
<rule ref="vendor/crawl/coding-standard/src/rulesets/phpcs-laravel.xml"/>
<rule ref="vendor/crawl/coding-standard/src/rulesets/extras/laravel-exclusions.xml"/>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="app" value="App"/>
<element key="tests" value="Tests"/>
<element key="database" value="Database"/>
<element key="database/seeds" value="Database\Seeds"/>
</property>
</properties>
</rule>
<file>app</file>
<file>bootstrap</file>
<file>config</file>
<file>database</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>
<exclude-pattern>bootstrap/cache</exclude-pattern>
</ruleset>

21
config/phpcs-package.xml Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-P-1">
<description>Crawl Coding Standard for Packages</description>
<rule ref="vendor/crawl/coding-standard/src/rulesets/phpcs.xml"/>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Package\Namespace"/>
<element key="tests" value="Package\Namespace\Tests"/>
</property>
</properties>
</rule>
<file>config</file>
<file>database</file>
<file>resources</file>
<file>src</file>
<file>tests</file>
</ruleset>

View File

@ -0,0 +1,531 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-GCS-1">
<description>extension of Generic Coding Standard</description>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/Generic -->
<!--
|=============================================================================
|=============================================================================
Arrays
|=============================================================================
|=============================================================================
-->
<!-- Indention check of 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Prefer [] over array() syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Bans the use of the PHP short array syntax -->
<!-- Disabled since we want the short syntax -->
<!--<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>-->
<!--
|=============================================================================
|=============================================================================
Classes
|=============================================================================
|=============================================================================
-->
<!-- Reports errors if the same class or interface name is used in multiple files -->
<!-- Disabled since there are namespaces to differentiate the classes -->
<!--<rule ref="Generic.Classes.DuplicateClassName"/>-->
<!-- Checks that the opening brace of a class/interface/trait is on the same line as the class declaration -->
<!-- Disabled since it conflicts with PSR12 -->
<!--<rule ref="Generic.Classes.OpeningBraceSameLine"/>-->
<!--
|=============================================================================
|=============================================================================
Code Analysis
|=============================================================================
|=============================================================================
-->
<!-- Don't allow `if($x = something()){}` -->
<!-- Disabled since it's covered by SlevomatCodingStandard.ControlStructures.AssignmentInCondition -->
<!--<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>-->
<!-- Yoda conditions decrease code comprehensibility and readability -->
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
<!-- Warns when it finds empty PHP open/close tag combinations or superfluous semicolons -->
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<!-- Check whether a control structure contains an empty body -->
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<!-- Detects for-loops that can be simplified to a while-loop. -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<!-- Detects for-loops that use a function call in the test expression -->
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<!-- Detects incrementer jumbling in for loops -->
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<!-- Detects unconditional if- and elseif-statements -->
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<!-- Detects unconditional if- and elseif-statements -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Checks for unused function parameters -->
<!-- Disabled since we allow unused function parameters -->
<!--<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>-->
<!-- Detects unnecessary overridden methods that simply call their parent -->
<!-- Disabled since the constructor is often overruled to define custom arguments via DI -->
<!--<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>-->
<!--
|=============================================================================
|=============================================================================
Commenting
|=============================================================================
|=============================================================================
-->
<!-- Ensures doc blocks follow basic formatting -->
<!-- Disabled since this is actually unusable -->
<!--<rule ref="Generic.Commenting.DocComment"/>-->
<rule ref="Generic.Commenting.Fixme"/>
<!--
|=============================================================================
|=============================================================================
Control Structures
|=============================================================================
|=============================================================================
-->
<!-- The body of each structure MUST be enclosed by braces -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.ControlStructures.InlineControlStructure"/>-->
<!--
|=============================================================================
|=============================================================================
Debug
|=============================================================================
|=============================================================================
-->
<!-- Runs gjslint on the file -->
<!-- Disabled since have a separate process for js linting -->
<!--<rule ref="Generic.Debug.ClosureLinter"/>-->
<!-- Runs csslint on the file -->
<!-- Disabled since have a separate process for css linting -->
<!--<rule ref="Generic.Debug.CSSLint"/>-->
<!-- Runs eslint on the file -->
<!-- Disabled since have a separate process for js linting -->
<!--<rule ref="Generic.Debug.ESLint"/>-->
<!-- Runs jshint on the file -->
<!-- Disabled since have a separate process for js linting -->
<!--<rule ref="Generic.Debug.ESHint"/>-->
<!--
|=============================================================================
|=============================================================================
Files
|=============================================================================
|=============================================================================
-->
<!-- Enabled by PSR-1 -->
<!--<rule ref="Generic.Files.ByteOrderMark"/>-->
<!-- Ensures the file ends with a newline character. -->
<rule ref="Generic.Files.EndFileNewline"/>
<!-- Ensures the file does not end with a newline character -->
<!-- Disabled since we want a newline at EOF -->
<!--<rule ref="Generic.Files.EndFileNoNewline"/>-->
<!-- Ensures the whole file is PHP only, with no whitespace or inline HTML -->
<rule ref="Generic.Files.InlineHTML"/>
<!-- Checks that end of line characters are correct -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.Files.LineEndings"/>-->
<!-- Checks the length of all lines in a file -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.Files.LineLength"/>-->
<!-- Checks that all file names are lowercased -->
<!-- Disabled since upper cases are okay in filenames -->
<!--<rule ref="Generic.Files.LowercasedFilename"/>-->
<!-- Only allow one object structure per file -->
<rule ref="Generic.Files.OneObjectStructurePerFile"/>
<rule ref="Generic.Files.OneClassPerFile"/>
<rule ref="Generic.Files.OneInterfacePerFile"/>
<rule ref="Generic.Files.OneTraitPerFile"/>
<!--
|=============================================================================
|=============================================================================
Formatting
|=============================================================================
|=============================================================================
-->
<!-- Ensures each statement is on a line by itself -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.Formatting.DisallowMultipleStatements"/>-->
<!-- Checks alignment of assignments -->
<!-- Disabled since we're not interested in aligned assignments -->
<!--<rule ref="Generic.Formatting.MultipleStatementAlignment"/>-->
<!-- Ensures there is no space after cast tokens -->
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<!-- Ensures a specific amount of spaces between the cast and the variable it applies to -->
<!-- Disabled since it's covered by Generic.Formatting.NoSpaceAfterCast -->
<!--<rule ref="Generic.Formatting.SpaceAfterCast"/>-->
<!-- Ensures there is no space between the ! operator and the variable it applies to -->
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="false"/>
</properties>
</rule>
<!-- Ensures there is exactly 1 space before a type cast, unless the cast statement is indented or multi-line -->
<!-- Disabled since we don't want this -->
<!--<rule ref="Generic.Formatting.SpaceBeforeCast"/>-->
<!--
|=============================================================================
|=============================================================================
Functions
|=============================================================================
|=============================================================================
-->
<!-- Ensures that variables are not passed by reference when calling a function -->
<rule ref="Generic.Functions.CallTimePassByReference"/>
<!-- Checks that calls to methods and functions are spaced correctly -->
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<!-- Braces should be newlined for functions, but not for closures -->
<!-- Disabled since PSR-2 contains custom ruleset for this rule -->
<!--<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman" />-->
<!-- Braces should not be on newline -->
<!-- Not enabled since we're interested in PSR-2s version of OpeningFunctionBraceBsdAllman -->
<!--<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />-->
<!--
|=============================================================================
|=============================================================================
Metrics
|=============================================================================
|=============================================================================
-->
<!-- Check the cyclomatic complexity for functions by counting the different paths the function includes -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="14"/>
<property name="absoluteComplexity" value="18"/>
</properties>
</rule>
<!--Check how many level deep the code is nested within a function (warning on 8, error on 12)-->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="5"/>
<property name="absoluteNestingLevel" value="5"/>
</properties>
</rule>
<!--
|=============================================================================
|=============================================================================
Naming Conventions
|=============================================================================
|=============================================================================
-->
<!-- Functions should be camelcased -->
<!-- Disabled since it's covered by PSR1.Methods.CamelCapsMethodName -->
<!--
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
<properties>
<property name="strict" value="true"/>
</properties>
</rule>
-->
<!-- Bans PHP 4 style constructors -->
<!-- Disabled since certain classes legitimately contain methods with the name of the class -->
<!--<rule ref="Generic.NamingConventions.ConstructorName"/>-->
<!-- Ensures that constant names are all uppercase -->
<!-- Enabled by PSR-1 -->
<!--<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>-->
<!--
|=============================================================================
|=============================================================================
PHP
|=============================================================================
|=============================================================================
-->
<!-- Bans the use of the backtick execution operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Checks that the opening PHP tag is the first content in a file -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Discourages the use of deprecated PHP functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Verifies that no alternative PHP tags are used -->
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<!-- Ban the use of the $_REQUEST superglobal -->
<rule ref="Generic.PHP.DisallowRequestSuperglobal"/>
<!-- Makes sure that shorthand PHP open tags are not used -->
<!-- Enabled by PSR-1 -->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<!-- Discourage the use of the PHP `goto` language construct -->
<rule ref="Generic.PHP.DiscourageGoto"/>
<!-- Disable some functions or referrer to preferred aliases if available -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="array_add" value="Arr::add"/>
<element key="array_collapse" value="Arr::collapse"/>
<element key="array_divide" value="Arr::divide"/>
<element key="array_dot" value="Arr::dot"/>
<element key="array_except" value="Arr::except"/>
<element key="array_first" value="Arr::first"/>
<element key="array_flatten" value="Arr::flatten"/>
<element key="array_forget" value="Arr::forget"/>
<element key="array_get" value="Arr::get"/>
<element key="array_has" value="Arr::has"/>
<element key="array_last" value="Arr::last"/>
<element key="array_only" value="Arr::only"/>
<element key="array_pluck" value="Arr::pluck"/>
<element key="array_prepend" value="Arr::prepend"/>
<element key="array_pull" value="Arr::pull"/>
<element key="array_random" value="Arr::random"/>
<element key="array_set" value="Arr::set"/>
<element key="array_sort" value="Arr::sort"/>
<element key="array_sort_recursive" value="Arr::sortRecursive"/>
<element key="array_where" value="Arr::where"/>
<element key="array_wrap" value="Arr::wrap"/>
<element key="camel_case" value="Str::camel"/>
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="collect" value="new Collection"/>
<element key="compact" value="null"/>
<element key="create_function" value="null"/>
<element key="dd" value="null"/>
<element key="delete" value="unset"/>
<element key="die" value="null"/>
<element key="doubleval" value="floatval"/>
<element key="dump" value="null"/>
<element key="empty" value="strlen() or count"/> <!-- Disallow `empty` calls due to it's unpredictable behavior -->
<element key="ends_with" value="Str::endsWith"/>
<element key="eval" value="null"/>
<element key="extract" value="null"/>
<element key="floatval" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="intval" value="null"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="kebab_case" value="Str::kebab"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pcntl_alarm" value="null"/>
<element key="pcntl_exec" value="null"/>
<element key="pcntl_exec" value="null"/>
<element key="pcntl_fork" value="null"/>
<element key="pcntl_fork" value="null"/>
<element key="pcntl_get_last_error" value="null"/>
<element key="pcntl_get_last_error" value="null"/>
<element key="pcntl_getpriority" value="null"/>
<element key="pcntl_getpriority" value="null"/>
<element key="pcntl_setpriority" value="null"/>
<element key="pcntl_setpriority" value="null"/>
<element key="pcntl_signal" value="null"/>
<element key="pcntl_signal" value="null"/>
<element key="pcntl_signal_dispatch" value="null"/>
<element key="pcntl_signal_dispatch" value="null"/>
<element key="pcntl_sigprocmask" value="null"/>
<element key="pcntl_sigprocmask" value="null"/>
<element key="pcntl_sigtimedwait" value="null"/>
<element key="pcntl_sigtimedwait" value="null"/>
<element key="pcntl_sigwaitinfo" value="null"/>
<element key="pcntl_sigwaitinfo" value="null"/>
<element key="pcntl_strerror" value="null"/>
<element key="pcntl_strerror" value="null"/>
<element key="pcntl_wait" value="null"/>
<element key="pcntl_wait" value="null"/>
<element key="pcntl_waitpid" value="null"/>
<element key="pcntl_waitpid" value="null"/>
<element key="pcntl_wexitstatus" value="null"/>
<element key="pcntl_wexitstatus" value="null"/>
<element key="pcntl_wifexited" value="null"/>
<element key="pcntl_wifexited" value="null"/>
<element key="pcntl_wifsignaled" value="null"/>
<element key="pcntl_wifsignaled" value="null"/>
<element key="pcntl_wifstopped" value="null"/>
<element key="pcntl_wifstopped" value="null"/>
<element key="pcntl_wstopsig" value="null"/>
<element key="pcntl_wstopsig" value="null"/>
<element key="pcntl_wtermsig" value="null"/>
<element key="pcntl_wtermsig" value="null"/>
<element key="pos" value="current"/>
<element key="print" value="echo"/>
<element key="redirect" value="$this->redirector->..."/>
<element key="request" value="$this->request->..."/>
<element key="response" value="$this->responseFactory->..."/>
<element key="settype" value="null"/>
<element key="shell_exec" value="exec"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="snake_case" value="Str::snake"/>
<element key="starts_with" value="Str::startsWith"/>
<element key="str_after" value="Str::after"/>
<element key="str_before" value="Str::before"/>
<element key="str_finish" value="Str::finish"/>
<element key="str_limit" value="Str::limit"/>
<element key="str_plural" value="Str::plural"/>
<element key="str_random" value="Str::random"/>
<element key="str_replace_array" value="Str::replaceArray"/>
<element key="str_replace_first" value="Str::replaceFirst"/>
<element key="str_replace_last" value="Str::replaceLast"/>
<element key="str_singular" value="Str::singular"/>
<element key="str_slug" value="Str::slug"/>
<element key="str_start" value="Str::start"/>
<element key="strchr" value="strstr"/>
<element key="studly_case" value="Str::studly"/>
<element key="title_case" value="Str::title"/>
<element key="var_dump" value="null"/>
</property>
</properties>
</rule>
<!-- All PHP reserved keywords and types [1][2] MUST be in lower case -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.PHP.LowerCaseKeyword"/>-->
<!--<rule ref="Generic.PHP.LowerCaseConstant"/>-->
<!--<rule ref="Generic.PHP.LowerCaseType"/>-->
<!-- Rules transforms errors to warnings. We don't want that -->
<rule ref="Generic.PHP.NoSilencedErrors">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Enforce declare strict types -->
<rule ref="Generic.PHP.RequireStrictTypes"/>
<!-- Ensures the PHP_SAPI constant is used instead of php_sapi_name() -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Ensures PHP believes the syntax is clean -->
<!-- Disabled since it's covered by `test:php-linting` job. This one is also extremely slow -->
<!-- <rule ref="Generic.PHP.Syntax"/> -->
<!-- Checks that all uses of TRUE, FALSE and NULL are uppercase -->
<!-- Disabled since we want them lower case -->
<!--<rule ref="Generic.PHP.UpperCaseConstant"/>-->
<!--
|=============================================================================
|=============================================================================
Strings
|=============================================================================
|=============================================================================
-->
<!-- Check whether two strings using the same quoting style are not concatenated -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="false"/>
<property name="error" value="true"/>
</properties>
</rule>
<!--
|=============================================================================
|=============================================================================
Version Control
|=============================================================================
|=============================================================================
-->
<!-- Detects merge conflict artifacts left in files -->
<rule ref="Generic.VersionControl.GitMergeConflict"/>
<!-- Tests that the correct Subversion properties are set -->
<!-- Disabled since we use git -->
<!--<rule ref="Generic.VersionControl.SubversionProperties"/>-->
<!--
|=============================================================================
|=============================================================================
Whitespace
|=============================================================================
|=============================================================================
-->
<!-- Check whether parenthesis contain unnecessary spaces -->
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="false"/>
</properties>
</rule>
<!-- Throws errors if spaces are used for indentation other than precision indentation -->
<!-- Disabled since we want spaces -->
<!--<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>-->
<!-- Throws errors if tabs are used for indentation -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>-->
<!-- Ensures there is no space between the operator and the variable it applies to -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Ensures all language constructs contain a single space between themselves and their content -->
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
<!-- Checks that control structures are defined and indented correctly -->
<!-- Enabled by PSR-12 -->
<!--<rule ref="Generic.WhiteSpace.ScopeIndent"/>-->
<!-- Checks whitespace between the spread operator and the variable/function call it applies to -->
<rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/>
</ruleset>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-LM-1">
<!-- Language strings are allowed to cross line length limit -->
<!-- Configs are allowed to cross line length limit -->
<rule ref="SlevomatCodingStandard.Files.LineLength.LineTooLong">
<exclude-pattern>*/resources/lang/*</exclude-pattern>
<exclude-pattern>config/</exclude-pattern>
</rule>
<!-- Migrations don't need namespace -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>database/</exclude-pattern>
</rule>
<!-- Migrations don't need to contain valid classnames-->
<rule ref="Squiz.Classes.ClassFileName">
<exclude-pattern>database/migrations/*</exclude-pattern>
<exclude-pattern>database/seeders/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<exclude-pattern>database/migrations/*</exclude-pattern>
<exclude-pattern>database/seeders/*</exclude-pattern>
</rule>
<!-- Blade files are not really php files -->
<exclude-pattern>*/*.blade.php$</exclude-pattern>
<exclude-pattern type="relative">^vendor/*</exclude-pattern>
<exclude-pattern type="relative">^\.git/*</exclude-pattern>
</ruleset>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-SCS-1">
<description>extension of Squiz Coding Standard</description>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/PEAR/Sniffs -->
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
</ruleset>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-PCS-1">
<description>extension for Phased Coding Standard</description>
<!-- Checks the naming and casing/camelcase/studlycase of variables and member variables -->
<!-- Disabled since called properties are also checked: $this->some_legitimate_camelcase_var -->
<!-- See: https://github.com/squizlabs/PHP_CodeSniffer/issues/1773-->
<!-- <rule ref="Squiz.NamingConventions.ValidVariableName">
Underscore prefixed variables are not preferred
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
We legitimately have snaked case properties due to mysql column naming convention
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
</rule>
-->
<!-- Some functions have $strict parameter. This sniff reports calls to these functions without the parameter or with $strict = false. -->
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="app" value="App::make"/>
</property>
</properties>
</rule>
</ruleset>

View File

@ -0,0 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-PCS-1">
<description>extension of PSR Coding Standard</description>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/PSR1 -->
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/PSR2 -->
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/PSR12 -->
<!--
Include all sniffs in the PSR2 standard. Note that the
path to the standard does not have to be specified as the
PSR2 standard exists inside the PHP_CodeSniffer install
directory.
-->
<rule ref="PSR12"/>
<!--
|=============================================================================
|=============================================================================
Rules not covered by PSR-2
|=============================================================================
|=============================================================================
-->
<!--
|=============================================================================
|=============================================================================
Rules covered by PSR-2
|=============================================================================
Enabled here due to custom property values
|=============================================================================
|=============================================================================
-->
<!-- Warn and error on lines longer than 120 chars. This includes comments. Default 120:0 -->
<!-- Disabled since it's covered by the more comprehensive SlevomatCodingStandard.Files.LineLength -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
<exclude name="Generic.Files.LineLength.MaxExceeded"/>
<exclude name="Generic.Files.LineLength.TooLong"/>
</rule>
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement">
<properties>
<property name="allowOnly" value="first"/>
</properties>
</rule>
<!--
|=============================================================================
|=============================================================================
Rules covered by PSR-2/PSR-1
|=============================================================================
Not enabled due to the usage of the default property values
|=============================================================================
|=============================================================================
-->
<!--
Run "vendor/bin/phpcs \-\-standard=PSR2 -e" to see default enabled rules
The PSR2 standard contains 42 sniffs
Generic
===================
Generic.ControlStructures.InlineControlStructure
Inline control structures are not allowed, give error if found
Example not allowed:
if($foo) bar();
if($foo) foreach($foo as $bar) {
zap($bar);
}
Generic.Files.ByteOrderMark
Disallow BOM character
Generic.Files.LineEndings
Ensure "\n" at end of file
Generic.Files.LineLength
Custom linelength settings above
Generic.Formatting.DisallowMultipleStatements
Disallow multiple statements on the same line
Generic.Functions.FunctionCallArgumentSpacing
Restrict whitespace in function calls
Generic.NamingConventions.UpperCaseConstantName
Constants must be uppercase
Generic.PHP.DisallowShortOpenTag
Disallow usage of <? as php opening tag
Generic.PHP.LowerCaseConstant
TRUE, FALSE and NULL must be lowercase
Generic.PHP.LowerCaseKeyword
PHP keywords must be lowercase (if instead of IF)
Generic.WhiteSpace.DisallowTabIndent
Spaces must be used for alignment; tabs are not allowed
Generic.WhiteSpace.ScopeIndent
Ensure code is indented properly
PEAR
===================
PEAR.Functions.ValidDefaultValue
Arguments with default values must be at the end of the argument list
PSR1
===================
PSR1.Classes.ClassDeclaration
One class per file
PSR1.Files.SideEffects
Detect side effects in files to prevent mixing of declaration of new symbols and executing logic
PSR1.Methods.CamelCapsMethodName
Methods must be in camel caps format
PSR2
===================
PSR2.Classes.ClassDeclaration
Restrict class declaration formatting
PSR2.Classes.PropertyDeclaration
Restrict property declaration
- Not prefixed with an underscore
- The var keyword must not be used to declare a property
- There must not be more than one property declared per statement
- Visibility must be declared
PSR2.ControlStructures.ControlStructureSpacing
Restrict whitespace in control structures
PSR2.ControlStructures.ElseIfDeclaration
Usage of ELSE IF is discouraged; use ELSEIF instead
PSR2.ControlStructures.SwitchDeclaration
Restrict switch declaration formatting
PSR2.Files.ClosingTag
A closing tag is not permitted at the end of a PHP file
PSR2.Files.EndFileNewline
File must end with a newline character
PSR2.Methods.FunctionCallSignature
?Detect multiline function signature or single line
PSR2.Methods.FunctionClosingBrace
Function closing brace must go on the next line following the body
PSR2.Methods.MethodDeclaration
Restrict method declaration
- Not prefixed with an underscore
- The final declaration must precede the visibility declaration
- The abstract declaration must precede the visibility declaration
- The static declaration must come after the visibility declaration
PSR2.Namespaces.NamespaceDeclaration
There must be one blank line after the namespace declaration
PSR2.Namespaces.UseDeclaration
Restrict use declaration
- There must be one USE keyword per declaration
- USE declarations must go after the first namespace declaration
- USE declarations must go after the namespace declaration
- There must be one blank line after the last USE statement
PSR12
===================
PSR12.Classes.AnonClassDeclaration
Enforces the formatting of anonymous classes
PSR12.Classes.ClosingBrace
Enforces that closing braces of classes/interfaces/traits/functions are not followed by a comment or statement
PSR12.ControlStructures.BooleanOperatorPlacement
Enforces that boolean operators between conditions are consistently at the start or end of the line
PSR12.ControlStructures.ControlStructureSpacing
Enforces that spacing and indents are correct inside control structure parenthesis
PSR12.Files.DeclareStatement
Enforces the formatting of declare statements within a file
PSR12.Files.FileHeader
Enforces the order and formatting of file header blocks
PSR12.Files.ImportStatement
Enforces the formatting of import statements within a file
PSR12.Files.OpenTag
Enforces that the open tag is on a line by itself when used at the start of a php-only file
PSR12.Functions.NullableTypeDeclaration
In nullable type declarations there MUST NOT be a space between the question mark and the type
PSR12.Functions.ReturnTypeDeclaration
Enforces the formatting of return type declarations in functions and closures
PSR12.Properties.ConstantVisibility
Enforces that constants must have their visibility defined
PSR12.Traits.UseDeclaration
Enforces the formatting of trait import statements within a class
Squiz
===================
Squiz.Classes.ValidClassName
Squiz.ControlStructures.ControlSignature
Squiz.ControlStructures.ForEachLoopDeclaration
Squiz.ControlStructures.ForLoopDeclaration
Squiz.ControlStructures.LowercaseDeclaration
Squiz.Functions.FunctionDeclaration
Squiz.Functions.FunctionDeclarationArgumentSpacing
Squiz.Functions.LowercaseFunctionKeywords
Squiz.Functions.MultiLineFunctionDeclaration
Squiz.Scope.MethodScope
Squiz.WhiteSpace.ControlStructureSpacing
Squiz.WhiteSpace.ScopeClosingBrace
Squiz.WhiteSpace.ScopeKeywordSpacing
Squiz.WhiteSpace.SuperfluousWhitespace
-->
</ruleset>

View File

@ -0,0 +1,605 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-SCS-1">
<description>extension of Slevomat Coding Standard</description>
<!-- https://github.com/slevomat/coding-standard -->
<!-- See https://github.com/slevomat/coding-standard/#sniffs-included-in-this-standard -->
<!-- Checks for missing property typehints in case they can be declared natively -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="true"/>
<property name="traversableTypeHints" type="array">
<element value="array"/>
<element value="iterable"/>
<element value="Traversable"/>
<element value="\Illuminate\Support\Collection"/>
</property>
</properties>
<!-- Disabled since subclasses can't always overrule parents -->
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<!-- Checks for missing return typehints in case they can be declared natively -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableObjectTypeHint" value="true"/>
<property name="traversableTypeHints" type="array">
<element value="array"/>
<element value="iterable"/>
<element value="Traversable"/>
<element value="\Illuminate\Support\Collection"/>
</property>
</properties>
<!-- Disabled since subclasses can't always overrule parents -->
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
</rule>
<!-- Reports useless @var annotation (or whole documentation comment) for constants because the type of constant is always clear -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Use the php 7.0+ Throwable interface instead of `Exception` -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Enforce declare strict types -->
<!-- Covered by PSR-12: Generic.PHP.RequireStrictTypes -->
<!--<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>-->
<!-- Disallows implicit array creation -->
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<!-- Disallows implicit array creation -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<element value="public constants"/>
<element value="protected constants"/>
<element value="private constants"/>
<element value="public static properties"/>
<element value="protected static properties"/>
<element value="private static properties"/>
<element value="public properties, protected properties, private properties"/>
<element value="public static abstract methods"/>
<element value="protected static abstract methods"/>
<element value="public abstract methods"/>
<element value="protected abstract methods"/>
<element value="static constructors"/>
<element value="constructor"/>
<element value="destructor"/>
<element value="public methods, protected methods, private methods"/>
<element value="public static methods, protected static methods, private static methods"/>
<element value="magic methods"/>
</property>
</properties>
</rule>
<!-- Prefer self:: over static:: for CONST which should not be changed -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Prefer self:: over static:: for class vars of final class -->
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
<!-- Don't allow `if($x = something()){}` -->
<!-- Also covered by Generic.CodeAnalysis.AssignmentInCondition, but this one is more permissive in while loops -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Disallows use of continue without integer operand in switch because it's emits warning in PHP 7.3 and higher -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Disallow `empty` language construct to prevent unexisting variable usage -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>
<!-- Only allow `===` and `!===` -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Prefer `$x ?? 5` over `isset($x) ? $x : 5` -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<!-- Requires use of null coalesce equal operator when possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<!-- Some functions have $strict parameter. This sniff reports calls to these functions without the parameter or with $strict = false. -->
<!-- Enabled in `phased-coding-standard` for now -->
<!-- <rule ref="SlevomatCodingStandard.Functions.StrictCall"/> -->
<!-- Reports closures not using $this that are not declared static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Disallows direct call of __invoke() -->
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
<!-- Disabled since we are not interested in disabling `$i++`. Use unary statement wisely though -->
<!--<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/>-->
<!-- Only allow unary statement as standalone to avoid hard to read code -->
<!-- Disabled since we allow the responsible usage of unary statements -->
<!--<rule ref="SlevomatCodingStandard.Operators.RequireOnlyStandaloneIncrementAndDecrementOperators"/>-->
<!-- Enforce `$i += 1` instead of `$i = $i + 1` -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Detect unused variables passed to closures via `use` statement-->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Detect unused parameters -->
<!-- Disabled since we often have unused optional arguments -->
<!--<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>-->
<!-- Detect useless default value for parameter -->
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<!-- Detect unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<!-- properties: searchAnnotations, ignoredAnnotationNames, ignoredAnnotations -->
<!-- Search in annotations to avoid false positives -->
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Detect use statements from same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Detect use-statements with alias to the same name -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>-->
<!-- Disallows references -->
<!-- Disabled since the code contains enough occurrences which can't easily be removed as of yet -->
<!--<rule ref="SlevomatCodingStandard.PHP.DisallowReference"/>-->
<!-- Reports usage of forbidden classes, interfaces, parent classes and traits -->
<rule ref="SlevomatCodingStandard.PHP.ForbiddenClasses">
<properties>
<property name="forbiddenClasses" type="array">
<!-- More facades from Illuminate to add: see app.php from any laravel installation -->
<element key="Validator" value="Illuminate\Support\Facades\Validator"/>
</property>
<property name="forbiddenExtends" type="array">
<element key="Exception" value="null"/>
</property>
<!--
<property name="forbiddenInterfaces" type="array">
</property>
<property name="forbiddenTraits" type="array">
</property>
-->
</properties>
</rule>
<!-- Requires assertion via assert instead of inline documentation comments -->
<!-- Disabled since we use `Assert::that` for this functionality -->
<!--<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion"/>-->
<!-- Requires nowdoc syntax instead of heredoc when possible -->
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc"/>
<!-- Detect random parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- PHP optimizes some internal functions into special opcodes on VM level.
Such optimization results in much faster execution compared to calling standard function.
This only works when these functions are not invoked with argument unpacking -->
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<!-- Detect rogue semicolons -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Disallows use of super global variables -->
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<!-- Looks for duplicate assignments to a variable -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Detect unused variables -->
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<!-- Detect useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Detect unreachable catch statement -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks whitespace in single line array declarations (whitespace between brackets, around commas, ...) -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace">
<properties>
<property name="enableEmptyArrayCheck" value="true"/>
</properties>
</rule>
<!-- Checks lines count between different class members, eg. between last property and first method. -->
<!-- Disabled since it's covered by Generic.WhiteSpace.FunctionSpacing -->
<!--<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>-->
<!-- Add trailing comma to multiline arrays -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Checks that there is a certain number of blank lines between constants -->
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="1"/>
<property name="maxLinesCountBeforeWithComment" value="1"/>
<property name="minLinesCountBeforeWithoutComment" value="0"/>
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
</properties>
</rule>
<!-- Disallows multi constant definition -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Disallows multi property definition -->
<!-- Disabled since it's covered by PSR2.Classes.PropertyDeclaration.Multiple -->
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>-->
<!-- Checks that there is a certain number of blank lines between methods -->
<!-- Disabled since it's covered by Squiz.WhiteSpace.FunctionSpacing.After -->
<!--<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>-->
<!-- Detect use of __CLASS__, get_parent_class(), get_called_class(), get_class(). Use ::class constant -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<!-- Enforces configurable number of lines around parent method call -->
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<!-- Checks that there is a certain number of blank lines between properties -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="1"/>
<property name="maxLinesCountBeforeWithComment" value="1"/>
<property name="minLinesCountBeforeWithoutComment" value="0"/>
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
</properties>
</rule>
<!-- Enforces method signature to be splitted to more lines so each parameter is on its own line -->
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
<properties>
<property name="minLineLength" value="121"/>
</properties>
</rule>
<!-- Enforces method signature to be on a single line -->
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature">
<properties>
<property name="maxLineLength" value="120"/>
</properties>
</rule>
<!-- Detects use of superfluous prefix or suffix "Abstract" for abstract classes -->
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>-->
<!-- Detects use of superfluous prefix or suffix "Interface" for interfaces -->
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<!-- Detects use of superfluous suffix "Exception" for exceptions -->
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>-->
<!-- Reports use of superfluous suffix "Error" for errors -->
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/>-->
<!-- Reports use of superfluous suffix "Trait" for traits -->
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>-->
<!-- Prohibits multiple traits separated by commas in one use statement -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Enforces configurable number of lines before first trait use, after last use and between two use statements -->
<!-- Disabled since it's covered by PSR12.Traits.UseDeclaration -->
<!--<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"/>-->
<!-- Enforces configurable number of lines around block control structures (if, foreach, ...) -->
<!-- Disabled since enforcing this is not requested -->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>-->
<!-- Enforces configurable number of lines around jump statements (continue, return, ...) -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="allowSingleLineYieldStacking" value="true"/>
<property name="linesCountBeforeControlStructure" value="1"/>
<property name="linesCountBeforeFirstControlStructure" value="0"/>
<property name="linesCountAfterControlStructure" value="1"/>
<property name="linesCountAfterLastControlStructure" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN"/>
</property>
</properties>
</rule>
<!-- Detect language construct used with parentheses `exit()`-->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Enforce new with parentheses -->
<!-- Disabled since it's covered by PSR12.Classes.ClassInstantiation -->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>-->
<!-- Disabled since common senses points toward new with parentheses -->
<!-- Enforce new without parentheses -->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>-->
<!-- Disabled since we are not interested in prohibiting `$x ?: $y` -->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
<!-- Ternary operator has to be reformatted to more lines when the line length exceeds the given limit -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator">
<properties>
<property name="lineLengthLimit" value="120"/>
</properties>
</rule>
<!-- Enforces conditions of if, elseif, while and do-while to be on a single line -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition">
<properties>
<property name="maxLineLength" value="120"/>
<property name="alwaysForSimpleConditions" value="false"/>
</properties>
</rule>
<!-- Enforces conditions of if, elseif, while and do-while with one or more boolean operators to be splitted to more lines so each condition part is on its own line -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition">
<properties>
<property name="minLineLength" value="121"/>
<property name="booleanOperatorOnPreviousLine" value="false"/>
<property name="alwaysSplitAllConditionParts" value="false"/>
</properties>
</rule>
<!-- Enforce `$x ?: $y` in contrary to `$x ? $x : $y` whenever possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<!-- Requires ternary operator when possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
<!-- Yoda conditions decrease code comprehensibility and readability -->
<!-- Disabled since it's covered by Generic.ControlStructures.DisallowYodaConditions -->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>-->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/>-->
<!-- Enforces maximum length of a single line of code -->
<rule ref="SlevomatCodingStandard.Files.LineLength">
<properties>
<property name="lineLengthLimit" value="120"/>
<property name="ignoreComments" value="false"/>
<property name="ignoreImports" value="true"/>
</properties>
</rule>
<!-- Checks fn declaration -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
<!-- Reports empty functions body and requires at least a comment inside -->
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
<!-- Disallows arrow functions -->
<!-- Disabled since we haven't made a choice what we want yet -->
<!--<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>-->
<!--<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>-->
<!-- Enforces function call to be splitted to more lines so each parameter is on its own line -->
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall">
<properties>
<property name="minLineLength" value="121"/>
</properties>
</rule>
<!-- Enforces function call to be on a single line -->
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall">
<properties>
<property name="maxLineLength" value="120"/>
<property name="ignoreWithComplexParameter" value="true"/>
</properties>
</rule>
<!-- Enforce alphabetically ordered use statement list -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="psr12Compatible" value="true"/>
<property name="caseSensitive" value="false"/>
</properties>
</rule>
<!-- Enforce only one namespace in a file -->
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/>
<!-- Restrict namespace declaration spacing -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
<!-- Restrict namespace newline wrapping -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" value="1"/>
<property name="linesCountAfterNamespace" value="1"/>
</properties>
</rule>
<!-- Restrict use newline wrapping -->
<!-- Disabled since it's covered by PSR12.Files.FileHeader -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>-->
<!-- Disallows numeric literal separators -->
<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
<!-- Requires use of numeric literal separators -->
<!-- Disabled since we prefer purity in code over random separators in numbers making them impossible to use elsewhere -->
<!--<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>-->
<!-- Enforces configurable number of spaces after reference -->
<rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing"/>
<!-- Enforces configurable number of spaces after ! -->
<!-- Disabled since it's covered by Generic.Formatting.SpaceAfterNot -->
<!--<rule ref="SlevomatCodingStandard.PHP.NegationOperatorSpacing"/>-->
<!-- Enforces configurable number of spaces after the ... operator -->
<!-- Disabled since it's covered by Generic.WhiteSpace.SpreadOperatorSpacingAfter -->
<!--<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>-->
<!-- Disallows usage of "mixed" type hint in phpDocs -->
<rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/>
<!-- Enforce typehints with native scalar for consistency -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- prefer string|null over null|string in type hints -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Enforce `[...]` over `list(...)` -->
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<!-- Enforces shorthand cast operators, forbids unset and binary cast operators. `(bool)` instead of (boolean) -->
<!-- Also covered by PSR12.Functions.NullableTypeDeclaration, but this one is more extensive -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Checks duplicate spaces anywhere because there aren't sniffs for every part of code to check formatting -->
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>
<!-- Detect PSR-4 compliance between Filepath and Namespace -->
<!-- Customized in phpcs-laravel and phpcs-module -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
<!-- Enforce visibility notation for class constants -->
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<!-- Restrict return type hint spacing -->
<!-- Disabled since it's covered by PSR12.Functions.NullableTypeDeclaration & PSR12.Functions.ReturnTypeDeclaration -->
<!--<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>-->
<!-- Enforce nullability ? symbol before each nullable and optional parameter -->
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<!-- Restrict parameter type hint spacing -->
<!-- Disabled since it's covered by PSR12.Functions.NullableTypeDeclaration -->
<!--<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>-->
<!-- Prohibit group use statements https://wiki.php.net/rfc/group_use_declarations -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Disabled since we want FQN's as `use` statement -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>-->
<!-- Disabled since we want FQN's as `use` statement -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>-->
<!-- Disabled since this is more annoying than useful -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>-->
<!-- Disabled since this is more annoying than useful -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>-->
<!-- Multiple uses per line is against PSR-2 -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Enforce `use` statements for FQN's in contrary to inline FQN's -->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Disabled since we want all FQN's as `use` statement -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>-->
<!-- Enforce clean use-statements without prefixed backslash -->
<!-- Disabled since it's covered by PSR12.Files.ImportStatement -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>-->
<!-- Disabled since PSR-2 enforces direct closing after body -->
<!--<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>-->
<!-- Disabled since we want all FQN's as `use` statement -->
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>-->
<!-- Reports @deprecated annotations without description -->
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<!-- Prohibit annotations as they're useless with version control -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@filesource"/>
<element value="@global"/>
<element value="@ignore"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@uses"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Disallow comments after code -->
<!-- Disabled since comments after code are a concise way of adding context -->
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowInlineCommentAfterCode"/>-->
<!-- Prohibit certain comments since there's useless -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^Created by \S+\.?\z~i"/>
<element value="~^\w* ?Constructor\.?$~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.?\z~i"/>
<element value="~^(Class|Trait|Interface) \S*\.?$~i"/>
</property>
</properties>
</rule>
<!-- Restrict doc comment spacing -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
<!-- Prohibit empty comments since they're useless-->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Restrict inline doc comment declaration (/** @var <type> $<var> */) -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.NoAssignment"/>
</rule>
<!-- Restrict multi-line comment with one line to 1 line comment -->
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
<!-- Disabled since we're interested in RequireOneLinePropertyDocComment -->
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>-->
<!-- Checks for useless doc comments. If the native method declaration contains everything and the phpDoc does not add anything useful -->
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment">
<properties>
<property name="traversableTypeHints" type="array">
<element value="array"/>
<element value="iterable"/>
<element value="Traversable"/>
<element value="\Illuminate\Support\Collection"/>
</property>
</properties>
</rule>
<!-- Inheritance is automatic and it's not needed to use a special annotation -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Reports useless conditions where both branches return true or false -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Reports useless ternary operator where both branches return true or false -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
</ruleset>

View File

@ -0,0 +1,474 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-SCS-1">
<description>extension of Squiz Coding Standard</description>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards/Squiz/Sniffs -->
<!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizwhitespacefunctionspacing -->
<!--
|=============================================================================
|=============================================================================
Array
|=============================================================================
|=============================================================================
-->
<!-- Ensures that arrays conform to the array coding standard -->
<!-- Disabled since it's mostly covered by Generic.WhiteSpace.* and Generic.Arrays.DisallowLongArraySyntax -->
<!-- <rule ref="Squiz.Arrays.ArrayDeclaration"/> -->
<!-- Ensure that there are no spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!--
|=============================================================================
|=============================================================================
CSS
|=============================================================================
|=============================================================================
-->
<!-- Not configured any because we don't parse css with the code sniffer -->
<!-- <rule ref="Squiz.CSS.*"/> -->
<!--
|=============================================================================
|=============================================================================
Classes
|=============================================================================
|=============================================================================
-->
<!-- Checks the declaration of the class and its inheritance is correct -->
<rule ref="Squiz.Classes.ClassDeclaration"/>
<!-- Tests that the file name and the name of the class contained within the file match -->
<!-- Disabled since it's covered by the more comprehensive SlevomatCodingStandard.Files.TypeNameMatchesFileName -->
<!-- <rule ref="Squiz.Classes.ClassFileName"/> -->
<!-- Ensures JS classes don't contain duplicate property names -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Classes.DuplicateProperty"/> -->
<!-- Ensures JS classes don't contain duplicate property names -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Classes.DuplicateProperty"/> -->
<!-- Tests self member references -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Ensures classes are in camel caps, and the first letter is capitalised -->
<!-- Complementary to SlevomatCodingStandard.Files.TypeNameMatchesFileName
This also detects typos in both file and class name -->
<rule ref="Squiz.Classes.ValidClassName"/>
<!--
|=============================================================================
|=============================================================================
Commenting
|=============================================================================
|=============================================================================
-->
<!-- Verifies that block comments are used appropriately -->
<!-- Disabled since we are fine with single line block comment -->
<!-- It also conflicts with doc comment type hinting -->
<!-- <rule ref="Squiz.Commenting.BlockComment"/> -->
<!-- Parses and verifies the class doc comment -->
<!-- Disabled since it seems a lot of useful @tags aren't allowed anymore -->
<!-- <rule ref="Squiz.Commenting.ClassComment"/> -->
<!-- Checks the //end ... comments on classes, interfaces and functions -->
<!-- Disabled since we don't want a verbose //end marker at the end of each function and class -->
<!-- <rule ref="Squiz.Commenting.ClosingDeclarationComment"/> -->
<!-- Tests that the stars in a doc comment align correctly -->
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<!-- Checks for empty catch clause without a comment -->
<!-- Enabled even though empty catch statements are disallowed in the case an empty catch is phpcs:ignored -->
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<!-- Parses and verifies the file doc comment -->
<!-- Disabled since we don't place file comments -->
<!-- <rule ref="Squiz.Commenting.FileComment"/> -->
<!-- Parses and verifies the doc comments for functions -->
<!-- Disabled since it requests a parameter comment for each parameter -->
<!-- <rule ref="Squiz.Commenting.FunctionComment"/> -->
<!-- Verifies that a @throws tag exists for each exception type a function throws -->
<!-- Disabled since PhpStorm doesn't automatically adds these and it's annoying manual work -->
<!-- <rule ref="Squiz.Commenting.FunctionCommentThrowTag"/> -->
<!-- Checks that there is adequate spacing between comments -->
<!-- Disabled since it is to strict to our liking: full stops for each comment -->
<!-- It also conflicts with doc comment type hinting -->
<!-- <rule ref="Squiz.Commenting.InlineComment"/> -->
<!-- Ensures long conditions have a comment at the end -->
<!-- Disabled since we don't want a verbose //end marker at the end of each (long) control structure -->
<!-- <rule ref="Squiz.Commenting.LongConditionClosingComment"/> -->
<!-- Checks to ensure that there are no comments after statements -->
<!-- Disabled since comments after statements are a great one-liner explanation -->
<!-- <rule ref="Squiz.Commenting.PostStatementComment"/> -->
<!-- Parses and verifies the variable doc comment -->
<!-- Disabled since it conflicts with SlevomatCodingStandard.PHP.TypeCast -->
<!-- <rule ref="Squiz.Commenting.VariableComment"/> -->
<!--
|=============================================================================
|=============================================================================
Control Structures
|=============================================================================
|=============================================================================
-->
<!-- Verifies that control statements conform to their coding standards -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.ControlSignature"/> -->
<!-- Ensures the use of else if over elseif -->
<!-- Disabled since it conflicts with PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.ElseIfDeclarationSniff"/> -->
<!-- Verifies that there is a space between each condition of foreach loops -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/> -->
<!-- Verifies that there is a space between each condition of for loops -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/> -->
<!-- Tests the spacing of shorthand IF statements -->
<!-- Disabled since it conflicts with numerous other sniffs (useless parenthesis, multi line) -->
<!-- <rule ref="Squiz.ControlStructures.InlineIfDeclaration"/> -->
<!-- Ensures all control structure keywords are lowercase -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/> -->
<!-- Enforces switch statement formatting -->
<!-- Disabled since it conflicts with PSR12 -->
<!-- <rule ref="Squiz.ControlStructures.SwitchDeclaration"/> -->
<!--
|=============================================================================
|=============================================================================
Debug
|=============================================================================
|=============================================================================
-->
<!-- Runs jslint.js on the file -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Debug.JSLint"/> -->
<!-- Runs jslint.js on the file -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Debug.JSLint"/> -->
<!-- Runs JavaScript Lint on the file -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Debug.JavaScriptLint"/> -->
<!-- Runs JavaScript Lint on the file -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Debug.JavaScriptLint"/> -->
<!--
|=============================================================================
|=============================================================================
Files
|=============================================================================
|=============================================================================
-->
<!-- Tests that classes and interfaces are not declared in .php files -->
<!-- Disabled since we just want php file extensions -->
<!-- <rule ref="Squiz.Files.FileExtension"/> -->
<!--
|=============================================================================
|=============================================================================
Formatting
|=============================================================================
|=============================================================================
-->
<!-- Tests that all arithmetic operations are bracketed -->
<!-- Disabled since it conflicts with PSR12 -->
<!-- <rule ref="Squiz.Formatting.OperatorBracket"/> -->
<!--
|=============================================================================
|=============================================================================
Functions
|=============================================================================
|=============================================================================
-->
<!-- Checks that arguments in function declarations are spaced correctly -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"/> -->
<!-- Checks the function declaration is correct -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.Functions.FunctionDeclaration"/> -->
<!-- Checks that duplicate arguments are not used in function declarations -->
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<!-- Tests for functions outside of classes -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Ensures all function keywords are lowercase -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/> -->
<!-- Ensure single and multi-line function declarations are defined correctly -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/> -->
<!--
|=============================================================================
|=============================================================================
Naming conventions
|=============================================================================
|=============================================================================
-->
<!-- TODO: find a way to disable for model attributes? -->
<!-- <rule ref="Squiz.NamingConventions.ValidVariableName">-->
<!-- <exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>-->
<!-- </rule>-->
<!--
|=============================================================================
|=============================================================================
Objects
|=============================================================================
|=============================================================================
-->
<!-- Ensures objects are assigned to a variable when instantiated -->
<!-- Disabled since chaining is actually pretty useful -->
<!-- <rule ref="Squiz.Objects.ObjectInstantiation"/> -->
<!-- Ensures the last member of an object is not followed by a comma -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Objects.ObjectMemberComma"/> -->
<!-- Ensures the last member of an object is not followed by a comma -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Objects.ObjectMemberComma"/> -->
<!-- Ensures that object indexes are written in dot notation -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Objects.DisallowObjectStringIndex"/> -->
<!-- Ensures that object indexes are written in dot notation -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.Objects.DisallowObjectStringIndex"/> -->
<!--
|=============================================================================
|=============================================================================
Operators
|=============================================================================
|=============================================================================
-->
<!-- enforce the use of IDENTICAL type operators rather than EQUAL operators -->
<!-- Disabled since implicit truthy and falsy checks are fine -->
<!-- <rule ref="Squiz.Operators.ComparisonOperatorUsage"/> -->
<!-- Ensures that the ++ operators are used when possible -->
<!-- Disabled since $var += 1 and $var -= 1 is fine -->
<!-- <rule ref="Squiz.Operators.IncrementDecrementUsage"/> -->
<!-- Ensures logical operators 'and' and 'or' are not used -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!--
|=============================================================================
|=============================================================================
PHP
|=============================================================================
|=============================================================================
-->
<!-- Ensures all calls to inbuilt PHP functions are lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Ensures that functions within functions are never used -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Bans the use of heredocs and nowdocs -->
<!-- Disabled since we allow Heredoc and Nowdoc -->
<!-- <rule ref="Squiz.PHP.Heredoc"/> -->
<!-- Stops the usage of the "global" keyword -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- The use of eval() is discouraged -->
<!-- Disabled since it's already covered by Generic.PHP.ForbiddenFunctions -->
<!-- <rule ref="Squiz.PHP.Eval"/> -->
<!-- Checks the indentation of embedded PHP code segments -->
<rule ref="Squiz.PHP.EmbeddedPhp"/>
<!-- Discourages the use of debug functions -->
<!-- Disabled since it covered by Generic.PHP.ForbiddenFunctions -->
<!-- <rule ref="Squiz.PHP.DiscouragedFunctions"/> -->
<!-- Bans the use of size-based functions in loop conditions -->
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
<!-- Ensures there is only one assignment on a line, and that it is the first thing on the line -->
<!-- Disabled since multiple assignments are allowed and return $this->cache = 'value' is also allowed -->
<!-- <rule ref="Squiz.PHP.DisallowMultipleAssignments"/> -->
<!-- Stops inline IF statements from being used -->
<!-- Disabled since this rule makes no sense... ternary operators are fine -->
<!-- <rule ref="Squiz.PHP.DisallowInlineIf"/> -->
<!-- Ensures that the value of a comparison is not assigned to a variable -->
<!-- Disabled since short assignments to create booleans are a great way to create readable code -->
<!-- <rule ref="Squiz.PHP.DisallowComparisonAssignment"/> -->
<!-- Ensures that boolean operators are only used inside control structure conditions -->
<!-- Disabled since short boolean checks are a great way to create readable code -->
<!-- <rule ref="Squiz.PHP.DisallowBooleanStatement"/> -->
<!-- Warn about commented out code -->
<!-- Disabled due to a high probability of false positives and sometimes commented code isn't all that bad -->
<!-- <rule ref="Squiz.PHP.CommentedOutCode"/> -->
<!-- Warns about code that can never been executed -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!--
|=============================================================================
|=============================================================================
Scope
|=============================================================================
|=============================================================================
-->
<!-- Checks for usage of $this in static methods, which will cause runtime errors -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Verifies that class members have scope modifiers -->
<rule ref="Squiz.Scope.MemberVarScope"/>
<!-- Verifies that class methods have scope modifiers -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.Scope.MethodScope"/> -->
<!--
|=============================================================================
|=============================================================================
Strings
|=============================================================================
|=============================================================================
-->
<!-- Makes sure there are no spaces around the concatenation operator -->
<!-- Disabled since it conflicts with PSR12 -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing"/> -->
<!-- Makes sure that any use of double quotes strings are warranted -->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<!-- Makes sure that any strings that are "echoed" are not enclosed in brackets -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!--
|=============================================================================
|=============================================================================
WhiteSpace
|=============================================================================
|=============================================================================
-->
<!-- Ensure cast statements don't contain whitespace -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Checks that control structures have the correct spacing around brackets -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/> -->
<!-- Checks that there is one empty line before the closing brace of a function -->
<!-- Disabled since we don't want superfluous whitespace -->
<!-- <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace"/> -->
<!-- Checks that there is no empty line after the opening brace of a function -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Checks the separation between functions and methods -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Ensures all language constructs contain a single space between themselves and their content -->
<!-- Disabled since this sniff is superseeded by Generic.WhiteSpace.LanguageConstructSpacing -->
<!-- <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> -->
<!-- Verifies that operators have valid spacing surrounding them -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> -->
<!-- Verifies that class members are spaced correctly -->
<!-- Disabled since it's covered by the more comprehensive SlevomatCodingStandard.Classes.PropertySpacing -->
<!--<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>-->
<!-- Ensure there is no whitespace before/after an object operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Verifies that operators have valid spacing surrounding them -->
<!-- Disabled since it's covered by PSR12 -->
<!-- <rule ref="Squiz.WhiteSpace.OperatorSpacing"/> -->
<!-- Ensures that a property or label colon has a single space after it and no space before it -->
<!-- Disabled since we don't parse javascript with the code sniffer -->
<!-- <rule ref="Squiz.WhiteSpace.PropertyLabelSpacing"/> -->
<!-- Checks that the closing braces of scopes are aligned correctly -->
<!-- Disabled since it's mostly covered by Generic.WhiteSpace.ScopeIndent -->
<!-- <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/> -->
<!-- Checks that the closing braces of scopes are aligned correctly -->
<!-- Disabled since it's mostly covered by Generic.WhiteSpace.ScopeIndent and Enabled by PSR-2 -->
<!-- <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/> -->
<!-- Ensure there is a single space after scope keywords -->
<!-- Enabled by PSR-2 -->
<!-- <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/> -->
<!-- Ensure there is no whitespace before a semicolon -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Checks for unneeded whitespace -->
<!-- Enabled by PSR-2 -->
<!-- <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> -->
<!-- Checks for unneeded whitespace -->
<!-- Enabled by PSR-2 -->
<!-- <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> -->
</ruleset>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-L-1">
<rule ref="./phpcs.xml"/>
<rule ref="./extras/laravel-exclusions.xml"/>
</ruleset>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-P-1">
<description>Coding Standard for Packages</description>
<rule ref="./phpcs.xml"/>
</ruleset>

9
src/rulesets/phpcs.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-1">
<rule ref="./settings.xml"/>
<rule ref="./extras/generic-coding-standard.xml"/>
<rule ref="./extras/psr-coding-standard.xml"/>
<rule ref="./extras/squiz-coding-standard.xml"/>
<rule ref="./extras/slevomat-coding-standard.xml"/>
<rule ref="./extras/pear-coding-standard.xml"/>
</ruleset>

61
src/rulesets/settings.xml Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CCS-1">
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
<description>Coding Standard</description>
<!--
You can hard-code command line values into your custom standard.
Note that this does not work for the command line values:
-v[v][v], -l, -d, -sniffs and -standard
The following tags are equivalent to the command line arguments:
-p
-->
<!-- How should the findings be reported. Values: full, summary-->
<arg name="report" value="full"/>
<!-- Encoding should be utf-8-->
<arg name="encoding" value="utf-8"/>
<!-- tab width should be 4 spaced-->
<arg name="tab-width" value="4"/>
<!-- files to tokenize at the same time. Setting this higher than '1' somehow makes it skip all but x files-->
<arg name="parallel" value="1"/>
<!-- Show colors in the output -->
<arg name="colors"/>
<!-- Show all found issues with a higher severity than '1', which basically is everything -->
<arg name="severity" value="1"/>
<!-- Show progress while performing the scan/fix -->
<arg value="p"/>
<!-- Show progress while performing the scan/fix -->
<arg name="extensions" value="php"/>
<!--'php_version' => '70205',-->
<!--
You can hard-code custom php.ini settings into your custom standard.
The following tag sets the memory limit to 128M.
-->
<ini name="memory_limit" value="128M"/>
<!--
Rulesets: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
The default is used unless otherwise noted
-->
<!-- relative path from PHPCS source location -->
<config name="installed_paths" value="../../../vendor/slevomat/coding-standard,../../../vendor/sirbrillig/phpcs-variable-analysis,../../../vendor/phpcompatibility/php-compatibility"/>
</ruleset>