Skip to content

Commit abe042b

Browse files
authored
Merge pull request #26 from flyeralarm/IN-1728-remove-return-type-sniff
IN-1728 - Remove ReturnTypeSniff with tests and from rulesets
2 parents a5a46a6 + 8c19682 commit abe042b

File tree

5 files changed

+8
-168
lines changed

5 files changed

+8
-168
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
# FLYERALARM PHP Coding Guideline Validator
22

3-
43
This repository contains the ruleset for the PHP code we develop at [FLYERALARM](https://flyeralarm.com).
54
It mostly consists of PSR-12 with some custom additions. The rules are enforced with the help of squizlabs/PHP_CodeSniffer
65

76
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,
87
“SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be
98
interpreted as described in [RFC 2119](http://www.ietf.org/rfc/rfc2119.txt).
109

10+
1111
## Custom Rules in addition to PSR-12
1212

1313
* Variable names MUST be in lowerCamelCase
1414
* Yoda conditions MUST NOT be used
1515
* Unit tests with @expectedException MUST contain @expectedExceptionMessage annotation
16-
* Return type annotations (@return) MUST only contain one of scalar type, object (e.g. no "@return string|null") or
17-
an array of one these
1816
* Exceptions messages MUST not contain exclamation marks or full stops
1917
* Keywords GOTO and EVAL MUST NOT be used
2018
* Underscores in namespaces MUST NOT be used
2119
* Classtype suffixes like Interface, Abstract or Trait MUST NOT be used (e.g. LoggerInterface)
2220

2321

2422
## How-To work within *this* project
23+
2524
To prepare run command:
2625
```bash
2726
make
@@ -48,7 +47,9 @@ test:
4847
vendor/bin/phpcs -w -p -s --standard=vendor/flyeralarm/php-code-validator/ruleset.xml src/ tests/
4948
```
5049

50+
5151
### Add project specific rules
52+
5253
The recommended way to define custom rules for the own project is to provide a ```phpcs.xml``` in the root of your
5354
project.
5455
PHP_CodeSniffer will automatically detect this standard if no other standard was defined (See [PHP_CodeSniffer Advanced Usage](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file)).
@@ -73,6 +74,7 @@ Once the file ```phpcs.xml``` is created the code can be validated using:
7374
vendor/bin/phpcs
7475
```
7576

77+
7678
### Update to latest stable
7779

7880
```bash
@@ -81,12 +83,14 @@ composer update flyeralarm/php-code-validator
8183

8284

8385
### Run sniffer
86+
8487
```bash
8588
make test
8689
```
8790

8891

8992
## Use within PHPStorm
93+
9094
1) Ensure the path to PHP Code Sniffer is configured - [open configuration manual](https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm#PHPCodeSnifferinPhpStorm-1.1.SpecifyingthepathtoPHPCodeSniffer)
9195
2) Open settings: \
9296
Mac: `PhpStorm` > `Preferences` > `Editor` > `Inspections` > `PHP` \
@@ -98,4 +102,4 @@ make test
98102
7) Confirm dialogs by pressing `ok`
99103

100104

101-
On a side note: [We are searching for talented people to join our various teams of developers in multiple locations](https://karriere.flyeralarm.com/jobs)
105+
On a side note: [We are searching for talented people to join our various teams of developers in multiple locations](https://www.flyeralarm.com/it-jobs/)

custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php

Lines changed: 0 additions & 148 deletions
This file was deleted.

ruleset.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/ForbiddenKeywordsSniff.php"/>
1111
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/NamespacesSniff.php"/>
1212
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/NoClassKindSuffixSniff.php"/>
13-
<rule ref="./custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php"/>
1413
<rule ref="./custom-standards/Flyeralarm/Sniffs/Docblock/ExpectedExceptionMessageSniff.php"/>
1514
<rule ref="./custom-standards/Flyeralarm/Sniffs/Variable/LowerCamelCaseSniff.php"/>
1615
<rule ref="./custom-standards/Flyeralarm/Sniffs/ControlStructures/YodaSniff.php"/>

tests/rules/doc/not-allowed/UnknownScalarReturnTypeInDocComment.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ruleset.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/ForbiddenKeywordsSniff.php"/>
1111
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/NamespacesSniff.php"/>
1212
<rule ref="./custom-standards/Flyeralarm/Sniffs/File/NoClassKindSuffixSniff.php"/>
13-
<rule ref="./custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php"/>
1413
<rule ref="./custom-standards/Flyeralarm/Sniffs/Docblock/ExpectedExceptionMessageSniff.php"/>
1514
<rule ref="./custom-standards/Flyeralarm/Sniffs/Variable/LowerCamelCaseSniff.php"/>
1615
<rule ref="./custom-standards/Flyeralarm/Sniffs/ControlStructures/YodaSniff.php"/>

0 commit comments

Comments
 (0)