Skip to content

Commit a7cf51f

Browse files
authored
Merge pull request #1 from samdark/initial-draft
Initial draft
2 parents 8201676 + 9b401e6 commit a7cf51f

File tree

2 files changed

+179
-176
lines changed

2 files changed

+179
-176
lines changed

meta.md

+65-67
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
1-
Extended Coding Style Guide Meta Document
2-
=========================================
1+
# Coding Style Guide Meta Document
32

4-
# 1. Summary
3+
## 1. Summary
54

6-
This document describes the process and discussions that led to the Extended Coding
7-
Style PSR. Its goal is to explain the reasons behind each decision.
5+
This document describes the process and discussions that led to the Coding
6+
Style PER. Its goal is to explain the reasons behind each decision.
87

9-
# 2. Why Bother?
8+
## 2. Why Bother?
109

11-
PSR-2 was accepted in 2012 and since then a number of changes have been made to PHP,
12-
most notably recent changes for PHP 7, which have implications for coding style
13-
guidelines. Whilst PSR-2 is very comprehensive of PHP functionality that existed at
10+
PSR-12 was accepted in 2019 and since then a number of changes have been made to PHP,
11+
most notably recent changes for PHP 8 and PHP 8.1, which have implications for coding style
12+
guidelines. Whilst PSR-12 is very comprehensive of PHP functionality that existed at
1413
the time of writing, new functionality is very open to interpretation. PSR-12 seeks
1514
to provide a set way that both coding style tools can implement, projects can declare
1615
adherence to and developers can easily relate on between different projects for these
1716
coding style reducing cognitive friction.
1817

19-
PSR-2 was created based upon the common practices of the PHP-FIG projects at the time
20-
but ultimately this meant it was a compromise of many of the different projects' guidelines.
21-
The repercussions of projects changing their coding guidelines to align with PSR-2 (Almost
22-
all projects do align with PSR-1, even if it is not explicitly stated) were seen to be too
23-
great (losing git history, huge changesets and breaking existing patches/pull requests).
18+
PSR-12 was an update for PSR-2 which was created based upon the common practices of the PHP-FIG
19+
projects at the time but ultimately this meant it was a compromise of many of the different
20+
projects' guidelines. The repercussions of projects changing their coding guidelines to align
21+
with PSR-2 (Almost all projects do align with PSR-1, even if it is not explicitly stated) were
22+
seen to be too great (losing git history, huge changesets and breaking existing patches/pull requests).
2423

2524
PSR-2 required adopters to reformat large amounts of existing code which stifled adoption.
2625
To help alleviate this issue with PSR-12, we have taken a more prescriptive approach and
2726
defined the standards for new language features as they are released.
2827

29-
However it is for a lack of wanting to be dictatorial that we will aim to apply PSR-2
28+
However, it is for a lack of wanting to be dictatorial that we aimed to apply PSR-2
3029
styling, rationale and stances (Described in Section 4, Approaches) in PSR-12 instead of
3130
establishing new conventions.
3231

33-
# 3. Scope
32+
The same approach is applied to the current PER.
3433

35-
## 3.1. Goals
34+
## 3. Scope
3635

37-
This PSR shares the same goals as PSR-2.
36+
### 3.1. Goals
37+
38+
This PER shares the same goals as PSR-12.
3839

3940
> The intent of this guide is to reduce cognitive friction when scanning code from
4041
> different authors. It does so by enumerating a shared set of rules and expectations
@@ -43,53 +44,52 @@ This PSR shares the same goals as PSR-2.
4344
> of guidelines to be used among all those projects. Thus, the benefit of this guide is
4445
> not in the rules themselves, but in the sharing of those rules.
4546
46-
This PSR is an extension of PSR-2, and therefore also an extension of PSR-1. The basis of
47-
PSR-12 is PSR-2 and therefore a list of differences is provided below to assist with migration
47+
This PER is an extension of PSR-12, and therefore also an extension of PSR-1. The basis of PER is
48+
PSR-12 and therefore a list of differences is provided below to assist with migration,
4849
but it should be considered as an independent specification.
4950

