Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Fix version and implement ruleset changes #38

Merged
merged 7 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
composer.phar
composer.lock
/vendor/
/build
phpunit.xml
2 changes: 1 addition & 1 deletion CodeIgniter4/Sniffs/Commenting/ClassCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClassCommentSniff extends FileCommentSniff
*/
protected $tags = [
'@package' => [
'required' => true,
'required' => false,
'allow_multiple' => false,
],
'@subpackage' => [
Expand Down
6 changes: 3 additions & 3 deletions CodeIgniter4/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FileCommentSniff implements Sniff
*/
protected $tags = [
'@package' => [
'required' => true,
'required' => false,
'allow_multiple' => false,
],
'@subpackage' => [
Expand All @@ -45,15 +45,15 @@ class FileCommentSniff implements Sniff
'allow_multiple' => false,
],
'@author' => [
'required' => true,
'required' => false,
'allow_multiple' => true,
],
'@copyright' => [
'required' => false,
'allow_multiple' => true,
],
'@license' => [
'required' => true,
'required' => false,
'allow_multiple' => false,
],
'@link' => [
Expand Down
22 changes: 17 additions & 5 deletions CodeIgniter4/ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset name="CodeIgniter4">
<description>CodeIgniter 4 coding standard for PHP_CodeSniffer</description>
<!--
<!--
* CodeIgniter 4 coding standard for PHP_CodeSniffer
*
* @author Louis Linehan <louis.linehan@gmail.com>
Expand Down Expand Up @@ -39,9 +39,21 @@
Methods and functions MUST have a doc block comment.
-->
<rule ref="Squiz.Commenting.FunctionComment"/>
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentFullStop">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.EmptyThrows">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ThrowsNotCapital">
<severity>0</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ThrowsNoFullStop">
<severity>0</severity>
</rule>
<!--
Doc block comment alignment.
-->
Expand All @@ -68,10 +80,10 @@
-->
<arg name="tab-width" value="4"/>
<!--
Ignore application/Views/ directory.
Ignore application/Views/ directory.
Ignore application/ThirdParty/ directory.
Ignore system/ThirdParty/ directory.
There could be a mix of styles in ThirdParty and View files
There could be a mix of styles in ThirdParty and View files
could contain all sorts of indentation, alignments and scopes.
@todo subject to change.
-->
Expand Down Expand Up @@ -213,7 +225,7 @@
-->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="lineLimit" value="250"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
Expand Down Expand Up @@ -242,7 +254,7 @@
Checks there are no blank lines before a function closing brace.
-->
<rule ref="CodeIgniter4.WhiteSpace.FunctionClosingBraceSpace"/>
<!--
<!--
The keyword elseif SHOULD be used instead of else if so that all control
keywords look like single words.
-->
Expand Down
72 changes: 3 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[CodeIgniter](https://codeigniter.com) 4 coding standard for use with [PHP_CodeSniffer 3](https://github.com/squizlabs/PHP_CodeSniffer).

Version 1.0.1
Version 1

| Master | Develop |
| :---: | :---: |
Expand All @@ -23,8 +23,8 @@ PHP (7.1 or greater) with mbstring extension.

### Composer install

`cd /Path/To/MyProject`
`composer require codeigniter4/codeigniter4-standard --dev`
`cd /Path/To/MyProject`
`composer require codeigniter4/codeigniter4-standard --dev`

Set the `phpcs standard path` and `phpcbf standard path` in your editor/plugin config to:

Expand Down Expand Up @@ -110,72 +110,6 @@ or if globally installed.

`phpcbf /Path/To/MyProject --standard=CodeIgniter4`

## Example editor configs

### SublimeText project config

Project > Edit Project

Set it to your preference.

```
{
"SublimeLinter":
{
"linters":
{
"phpcs":
{
"@disable": false,
"cmd": "/Path/To/php_codesniffer/bin/phpcs",
// Or if installed globally. "cmd": "phpcs",
"standard": "/Path/To/CodeIgniter4-Standard/CodeIgniter4/ruleset.xml"
}
}
},
"folders":
[
{
"path": "/Path/To/MyProject"
}
],
"settings":
{
"phpcs":
{
"extensions_to_execute":
[
"php"
],
"phpcs_executable_path": "/Path/To/php_codesniffer/bin/phpcs",
// Or if installed globally. "phpcbf_executable_path": "phpcs",
"phpcs_additional_args":
{
"--standard": "/Path/To/CodeIgniter4-Standard/CodeIgniter4/ruleset.xml",
// Optional don't show warnings
// "-n": ""
},
"phpcbf_executable_path": "/Path/To/php_codesniffer/bin/phpcbf",
// Or if installed globally. "phpcbf_executable_path": "phpcbf",
"phpcbf_additional_args":
{
"--standard": "/Path/To/CodeIgniter4-Standard/CodeIgniter4/ruleset.xml",
// Optional don't fix warnings (if they're fixable)
// "-n": ""
},
// Execute the sniffer on file save. (Using contextual menu instead)
"phpcs_execute_on_save": false,
// Show the error list after save. (Using sublime linter instead)
"phpcs_show_errors_on_save": false,
// Show the errors in the quick panel so you can then goto line. (Gets annoying)
"phpcs_show_quick_panel": false,
// Turn the debug output on/off.
"show_debug": false
}
}
}
```

## Credits

Thanks to Greg Sherwood, Marc McIntyre, Andy Grunwald, Thomas Ernest and Erik Torsner, for providing open source code which helped me build this standard and a big thanks to [Squiz Labs](http://www.squizlabs.com) for creating [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "codeigniter4/codeigniter4-standard",
"type": "phpcodesniffer-standard",
"description": "CodeIgniter 4 Standard for PHP_CodeSniffer 3.",
"version":"1.0.1",
"license":"MIT",
"authors": [
{
Expand Down