Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 32f885b

Browse files
committed
Merge branch 'feature/8' into develop
Close #8
2 parents e68f9f5 + 5209767 commit 32f885b

27 files changed

+492
-218
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.0.0-alpha.3 - TBD
6+
7+
### Added
8+
9+
- [#8](https://github.com/zendframework/zend-coding-standard/pull/8) adds some sniffs from webimpress/coding-standard.
10+
11+
- Forbid null values for class properties
12+
- Comments at the end of the line, with at least single space
13+
- Requires one space after namespace keyword
14+
- One space after break/continue with argument, remove redundant 1
15+
- Forbid continue in switch; use break instead
16+
- Require camelCase variable names
17+
- Detects for-loops that can be simplified to a while-loop
18+
- Detects unconditional if- and elseif-statements
19+
- Forbid goto instruction
20+
- Forbid multiple traits by declaration
21+
- Require lowercase function and const keywords in imports with one space after
22+
- Forbid superfluous leading backslash in use statements
23+
- Forbid whitespace around double colon operator
24+
- Forbid whitespace around double colon operator
25+
26+
### Changed
27+
28+
- [#8](https://github.com/zendframework/zend-coding-standard/pull/8) replaces sniffs in favor of webimpress/coding-standard as these are more reliable or fixes more cases.
29+
30+
### Deprecated
31+
32+
- Nothing.
33+
34+
### Removed
35+
36+
- Nothing.
37+
38+
### Fixed
39+
40+
- Nothing.
41+
542
## 2.0.0-alpha.2 - 2018-11-26
643

744
### Added

docs/book/v2/coding-style-guide.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Zend Framework Coding Style Guide
22

3-
This specification extends and expands [PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md),
4-
the extended coding style guide and requires adherence to [PSR-1](https://www.php-fig.org/psr/psr-1),
3+
This specification extends and expands [PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md),
4+
the extended coding style guide and requires adherence to [PSR-1](https://www.php-fig.org/psr/psr-1),
55
the basic coding standard.
66

7-
> Note: PSR-12 is not finalized. e.g. The `!` operator and `:` placement for return values are still under discussion.
7+
> Note: PSR-12 is not finalized. e.g. The `!` operator and `:` placement for return values are still under discussion.
88
We will change these rules, and, when PSR-12 is finalized, adapt them.
99

1010
## General
1111

1212
### Basic Coding Standard
1313

1414
Code MUST follow all rules outlined in [PSR-1](https://www.php-fig.org/psr/psr-1) and
15-
[PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md), except in
15+
[PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md), except in
1616
specific cases outlined in this specification, until PSR-12 is accepted as a standard.
1717

1818
### Indenting and Alignment
1919

20-
- There should be one space on either side of an equals sign used to assign a value to a variable. In case of a
20+
- There should be one space on either side of an equals sign used to assign a value to a variable. In case of a
2121
block of related assignments, more space may be inserted before the equal sign to promote readability.
2222
[*](ruleset.md#genericformattingmultiplestatementalignment)
2323

@@ -43,7 +43,7 @@ $array = [
4343
'key1' => 'value1',
4444
'key2' => 'value2',
4545
'keyTwenty' => 'value3',
46-
];
46+
];
4747

4848
$var = [
4949
'one' => function() {
@@ -72,13 +72,13 @@ $var = [
7272
- Comments may be omitted and should not be used for typehinted arguments.
7373
- Comments may not start with `#`. [*](ruleset.md#pearcommentinginlinecomment)
7474
- Comments may not be empty. [*](ruleset.md#slevomatcodingstandardcommentingemptycomment)
75-
- The words _private_, _protected_, _static_, _constructor_, _deconstructor_, _Created by_, _getter_ and _setter_,
75+
- The words _private_, _protected_, _static_, _constructor_, _deconstructor_, _Created by_, _getter_ and _setter_,
7676
may not be used in comments. [*](ruleset.md#slevomatcodingstandardcommentingforbiddencomments)
7777
- The annotations `@api`, `@author`, `@category`, `@created`, `@package`, `@subpackage` and `@version` may not
7878
be used in comments. Git commits provide accurate information. [*](ruleset.md#slevomatcodingstandardcommentingforbiddenannotations)
7979
- The asterisks in a doc comment should align, and there should be one space between the asterisk and tag.
8080
[*](ruleset.md#squizcommentingdoccommentalignment)
81-
- Comment tags `@param`, `@throws` and `@return` should not be aligned or contain multiple spaces between the tag,
81+
- Comment tags `@param`, `@throws` and `@return` should not be aligned or contain multiple spaces between the tag,
8282
type and description. [*](ruleset.md#squizcommentingfunctioncomment)
8383
- If a function throws any exceptions, they should be documented in `@throws` tags.
8484
[*](ruleset.md#squizcommentingfunctioncomment)
@@ -93,12 +93,12 @@ In addition to [PSR-12](https://github.com/php-fig/fig-standards/blob/master/pro
9393
- Each PHP file should have a page level docblock with `@see`, `@copyright` and `@license`. The copyright date should
9494
only be adjusted if the file has changed.
9595
- Each PHP file should have a strict type declaration at the top after the page level docblock. [*](ruleset.md#slevomatcodingstandardtypehintsdeclarestricttypes)
96-
- Import statements should be alphabetically sorted. [*](ruleset.md#slevomatcodingstandardnamespacesalphabeticallysorteduses)
96+
- Import statements should be alphabetically sorted. [*](ruleset.md#webimpresscodingstandardphpinstantiatingparenthesis)
9797
- Import statements should not be grouped. [*](ruleset.md#slevomatcodingstandardnamespacesdisallowgroupuse)
9898
- Each import statement should be on its own line. [*](ruleset.md#slevomatcodingstandardnamespacesmultipleusesperline)
9999
- Absolute class name references, functions and constants should be imported. [*](ruleset.md#slevomatcodingstandardnamespacesreferenceusednamesonly)
100-
- Unused import statements are not allowed. [*](ruleset.md#slevomatcodingstandardnamespacesunuseduses)
101-
- Classes and function within the same namespace should not be imported. [*](ruleset.md#slevomatcodingstandardnamespacesusefromsamenamespace)
100+
- Unused import statements are not allowed. [*](ruleset.md#webimpresscodingstandardnamespacesunusedusestatement)
101+
- Classes and function within the same namespace should not be imported. [*](ruleset.md#webimpresscodingstandardnamespacesunusedusestatement)
102102
- Imports should not have an alias with the same name. [*](ruleset.md#slevomatcodingstandardnamespacesuselessalias)
103103
- A class should not have unused private constants, (or write-only) properties and methods. [*](ruleset.md#slevomatcodingstandardclassesunusedprivateelements)
104104

@@ -137,10 +137,10 @@ class FooBar
137137

138138
In addition to [PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#4-classes-properties-and-methods):
139139

140-
- Class name resolution via `::class` should be used instead of `__CLASS__`, `get_class()`, `get_class($this)`,
140+
- Class name resolution via `::class` should be used instead of `__CLASS__`, `get_class()`, `get_class($this)`,
141141
`get_called_class()` and `get_parent_class()`. [*](ruleset.md#slevomatcodingstandardclassesmodernclassnamereference)
142142
- Methods may not have the final declaration in classes declared as final. [*](ruleset.md#genericcodeanalysisunnecessaryfinalmodifier)
143-
- The colon used with return type declarations MUST be surrounded with 1 space. [*](ruleset.md#slevomatcodingstandardtypehintsreturntypehintspacing)
143+
- The colon used with return type declarations MUST be surrounded with 1 space. [*](ruleset.md#webimpresscodingstandardformattingreturntype)
144144
- Nullable and optional arguments, which are marked as `= null`, must have the `?` symbol present. [*](ruleset.md#slevomatcodingstandardtypehintsnullabletypefornulldefaultvalue)
145145

146146
```php
@@ -158,16 +158,16 @@ class ClassName extends ParentClass implements ArrayAccess, Countable
158158
use FirstTrait;
159159
use SecondTrait;
160160
use ThirdTrait;
161-
161+
162162
public const CONSTANT = 'constant';
163-
163+
164164
private $property;
165-
165+
166166
public function fooBarBaz(int $arg1, &$arg2, array $arg3 = [], ?$arg4 = null) : void
167167
{
168168
return;
169169
}
170-
170+
171171
public function aVeryLongMethodName(
172172
FirstInterface $arg1,
173173
&$arg2,
@@ -367,7 +367,7 @@ $instance = new class extends Foo implements
367367
- Short list syntax `[...]` should be used instead of `list(...)`. [*](ruleset.md#slevomatcodingstandardphpshortlist)
368368
- Short form of type keywords must be used. i.e. `bool` instead of `boolean`, `int` instead of `integer`, etc.
369369
The `binary` and `unset` cast operators are not allowed. [*](ruleset.md#slevomatcodingstandardphptypecast)
370-
- Parentheses should not be used if they can be omitted. [*](ruleset.md#slevomatcodingstandardphpuselessparentheses)
370+
- Parentheses should not be used if they can be omitted. [*](ruleset.md#webimpresscodingstandardformattingunnecessaryparentheses)
371371
- Semicolons `;` should not be used if they can be omitted. [*](ruleset.md#slevomatcodingstandardphpuselesssemicolon)
372372
- Variables should be returned directly instead of assigned to a variable which is not used. [*](ruleset.md#slevomatcodingstandardvariablesuselessvariable)
373373
- The `self` keyword should be used instead of the current class name, and should not have spaces around `::`.
@@ -376,8 +376,8 @@ $instance = new class extends Foo implements
376376
- Double quote strings may only be used if they contain variables. [*](ruleset.md#squizstringsdoublequoteusage)
377377
- Strings should not be enclosed in parentheses when being echoed. [*](ruleset.md#squizstringsechoedstrings)
378378
- Type casts should not have whitespace inside the parentheses. [*](ruleset.md#squizwhitespacecastspacing)
379-
- The opening brace for functions should be on a new line with no blank lines surrounding it. [*](ruleset.md#squizwhitespacefunctionopeningbracespace)
380-
- The PHP constructs `echo`, `print`, `return`, `include`, `include_once`, `require`, `require_once`, and `new`, should
379+
- The opening brace for functions should be on a new line with no blank lines surrounding it. [*](ruleset.md#webimpresscodingstandardwhitespacebraceblankline)
380+
- The PHP constructs `echo`, `print`, `return`, `include`, `include_once`, `require`, `require_once`, and `new`, should
381381
have one space after them. [*](ruleset.md#squizwhitespacelanguageconstructspacing)
382382
- The object operator `->` should not have any spaces around it. [*](ruleset.md#squizwhitespaceobjectoperatorspacing)
383383
- Semicolons should not have spaces before them. [*](ruleset.md#squizwhitespacesemicolonspacing)

0 commit comments

Comments
 (0)