50-
This PSR will include coding style guidelines related to new functionality added to PHP
51-
after the publication of PSR-2; this includes PHP 5.5, PHP 5.6 and PHP 7.0. This PSR will
52-
also include clarifications on the text of PSR-2, as described in the PSR-2 Errata.
51+
This PER will include coding style guidelines related to new functionality added to PHP
52+
after the publication of PSR-12. This PER will also include clarifications on the text of
53+
PSR-12.
5354

54-
## 3.2. Non-Goals
55+
### 3.2. Non-Goals
5556

56-
It is not the intention of this PSR to add entirely new coding style guidelines. PSR-12 will
57-
also not change anything stipulated in PSR-1 and PSR-2.
57+
It is not the intention of this PER to add entirely new coding style guidelines. It will
58+
also not change anything stipulated in PSR-1 and PSR-12.
5859

59-
# 4. Approaches
60+
## 4. Approaches
6061

61-
The overarching approach is to attempt to apply existing PSR-2 styling and rationale to
62+
The overarching approach is to attempt to apply existing PSR-12 styling and rationale to
6263
new functionality as opposed to establishing new conventions.
6364

64-
## 4.1. Strict Types Declarations
65+
### 4.1. Strict Types Declarations
6566

66-
There was a discussion about whether or not strict types should be enforced in the standard
67+
There was a discussion about whether strict types should be enforced in the standard
6768
https://github.com/cs-extended/fig-standards/issues/7. All were in agreement we should only
6869
use a MUST or MUST NOT statement and avoid the use of a SHOULD statement and nobody wanted
6970
to say that strict types could not be declared. The discussion was whether it should be
70-
considered a coding style item which should be covered or whether it was out of scope and it
71+
considered a coding style item which should be covered or whether it was out of scope, and it
7172
was decided to be out of scope of a coding style guide.
7273

73-
## 4.2. Finally and Return Types Declaration Spacing
74+
### 4.2. Finally and Return Types Declaration Spacing
7475

