@@ -26,7 +26,7 @@ To help alleviate this issue with PSR-12, we have taken a more prescriptive appr
26
26
defined the standards for new language features as they are released.
27
27
28
28
However, it is for a lack of wanting to be dictatorial that we aimed to apply PSR-2
29
- styling, rationale and stances (Described in Section 4 , Approaches) in PSR-12 instead of
29
+ styling, rationale and stances (Described in Section 5 , Approaches) in PSR-12 instead of
30
30
establishing new conventions.
31
31
32
32
The same approach is applied to the current PER.
@@ -57,12 +57,42 @@ PSR-12.
57
57
It is not the intention of this PER to add entirely new coding style guidelines. It will
58
58
also not change anything stipulated in PSR-1 and PSR-12.
59
59
60
- ## 4. Approaches
60
+ ## 4. Versioning
61
+
62
+ New releases of this PER are assigned version numbers in keeping with [ semantic versioning] ( https://semver.org/ ) .
63
+ Semantic versioning is well defined when applied to software releases but has no common definition in other contexts.
64
+ This PER applies the following meanings:
65
+
66
+ * ** Patch** versions may contain:
67
+ * Any changes that do not alter the underlying requirements of this PER, such as fixing typos, adding clarifications or
68
+ other modifications with no compatibility impact.
69
+ * ** Minor** versions may additionally:
70
+ * Add new requirements for PHP syntax previously unspecified in this PER.
71
+ * Add, remove or alter requirements in a way that is both more permissive and backwards compatible for implementers.
72
+ * ** Major** versions may additionally:
73
+ * Add, remove or alter any requirements.
74
+
75
+ Projects are expected to pin their own coding style guidelines to a major version of this PER, allowing for regular
76
+ upgrades to minor and patch releases as they are published. When performing such upgrades, it is intended that no change
77
+ to existing code is required to maintain compliance with all requirements and recommendations of this PER. This ensures
78
+ new code contributions processed by an automatic formatter follow (or disregard) recommendations consistently with the
79
+ existing code.
80
+
81
+ Please note this backwards compatibility promise does not extend to projects that use new PHP syntax yet to be specified
82
+ in this PER. In this circumstance, a minor version may introduce new requirements that are effectively breaking changes.
83
+
84
+ It is ultimately determined whether a meaningful change may be included in a minor release on a case-by-case basis by
85
+ consensus. The addition of ` MAY ` or ` OPTIONAL ` requirements or the removal of requirements with non-optional RFC 2119
86
+ keywords will not always meet the criteria for minor release. For example, specifying that projects may use tabs instead
87
+ of spaces for indentation creates a new implicit requirement that projects must use one style consistently; this new
88
+ burden on projects to reformat incoming contributions to their chosen style defines the change as major.
89
+
90
+ ## 5. Approaches
61
91
62
92
The overarching approach is to attempt to apply existing PSR-12 styling and rationale to
63
93
new functionality as opposed to establishing new conventions.
64
94
65
- ### 4 .1. Strict Types Declarations
95
+ ### 5 .1. Strict Types Declarations
66
96
67
97
There was a discussion about whether strict types should be enforced in the standard
68
98
https://github.com/cs-extended/fig-standards/issues/7 . All were in agreement we should only
@@ -71,25 +101,25 @@ to say that strict types could not be declared. The discussion was whether it sh
71
101
considered a coding style item which should be covered or whether it was out of scope, and it
72
102
was decided to be out of scope of a coding style guide.
73
103
74
- ### 4 .2. Finally and Return Types Declaration Spacing
104
+ ### 5 .2. Finally and Return Types Declaration Spacing
75
105
76
106
Numerous options were suggested, and they can be seen
77
107
[ here for return type declarations] ( https://gist.github.com/michaelcullum/c025f3870c9ea1dd2668#file-returntypesspacing-php ) or
78
108
[ here for finally blocks] ( https://gist.github.com/michaelcullum/c025f3870c9ea1dd2668#file-finallyblocks-php )
79
109
and the current implementation was chosen due to consistency with other parts of the standard.
80
110
81
- ### 4 .3. Enforcing short form for all type keywords
111
+ ### 5 .3. Enforcing short form for all type keywords
82
112
83
113
PHP 7.0 introduced [ scalar types declaration] ( http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration )
84
114
which does not support long type aliases. Therefore, it makes sense to enforce primary short type forms to be used to
85
115
have uniform syntax and prevent possible confusion.
86
116
87
- ### 4 .4. Public Survey
117
+ ### 5 .4. Public Survey
88
118
89
119
In order to settle things using data, survey was conducted and responses from 142 people
90
120
including 17 project representatives were gathered:
91
121
92
- #### 4 .4.1. PHP-FIG Representative Results
122
+ #### 5 .4.1. PHP-FIG Representative Results
93
123
94
124
| Representative | Project | Compound namespaces with a depth of two or more MUST not be used | Header statement grouping and ordering | Declare statements must each be on their own line | Declare statements in PHP files containing markup | Declare statements have no spaces: ` declare(strict_types=1); ` | Block declare statement formatting | ` new ` keyword usage, parenthesis required | Return type declaration formatting | Use statement leading slashes disallowed | Block namespace declaration formatting | General operator spacing | Try, Catch, Finally formatting | Anonymous class declaration formatting | Keyword casing, only lower case | Type keywords, short form only |
95
125
| -------------- | ------- | ---------------------------------------------------- | ---------------------------------- | ----------------------------------------- | ------------------------------------------- | -------------------------------------------------------- | ------------------------------- | ------------------------------------- | ------------------------------- | ------------------------------------ | ----------------------------------- | ---------------------- | --------------------------- | ----------------------------------- | --------------------------- | -------------------------- |
@@ -111,7 +141,7 @@ including 17 project representatives were gathered:
111
141
| Chuck Burgess | PEAR | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
112
142
| | ** Totals** : | 13/3| 15/1| 15/1| 13/3| 14/2| 15/1| 14/2| 15/1| 14/2| 14/2| 15/1| 16/0| 15/1| 15/1| 15/1|
113
143
114
- #### 4 .4.2. General non-representative voters
144
+ #### 5 .4.2. General non-representative voters
115
145
116
146
| Question | For | Against | Percentage For |
117
147
| -------- | --- | ------- | -------------- |
@@ -131,7 +161,7 @@ including 17 project representatives were gathered:
131
161
| Keyword casing, only lower case | 124 | 2 | 98.39% |
132
162
| Type keywords, short form only | 121 | 5 | 95.87% |
133
163
134
- ### 4 .5. Multiline Function Arguments Mixed With Multiline Return
164
+ ### 5 .5. Multiline Function Arguments Mixed With Multiline Return
135
165
136
166
A potential readability issue [ was raised on the mailing list] ( https://groups.google.com/d/msg/php-fig/ULSL4gqK8GY/cgDELuPOCQAJ ) .
137
167
We reviewed options for changes to the specification that could provide better readability and
@@ -140,13 +170,13 @@ arguments and the return are both multiline. Instead, it was pointed out that th
140
170
_ already_ allows you to decide where you'd like to add blank lines, and so we will leave it to
141
171
the implementors to decide.
142
172
143
- ## 5 . Changelog
173
+ ## 6 . Changelog
144
174
145
175
Please note this changelog is not a verbose list of changes from PSR-12 and further but highlights the most
146
176
notable changes. It should be considered a new specification, and therefore you should read the
147
177
specification for a full understanding of its contents.
148
178
149
- ### 5 .1. New Statements
179
+ ### 6 .1. New Statements
150
180
151
181
* Lowercase for all keywords - Section 2.5
152
182
* Short form for all type keywords - Section 2.5
@@ -165,7 +195,7 @@ specification for a full understanding of its contents.
165
195
* Ternary operators - Section 6.3
166
196
* Anonymous classes - Section 8
167
197
168
- ### 5 .2. Clarifications and Errata
198
+ ### 6 .2. Clarifications and Errata
169
199
170
200
* Adjust 'methods' to 'methods and functions' in a number of instances - Throughout
171
201
* Adjust references to classes and interfaces to also include traits - Throughout
@@ -176,33 +206,33 @@ specification for a full understanding of its contents.
176
206
* PSR-2 errata statement about extending multiple interfaces - Section 4
177
207
* Forbid blank lines before/after closing/opening braces for classes - Section 4
178
208
179
- ## 6 . People
209
+ ## 7 . People
180
210
181
- ### 6 .1. Editor:
211
+ ### 7 .1. Editor:
182
212
183
213
* Korvin Szanto
184
214
185
- ### 6 .2. Sponsor:
215
+ ### 7 .2. Sponsor:
186
216
187
217
* Chris Tankersley
188
218
189
- ### 6 .3. Working Group Members:
219
+ ### 7 .3. Working Group Members:
190
220
191
221
* Alexander Makarov
192
222
* Ken Guest
193
223
* Larry Garfield
194
224
* Luke Diggins
195
225
* Woody Gilk
196
226
197
- ### 6 .4. Special Thanks
227
+ ### 7 .4. Special Thanks
198
228
199
229
* Everyone involved in PSR-1, PSR-2, PSR-12.
200
230
201
- ## 7 . Votes
231
+ ## 8 . Votes
202
232
203
233
* ** Entrance Vote:** https://groups.google.com/g/php-fig/c/YqPDYGK0RhM/m/pJmThkNKBgAJ
204
234
205
- ## 8 . Relevant Links
235
+ ## 9 . Relevant Links
206
236
207
237
_ ** Note:** Order descending chronologically._
208
238
0 commit comments