Skip to content

Commit fa34ce8

Browse files
committed
Just use PSR-12 for coding standards for now
1 parent ed0ebd9 commit fa34ce8

File tree

3 files changed

+85
-83
lines changed

3 files changed

+85
-83
lines changed

TESTING.md

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,81 +26,35 @@ Once you have written your code and tests, run the tests to make sure there are
2626
To run the tests, enter the following commands in a separate Terminal window:
2727

2828
```bash
29-
vendor/bin/phpunit --verbose tests
29+
vendor/bin/phpunit --verbose --stop-on-failure
3030
```
3131

3232
If a test fails, you can inspect the output.
3333

3434
Any errors should be corrected by making applicable code or test changes.
3535

36-
## Run PHP CodeSniffer
37-
38-
[PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) checks that all code meets Coding Standards.
39-
40-
To run the tests, enter the following command:
41-
42-
```bash
43-
vendor/bin/phpcs ./ --standard=phpcs.xml -v -s
44-
```
45-
46-
`--standard=phpcs.xml` tells PHP CodeSniffer to use the Coding Standards rules / configuration defined in `phpcs.xml`.
47-
`-v` produces verbose output
48-
`-s` specifies the precise rule that failed
49-
50-
Any errors should be corrected by either:
51-
- making applicable code changes
52-
- (Experimental) running `vendor/bin/phpcbf ./ --standard=phpcs.xml -v -s` to automatically fix coding standards
53-
54-
Need to change the coding standard rules applied? Either:
55-
- ignore a rule in the affected code, by adding `phpcs:ignore {rule}`, where {rule} is the given rule that failed in the above output.
56-
- edit the [phpcs.xml](phpcs.xml) file.
57-
58-
**Rules should be ignored with caution**
59-
6036
## Run PHP CodeSniffer for Tests
6137

62-
[PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) checks that all test code meets Coding Standards.
38+
[PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) checks that all test code meets the [PSR-12 Coding Standards](https://www.php-fig.org/psr/psr-12/).
6339

64-
To run the tests, enter the following command:
40+
To run CodeSniffer on tests, enter the following command:
6541

6642
```bash
67-
vendor/bin/phpcs ./ --standard=phpcs.tests.xml -v -s
43+
vendor/bin/phpcs --standard=phpcs.tests.xml
6844
```
6945

70-
`--standard=phpcs.tests.xml` tells PHP CodeSniffer to use the Coding Standards rules / configuration defined in `phpcs.tests.xml`.
71-
`-v` produces verbose output
72-
`-s` specifies the precise rule that failed
46+
`--standard=phpcs.tests.xml` tells PHP CodeSniffer to use the use the [phpcs.tests.xml](phpcs.tests.xml) configuration file
7347

7448
Any errors should be corrected by either:
7549
- making applicable code changes
76-
- (Experimental) running `vendor/bin/phpcbf ./ --standard=phpcs.xml -v -s` to automatically fix coding standards
50+
- (Experimental) running `vendor/bin/phpcbf --standard=phpcs.tests.xml` to automatically fix coding standards
7751

7852
Need to change the coding standard rules applied? Either:
7953
- ignore a rule in the affected code, by adding `phpcs:ignore {rule}`, where {rule} is the given rule that failed in the above output.
80-
- edit the [phpcs.xml](phpcs.xml) file.
54+
- edit the [phpcs.tests.xml](phpcs.tests.xml) file.
8155

8256
**Rules can be ignored with caution**, but it's essential that rules relating to coding style and inline code commenting / docblocks remain.
8357

84-
## Run PHPStan
85-
86-
[PHPStan](https://phpstan.org) performs static analysis on the code. This ensures:
87-
88-
- DocBlocks declarations are valid and uniform
89-
- Typehinting variables and return types declared in DocBlocks are correctly cast
90-
- Any unused functions are detected
91-
- Unnecessary checks / code is highlighted for possible removal
92-
- Conditions that do not evaluate can be fixed/removed as necessary
93-
94-
Run the following command to run PHPStan:
95-
96-
```bash
97-
vendor/bin/phpstan --memory-limit=1G
98-
```
99-
100-
Any errors should be corrected by making applicable code changes.
101-
102-
False positives [can be excluded by configuring](https://phpstan.org/user-guide/ignoring-errors) the `phpstan.neon` file.
103-
10458
## Next Steps
10559

10660
Once your tests are written and successfully run locally, submit your branch via a new [Pull Request](https://github.com/ConvertKit/ConvertKitSDK-PHP/compare).

phpcs.tests.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@
1414
<!-- Exclude "Each class must be in a namespace of at least one level (a top-level vendor name)" -->
1515
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
1616
</rule>
17-
18-
<rule ref="Squiz"></rule>
1917
</ruleset>

0 commit comments

Comments
 (0)