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

Commit d1d815a

Browse files
committed
Merge branch 'release/1.0.0-beta0005'
2 parents 9892bd0 + f2d17c1 commit d1d815a

File tree

6 files changed

+208
-28
lines changed

6 files changed

+208
-28
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CodeIgniter4-Standard
2+
3+
## Contributing

Codeigniter4/Sniffs/ControlStructures/AllmanControlSignatureSniff.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public function process(File $phpcsFile, $stackPtr)
7474
|| $tokens[$stackPtr]['code'] === T_WHILE
7575
|| $tokens[($stackPtr)]['code'] === T_ELSE
7676
) {
77+
// If this is alternate syntax ":" instead of ":" then skip it.
78+
if (isset($tokens[$stackPtr]['scope_opener']) === true) {
79+
$openingBracePtr = $tokens[$stackPtr]['scope_opener'];
80+
if ($tokens[$openingBracePtr]['code'] === T_COLON) {
81+
return;
82+
}
83+
}
84+
7785
$prevContentPtr = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
7886

7987
// Skip if this T_IF is part of an else if.
@@ -136,6 +144,14 @@ public function process(File $phpcsFile, $stackPtr)
136144
$openingBracePtr = $tokens[$stackPtr]['scope_opener'];
137145
$braceLine = $tokens[$openingBracePtr]['line'];
138146

147+
// If this is alternate syntax ":" instead of ":" then skip it.
148+
if (isset($tokens[$stackPtr]['scope_opener']) === true) {
149+
$openingBracePtr = $tokens[$stackPtr]['scope_opener'];
150+
if ($tokens[$openingBracePtr]['code'] === T_COLON) {
151+
return;
152+
}
153+
}
154+
139155
if ($tokens[($stackPtr)]['code'] === T_ELSE
140156
|| $tokens[($stackPtr)]['code'] === T_TRY
141157
|| $tokens[($stackPtr)]['code'] === T_DO

Codeigniter4/ruleset.xml

Lines changed: 181 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,195 @@
77
* @author Louis Linehan <louis.linehan@gmail.com>
88
* @copyright 2017 Louis Linehan
99
* @license https://github.com/louisl/CodeIgniter4-Standard/blob/master/LICENSE MIT License
10+
* @version Version 1.0.0-beta0005
11+
-->
12+
<!--
13+
Tab width is 4 spaces (for phpcs)
1014
-->
1115
<arg name="tab-width" value="4"/>
16+
<!--
17+
Ignore /ThirdParty/ directory. There could be a mix of styles in here.
18+
-->
1219
<arg name="ignore" value="*/ThirdParty/*"/>
20+
<!--
21+
Files MUST use UTF-8 character set encoding without BOM
22+
-->
1323
<rule ref="Generic.Files.ByteOrderMark"/>
24+
<!--
25+
Files MUST NOT have the PHP closing tag '?>' at the as the last content.
26+
Files MUST END with a single empty line.
27+
-->
1428
<rule ref="PSR2.Files.EndFileNewline"/>
29+
<!--
30+
Disallow short php open tags "<?".
31+
-->
32+
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
33+
<!--
34+
Allow short php echo tags "<?=".
35+
-->
36+
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
37+
<severity>0</severity>
38+
</rule>
39+
<!--
40+
Files MUST have a File doc block comment.
41+
- Checks tag order, format and spacing.
42+
-->
1543
<rule ref="Generic.Commenting.DocComment"/>
44+
<!--
45+
Functions MUST have a doc block comment.
46+
- Checks tag order, format and spacing.
47+
-->
1648
<rule ref="PEAR.Commenting.FunctionComment"/>
49+
<!--
50+
Checks doc block alignment.
51+
-->
1752
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
53+
<!--
54+
Checks file doc block comment required tags, and order, format and spacing.
55+
-->
1856
<rule ref="CodeIgniter4.Commenting.FileComment">
1957
<properties>
2058
<property name="error" value="false"/>
2159
</properties>
2260
</rule>
61+
<!--
62+
Checks class doc block comment required tags, and order, format and spacing.
63+
-->
2364
<rule ref="CodeIgniter4.Commenting.ClassComment"/>
65+
<!--
66+
for
67+
Variables that have a comment.
68+
- Checks tag order, format and spacing.
69+
-->
2470
<rule ref="Squiz.Commenting.VariableComment">
2571
<properties>
2672
<property name="error" value="false"/>
2773
</properties>
2874
</rule>
75+
<!--
76+
User defined constants must be upper case.
77+
-->
2978
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
79+
<!--
80+
Boolean or "||" must be used. Not logical "or".
81+
-->
3082
<rule ref="CodeIgniter4.Operators.BooleanOr"/>
83+
<!--
84+
Boolean and "&&" must be used. Not logical "and".
85+
-->
3186
<rule ref="CodeIgniter4.Operators.BooleanAnd"/>
87+
<!--
88+
Boolean not "!" must have a space after.
89+
-->
3290
<rule ref="CodeIgniter4.WhiteSpace.BooleanNotSpaceAfter"/>
91+
<!--
92+
Is identical "===" must be used. Not is equal "==".
93+
-->
3394
<rule ref="CodeIgniter4.Operators.IsIdentical"/>
95+
<!--
96+
Is not identical "!==" must be used. Not is not equal "!=".
97+
-->
3498
<rule ref="CodeIgniter4.Operators.IsNotIdentical"/>
99+
<!--
100+
Warning for discouraged functions.
101+
error_log
102+
print_r
103+
var_dump
104+
last_query
105+
enable_profiler
106+
-->
35107
<rule ref="CodeIgniter4.PHP.DiscouragedFunctions"/>
36-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
37-
<properties>
38-
<property name="ignoreBlankLines" value="false"/>
39-
</properties>
40-
</rule>
41-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
42-
<severity>0</severity>
43-
</rule>
44-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
45-
<severity>0</severity>
46-
</rule>
47-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
48-
<severity>0</severity>
49-
</rule>
108+
<!--
109+
White space. (Unnecessary tabs, spaces and lines).
110+
There must not be white space at the start of the file.
111+
There must not be white space at the end of lines.
112+
There must not be white space on empty lines.
113+
There must not be white space at the start of the file.
114+
-->
115+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
116+
<!--
117+
There should be once class per file, execept for cases where
118+
breaking this rule makes more sense.
119+
-->
50120
<rule ref="CodeIgniter4.Files.OneClassPerFile"/>
121+
<!--
122+
Checks tabs are used for indenting scopes.
123+
-->
51124
<rule ref="Generic.WhiteSpace.ScopeIndent">
52125
<properties>
53126
<property name="tabIndent" value="true"/>
54127
</properties>
55128
</rule>
129+
<!--
130+
Checks tabs are used for indenting.
131+
-->
56132
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
133+
<!--
134+
Checks line endings are unix "\n".
135+
-->
57136
<rule ref="Generic.Files.LineEndings">
58137
<properties>
59138
<property name="eolChar" value="\n"/>
60139
</properties>
61140
</rule>
141+
<!--
142+
Checks opening function brace "{" is BsdAllman.
143+
-->
62144
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
145+
<!--
146+
Checks control structures are BsdAllman.
147+
-->
63148
<rule ref="CodeIgniter4.ControlStructures.AllmanControlSignature"/>
149+
<!--
150+
Checks control structures are spaced properly.
151+
-->
64152
<rule ref="CodeIgniter4.ControlStructures.ControlStructureSpacing"/>
153+
<!--
154+
Checks function arguments are spaced properly.
155+
-->
65156
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
157+
<!--
158+
Checks visibilty is declared for method scopes.
159+
-->
66160
<rule ref="Squiz.Scope.MethodScope"/>
161+
<!--
162+
Checks scope keywords are spaced properly.
163+
-->
67164
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
68-
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
165+
<!--
166+
Disallow multiple statements on one line.
167+
-->
69168
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
169+
<!--
170+
Use single quotes unless the string contains single quotes.
171+
-->
70172
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
173+
<!--
174+
Warning for lines exceeding 120 characters.
175+
-->
71176
<rule ref="Generic.Files.LineLength">
72177
<properties>
73178
<property name="lineLimit" value="120"/>
74179
<property name="absoluteLineLimit" value="0"/>
75180
</properties>
76181
</rule>
182+
<!--
183+
Checks function and method arguments with default values are at the
184+
end of the argument list.
185+
-->
77186
<rule ref="PEAR.Functions.ValidDefaultValue"/>
78-
<rule ref="CodeIgniter4.Functions.FunctionDeclaration"/>
187+
<!--
188+
Checks single and multi-line function declarations are styled properly.
189+
-->
190+
<rule ref="CodeIgniter4.Functions.FunctionDeclaration"/>
191+
<!--
192+
Checks arguments in functions are spaced properly.
193+
-->
79194
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
80195
<properties>
81196
<property name="equalsSpacing" value="1"/>
82197
</properties>
83198
</rule>
84-
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
85-
<severity>0</severity>
86-
</rule>
87199
<!--
88200
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
89201
<properties>
@@ -92,32 +204,81 @@
92204
</rule>
93205
@todo clash here.
94206
-->
207+
<!--
208+
Checks there are no blank lines after a function opening brace.
209+
-->
95210
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
211+
<!--
212+
Checks there are no blank lines before a function closing brace.
213+
-->
96214
<rule ref="CodeIgniter4.WhiteSpace.FunctionClosingBraceSpace">
97215
<properties>
98216
<property name="allowedLines" value="0" />
99217
</properties>
100218
</rule>
219+
<!--
220+
Checks for each declarations are styled properly.
221+
-->
101222
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
223+
<!--
224+
Checks for loop declarations are styled properly.
225+
-->
102226
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
227+
<!--
228+
Checks inline control structures and fixes with phpcbf.
229+
-->
103230
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
231+
<!--
232+
Warning for todo items.
233+
-->
104234
<rule ref="Generic.Commenting.Todo"/>
235+
<!--
236+
Check concatenation spacing and if needed.
237+
-->
105238
<rule ref="Squiz.Strings.ConcatenationSpacing">
106239
<properties>
107240
<property name="spacing" value="1"/>
108241
<property name="ignoreNewlines" value="true"/>
109242
</properties>
110243
</rule>
244+
<!--
245+
Check operator spacing.
246+
-->
111247
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
112248
<properties>
113249
<property name="ignoreNewlines" value="true"/>
114250
</properties>
115251
</rule>
252+
<!--
253+
Filename must match class if it contains one.
254+
-->
116255
<rule ref="CodeIgniter4.Files.FilenameMatchesClass"/>
256+
<!--
257+
Checks namespace declaration.
258+
-->
117259
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
260+
<!--
261+
Checks use declaration.
262+
-->
118263
<rule ref="PSR2.Namespaces.UseDeclaration"/>
264+
<!--
265+
Checks PHP keywords are lower case.
266+
-->
119267
<rule ref="Generic.PHP.LowerCaseKeyword"/>
268+
<!--
269+
PHP constants "true", "false" and "null" must be lower case.
270+
-->
120271
<rule ref="Generic.PHP.LowerCaseConstant"/>
272+
<!--
273+
Checks variable names
274+
private, protected _lowerCamelCase
275+
public lowerCamelCase
276+
-->
121277
<rule ref="Squiz.NamingConventions.ValidVariableName"/>
278+
<!--
279+
Checks method names
280+
private, protected _lowerCamelCase()
281+
public lowerCamelCase() except allowed public method names.
282+
-->
122283
<rule ref="CodeIgniter4.NamingConventions.ValidMethodName"/>
123-
</ruleset>
284+
</ruleset>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
CodeIgniter 4 Standard for [PHP_CodeSniffer 3](https://github.com/squizlabs/PHP_CodeSniffer).
44

5-
Version 1.0.0-beta0004
5+
Version 1.0.0-beta0005
66

77
This is currently a work in progress.
88

@@ -17,11 +17,11 @@ As this is a beta version you will need to add `"minimum-stability": "dev"` to y
1717

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

20-
`/Path/To/MyProject/vendor/louisl/CodeIgniter4-Standard/CodeIgniter4/ruleset.xml`
20+
`/Path/To/MyProject/vendor/louisl/codeigniter4-standard/CodeIgniter4/ruleset.xml`
2121

2222
### Download install
2323

24-
Download [CodeIgniter4-Standard](https://github.com/louisl/CodeIgniter4-Standard/archive/master.zip).
24+
Download [CodeIgniter4-Standard](https://github.com/louisl/CodeIgniter4-Standard/archive/v1.0.0-beta0005.zip).
2525

2626
Set `standard ` paths to your local filesystem:
2727

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "louisl/codeigniter4-standard",
33
"description": "CodeIgniter 4 Standard for PHP_CodeSniffer 3.",
4-
"version":"1.0.0-beta0004",
4+
"version":"1.0.0-beta0005",
55
"license":"MIT",
66
"authors": [
77
{
@@ -14,6 +14,6 @@
1414
"require": {
1515
},
1616
"require-dev": {
17-
"squizlabs/php_codesniffer": "~3.0"
17+
"squizlabs/php_codesniffer": "^3.0.0"
1818
}
1919
}

composer.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)