75-
Numerous different options were suggested and they can be seen
76+
Numerous options were suggested, and they can be seen
7677
[here for return type declarations](https://gist.github.com/michaelcullum/c025f3870c9ea1dd2668#file-returntypesspacing-php) or
7778
[here for finally blocks](https://gist.github.com/michaelcullum/c025f3870c9ea1dd2668#file-finallyblocks-php)
78-
and the current implementation was chosen due to consistency with other parts of the PSR-12
79-
specification that came from PSR-2.
79+
and the current implementation was chosen due to consistency with other parts of the standard.
8080

81-
## 4.3. Enforcing short form for all type keywords
81+
### 4.3. Enforcing short form for all type keywords
8282

8383
PHP 7.0 introduced [scalar types declaration](http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration)
84-
which does not support long type aliases. Therefore it makes sense to enforce primary short type forms to be used to
84+
which does not support long type aliases. Therefore, it makes sense to enforce primary short type forms to be used to
8585
have uniform syntax and prevent possible confusion.
8686

87-
## 4.4. Public Survey
87+
### 4.4. Public Survey
8888

8989
In order to settle things using data, survey was conducted and responses from 142 people
9090
including 17 project representatives were gathered:
9191

92-
### 4.4.1. PHP-FIG Representative Results
92+
#### 4.4.1. PHP-FIG Representative Results
9393

9494
| 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 |
9595
| -------------- | ------- | ---------------------------------------------------- | ---------------------------------- | ----------------------------------------- | ------------------------------------------- | -------------------------------------------------------- | ------------------------------- | ------------------------------------- |------------------------------- |------------------------------------ | ----------------------------------- | ---------------------- |--------------------------- | ----------------------------------- | --------------------------- | -------------------------- |
@@ -111,7 +111,7 @@ including 17 project representatives were gathered:
111111
| Chuck Burgess | PEAR ||||||||||||||||
112112
| | **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|
113113

114-
### 4.4.2. General non-representative voters
114+
#### 4.4.2. General non-representative voters
115115

116116
| Question | For | Against | Percentage For |
117117
| -------- | --- | ------- | -------------- |
@@ -131,22 +131,22 @@ including 17 project representatives were gathered:
131131
| Keyword casing, only lower case | 124 | 2 | 98.39% |
132132
| Type keywords, short form only | 121 | 5 | 95.87% |
133133

134-
## 4.5. Multiline Function Arguments Mixed With Multiline Return
134+
### 4.5. Multiline Function Arguments Mixed With Multiline Return
135135

136136
A potential readability issue [was raised on the mailing list](https://groups.google.com/d/msg/php-fig/ULSL4gqK8GY/cgDELuPOCQAJ).
137137
We reviewed options for changes to the specification that could provide better readability and
138138
the floated option was to require a blank line after the opening bracket of a function if the
139-
arguments and the return are both multiline. Instead it was pointed out that this specification
140-
_already_ allows you to decide where you'd like to add blank lines and so we will leave it to
139+
arguments and the return are both multiline. Instead, it was pointed out that this specification
140+
_already_ allows you to decide where you'd like to add blank lines, and so we will leave it to
141141
the implementors to decide.
142142

143-
# 5. Changelog from PSR-2
143+
## 5. Changelog
144144

145-
Please note this changelog is not a verbose list of changes from PSR-2 but highlights the most
146-
notable changes. It should be considered a new specification and therefore you should read the
145+
Please note this changelog is not a verbose list of changes from PSR-12 and further but highlights the most
146+
notable changes. It should be considered a new specification, and therefore you should read the
147147
specification for a full understanding of its contents.
148148

149-
## 5.1. New Statements
149+
### 5.1. New Statements
150150

151151
* Lowercase for all keywords - Section 2.5
152152
* Short form for all type keywords - Section 2.5
@@ -165,7 +165,7 @@ specification for a full understanding of its contents.
165165
* Ternary operators - Section 6.3
166166
* Anonymous classes - Section 8
167167

168-
## 5.2. Clarifications and Errata
168+
### 5.2. Clarifications and Errata
169169

170170
* Adjust 'methods' to 'methods and functions' in a number of instances - Throughout
171171
* Adjust references to classes and interfaces to also include traits - Throughout
@@ -176,36 +176,34 @@ specification for a full understanding of its contents.
176176
* PSR-2 errata statement about extending multiple interfaces - Section 4
177177
* Forbid blank lines before/after closing/opening braces for classes - Section 4
178178

179-
# 6. People
179+
## 6. People
180+
181+
### 6.1. Editor:
180182

181-
## 6.1. Editor:
182-
* Korvin Szanto
183+
* Alexander Makarov
183184

184-
## 6.2. Sponsor:
185+
### 6.2. Sponsor:
185186

186-
* Chris Tankersley
187+
*
187188

188-
## 6.3. Working Group Members:
189+
### 6.3. Working Group Members:
189190

190-
* Alessandro Lai
191191
* Alexander Makarov
192-
* Michael Cullum
193-
* Robert Deutz
192+
*
193+
*
194+
*
194195

195-
## 6.4. Special Thanks
196+
### 6.4. Special Thanks
196197

197-
* Michael Cullum for drafting the original specification
198-
* Alexandar Makarov for coordinating the draft during PHP-FIG 2.0
199-
* Cees-Jan Kiewiet for moral support
198+
* Everyone involved in PSR-1, PSR-2, PSR-12.
200199

201-
# 7. Votes
200+
## 7. Votes
202201

203-
* **Entrance Vote:** https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/php-fig/P9atZLOcUBM/_jwkvlYKEAAJ
204-
* **Approval Vote:** https://groups.google.com/forum/#!topic/php-fig/1uaeSMaDGbk
202+
* **Entrance Vote:**
203+
* **Approval Vote:**
205204

206-
# 8. Relevant Links
205+
## 8. Relevant Links
207206

208207
_**Note:** Order descending chronologically._
209208

210-
* [Inspiration Mailing List Thread](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/php-fig/wh9avopSR9k)
211-
* [Initial Mailing List PSR Proposal Thread](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/php-fig/MkFacLdfGso)
209+
*

0 commit comments

Comments
 (0)