- Notifications
You must be signed in to change notification settings - Fork 28
Add migration document re differences between PER-CS v1.0 and PER-CS v2.0 #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
36 commits Select commit Hold shift + click to select a range
a6ff325 Some initial notes re differences between PSR12 and PERCSv2.0
kenguest 3ccb609 Rename
kenguest 9aed798 Rename
kenguest aaf2b42 Improve markup
kenguest 91819f2 Fix markup for sections on short closures and enums
kenguest 3b29740 Tidy up
kenguest 5cd50f2 Add link to autogenerated changelog
kenguest 209c586 Call this a migration document
kenguest 2734f41 Additional changes as suggested by Crell
kenguest 3635c2e Remove unnecessary empty line
kenguest feb4e9d Remove text from previous PSRs that are not new to PER-CS v2
kenguest 05a0748 Method chaining
kenguest 7aa1183 file name - drop the version being migrated from
kenguest 6fbc900 Oxford comma...
kenguest e116298 Update migration-2.0.md
kenguest e354506 Update migration-2.0.md
kenguest 40f0c37 Update migration-2.0.md
kenguest 2960dec Update migration-2.0.md
kenguest e0baa66 Update migration-2.0.md
kenguest 303fcb7 Update migration-2.0.md
kenguest ea0002e Update migration-2.0.md
kenguest 838bcad Update migration-2.0.md
kenguest d1490b4 Update migration-2.0.md
kenguest 50e058a Consistency
kenguest 6e92d9b Update migration-2.0.md
kenguest 62f4377 Update migration-2.0.md
kenguest a90e814 Update migration-2.0.md
kenguest 4c160bd Apply suggestions from review
kenguest fae5c1e Update migration-2.0.md
kenguest 62e3123 More concise, with examples.
kenguest 9a4d7e2 Syntax highlighting for example php code
kenguest a217170 Fix syntax re syntax highlighting
kenguest c789b06 Syntax highlighting for example php code
kenguest 3dff722 Add some more examples.
kenguest f7b112c Forgot closing syntax markers
kenguest 4ec7bb5 Add some more examples.
kenguest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,196 @@ | ||||||
| # Migrating from PER-CS v1.0 (PSR-12) to PER-CS v2.0 ### | ||||||
| | ||||||
| ## Summary | ||||||
| | ||||||
| PER-CS is the next evolution of the PSR set of Coding Standards from the | ||||||
| PHP-FIG (Framework Interoperability Group). It extends the Coding Standards | ||||||
| laid out in PSR-12 to the newest functionality added to PHP such as the match | ||||||
| keyword, enums, attributes, and more. | ||||||
| | ||||||
| This document describes the changes and additions on a section by section | ||||||
| basis between PER-CS v2.0 and PER-CS v1.0 (which is a direct equivalent of | ||||||
| PSR12 with very minor changes). | ||||||
| | ||||||
| It is derived in part from [a GitHub-generated changelog](https://github.com/php-fig/per-coding-style/compare/1.0.0...2.0.0) | ||||||
| and focuses on the changes on a section-by-section basis as its focus is to be more readable. | ||||||
| | ||||||
| This document intends to provide a summary of these changes that can | ||||||
| then be used to drive action lists for toolset producers to support PER-CS v2.0. | ||||||
| | ||||||
| This document is non-normative. The published [2.0 PER-CS](https://www.php-fig.org/per/coding-style/) specification | ||||||
| is the canonical source for the PER-CS formatting expectations. | ||||||
| | ||||||
| ## [Section 2.6 - Trailing Commas](https://www.php-fig.org/per/coding-style/#26-trailing-commas) | ||||||
| | ||||||
| Numerous constructs now allow a sequence of values to have an optional trailing | ||||||
| comma: | ||||||
| * If the final item is on the same line then there MUST NOT be a trailing comma | ||||||
| * If the final item is not on the same line then there MUST be a trailing comma | ||||||
| | ||||||
| ## [Section 4.4 - Methods and Functions](https://www.php-fig.org/per/coding-style/#44-methods-and-functions) | ||||||
| | ||||||
| If a function or method contains no statements or comments (such as an empty | ||||||
| no-op implementation or when using constructor property promotion), then the | ||||||
| body SHOULD be abbreviated as {} and placed on the same line as the previous | ||||||
| symbol, separated by a space. | ||||||
| So, for a method of a subclass that does nothing: | ||||||
| | ||||||
| <?php | ||||||
| class SubClass extends BaseClass | ||||||
| { | ||||||
| protected function init() {} | ||||||
| } | ||||||
| | ||||||
| ## [Section 4.6 - Modifier Keywords](https://www.php-fig.org/per/coding-style/#46-modifier-keywords) | ||||||
| | ||||||
| Modifier keywords are keywords that alter how PHP handles classes, | ||||||
| properties and methods. | ||||||
| | ||||||
| These keywords MUST BE ordered as follows: | ||||||
| | ||||||
| [abstract|final] [public|protected|private] [static] [readonly] | ||||||
| [type] name | ||||||
| | ||||||
| Furthermore all keywords must be on a single line and MUST be separated | ||||||
kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||
| by a single space. | ||||||
| | ||||||
| ## [Section 4.7 - Method and Function Calls](https://www.php-fig.org/per/coding-style/#47-method-and-function-calls) | ||||||
| | ||||||
| If using named arguments, there MUST NOT be a space between the argument name and colon, | ||||||
kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved | ||||||
| and there MUST be a single space between the colon and the argument value. | ||||||
| | ||||||
| Method chaining MAY be put on separate lines, where each subsequent line is indented once. When doing so, the first method MUST be on the next line. | ||||||
kenguest marked this conversation as resolved. Show resolved Hide resolved | ||||||
| | ||||||
| ## [Section 4.8 - Function Callable References](https://www.php-fig.org/per/coding-style/#48-function-callable-references) | ||||||
| | ||||||
| Function callable references - there must not be whitespace surrounding the '...' operator () | ||||||
| | ||||||
| ## [Section 5.2 - Switch, Case, Match](https://www.php-fig.org/per/coding-style/#52-switch-case-match) | ||||||
| | ||||||
| The match keyword is now covered. | ||||||
kenguest marked this conversation as resolved. Show resolved Hide resolved | ||||||
| | ||||||
| ## [Section 7.1 - Short Closures](https://www.php-fig.org/per/coding-style/#71-short-closures) | ||||||
| | ||||||
| A new subsection about Short Closures. | ||||||
| | ||||||
| As with standard closures, 'fn' must not be succeeded by a space. | ||||||
| The '=>' symbol MUST be preceeded and succeeded by a space. (No leading or trailing spaces) | ||||||
| ||||||
| The '=>' symbol MUST be preceeded and succeeded by a space. (No leading or trailing spaces) | |
| The '=>' symbol MUST be preceded and succeeded by a space. (No leading or trailing spaces) |
kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved
kenguest marked this conversation as resolved.
Outdated Show resolved Hide resolved kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved
kenguest marked this conversation as resolved.
Outdated Show resolved Hide resolved kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved
kenguest marked this conversation as resolved.
Outdated Show resolved Hide resolved kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved
kenguest marked this conversation as resolved.
Outdated Show resolved Hide resolved kenguest marked this conversation as resolved. Outdated Show resolved Hide resolved
kenguest marked this conversation as resolved.
Outdated Show resolved Hide resolved Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.