This repository was archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Zend Coding Standard 2 #5
Closed
Closed
Changes from 11 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
dbacd12
Import strict ruleset
geerteltink 5863c14
Allow functions inside functions
geerteltink 06a5606
Allow @var for constants
geerteltink d27454d
Allow @since for noting API additions
geerteltink 646eea1
Allow fancy yoda conditions as a defensive programming approach
geerteltink fa193f3
Forbid short open tag, but allow short echo tags for use in templates
geerteltink f1cef3f
Add documentation structure
geerteltink 911065a
Use xmllint to validate against schema
geerteltink 365acdf
Remove copyright in mkdocs config as it's not being used anymore
geerteltink b3146a6
Remove index.html because it's generated by the theme
geerteltink 5c86655
Disable phpunit tests until there is something to test
geerteltink ce7ae4a
Use PSR-12 compatible imports
geerteltink 3f602fa
Add rules to documentation
geerteltink 39ba67a
Add some test cases
geerteltink e9d9a2d
Update docs for alias functions
geerteltink 2d29543
Document the new way to ignore parts of a file phpcs:enable phpcs:dis…
geerteltink 2397775
Don't allow fully qualified classes from global space
geerteltink a063051
Add useful tests
geerteltink 29b05a0
Fix typo in ci script
geerteltink d35d34e
Don't remove xdebug as php nightly doesn't have it
geerteltink b4d915d
Test expected violations for fixable code
geerteltink 45d14bd
Require ? when default value is null
geerteltink 5b00974
Improve documentation formatting
geerteltink dc11e2e
Add PSR-12 test cases
geerteltink 6dc1801
Update concatenation spacing test
geerteltink c7718be
Update expected phpcs report
geerteltink 7367ecd
Improve concatenation tests
geerteltink a88527c
Add phpcs cache for speed improvement
geerteltink c15e28e
Document the coding standard and all rules
geerteltink d044763
First set of documentation improvements and fixes
geerteltink f722edd
More grammar fixes
geerteltink ba703a4
Reorder rules and disable double rules
geerteltink 2702288
Add missing rule: Class name resolution via ::class
geerteltink b9509c8
Add coding-style-guide to mkdocs config
geerteltink 4da5772
Add changelog for #5
geerteltink 9737c95
Improve wording and add example for Generic.Classes.DuplicateClassName
geerteltink 7ea79cc
It's raining outside, so more examples and improved formatting
geerteltink 70b63af
Update phpcs config in readme
geerteltink f93740b
Update array indentation test
geerteltink c531490
Don't align equal statements, double arrow arrays or phpdoc comment tags
geerteltink aba1c3a
Remove early exit rule as it is overly aggressive when "fixing" the code
geerteltink a276b18
Add references
geerteltink bf0d951
Update changelog with latest changes
geerteltink 3386b02
Update intro and readme
geerteltink 300e613
Fix creation of double trailing commas on specific arrays
geerteltink 61f3bc5
PSR-12: Force Unix LF (linefeed) line ending
geerteltink ea3de20
Allow global functions
geerteltink 53a7dcd
Align comments, statements and arrays
geerteltink 850f481
Align array double arrows
geerteltink 5eaa798
Validate fixes before running tests
geerteltink 41d35b9
Fix single arrow indention test
geerteltink 3974380
Reset array alignment and start from scratch
geerteltink 137dc8a
Update slevomat/coding-standard requirement and add regression test for
geerteltink 61f6b4b
Add test for constant aligning
geerteltink 5f2280d
Align double arrows in multiline arrays
geerteltink a3d45d7
Update expected errors report
geerteltink 27b735f
Require php_codesniffer 3.3.2
geerteltink 95213b5
Update array indentation tests
geerteltink 38a2dea
Use new format to declare array properties
geerteltink 7dc2f78
Update phpcs report
geerteltink 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,10 @@ | ||
/clover.xml | ||
/composer.lock | ||
/coveralls-upload.json | ||
/docs/html/ | ||
/phpcs.log | ||
/phpcs.xml | ||
/phpunit.xml | ||
/vendor/ | ||
/zf-mkdoc-theme.tgz | ||
/zf-mkdoc-theme/ |
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,36 @@ | ||
dist: trusty | ||
sudo: false | ||
language: php | ||
|
||
php: | ||
- 7.1 | ||
- 7.2 | ||
- nightly | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
before_install: | ||
- phpenv config-rm xdebug.ini | ||
- composer self-update | ||
|
||
install: travis_retry composer update --prefer-dist | ||
|
||
stages: | ||
- Validate against schema | ||
|
||
jobs: | ||
allow_failures: | ||
- php: nightly | ||
|
||
include: | ||
- stage: Validate against schema | ||
addons: | ||
apt: | ||
packages: | ||
- libxml2-utils | ||
script: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd src/ZendCodingStandard/ruleset.xml | ||
|
||
notifications: | ||
email: false |
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
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
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 |
---|---|---|
@@ -1,12 +1,35 @@ | ||
{ | ||
"name": "zendframework/zend-coding-standard", | ||
"description": "Zend Framework coding standard", | ||
"type": "phpcodesniffer-standard", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm so happy that composer has made things like plugin registration automated via package |
||
"description": "Zend Framework Coding Standard", | ||
"license": "BSD-3-Clause", | ||
"keywords": [ | ||
"zf", | ||
"zendframework", | ||
"coding standard" | ||
], | ||
"support": { | ||
"docs": "https://docs.zendframework.com/zend-coding-standard/", | ||
"issues": "https://github.com/zendframework/zend-coding-standard/issues", | ||
"source": "https://github.com/zendframework/zend-coding-standard", | ||
"rss": "https://github.com/zendframework/zend-coding-standard/releases.atom", | ||
"chat": "https://zendframework-slack.herokuapp.com", | ||
"forum": "https://discourse.zendframework.com/c/questions/components" | ||
}, | ||
"require": { | ||
"squizlabs/php_codesniffer": "^2.7" | ||
"php": "^7.1", | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", | ||
"slevomat/coding-standard": "^4.7.3", | ||
"squizlabs/php_codesniffer": "^3.3.1" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "2.0.x-dev" | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"ZendCodingStandard\\Sniffs\\": "src/ZendCodingStandard/Sniffs" | ||
} | ||
} | ||
} |
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
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,189 @@ | ||
# CONTRIBUTING | ||
|
||
## RESOURCES | ||
|
||
If you wish to contribute to this project, please be sure to | ||
read/subscribe to the following resources: | ||
|
||
- [Coding Standards](https://github.com/zendframework/zend-coding-standard) | ||
- [Forums](https://discourse.zendframework.com/c/contributors) | ||
- [Chat](https://zendframework-slack.herokuapp.com) | ||
- [Code of Conduct](CODE_OF_CONDUCT.md) | ||
|
||
If you are working on new features or refactoring | ||
[create a proposal](https://github.com/zendframework/zend-coding-standard/issues/new). | ||
|
||
## RUNNING TESTS | ||
|
||
To run tests: | ||
|
||
- Clone the repository: | ||
|
||
```console | ||
$ git clone git://github.com/zendframework/zend-coding-standard.git | ||
$ cd zend-coding-standard | ||
``` | ||
|
||
- Install dependencies via composer: | ||
|
||
```console | ||
$ composer install | ||
``` | ||
|
||
If you don't have `composer` installed, please download it from https://getcomposer.org/download/ | ||
|
||
- Run the tests using the "test" command shipped in the `composer.json`: | ||
|
||
```console | ||
$ composer test | ||
``` | ||
|
||
You can turn on conditional tests with the `phpunit.xml` file. | ||
To do so: | ||
|
||
- Copy `phpunit.xml.dist` file to `phpunit.xml` | ||
- Edit `phpunit.xml` to enable any specific functionality you | ||
want to test, as well as to provide test values to utilize. | ||
|
||
## Running Coding Standards Checks | ||
|
||
First, ensure you've installed dependencies via composer, per the previous | ||
section on running tests. | ||
|
||
To run CS checks only: | ||
|
||
```console | ||
$ composer cs-check | ||
``` | ||
|
||
To attempt to automatically fix common CS issues: | ||
|
||
```console | ||
$ composer cs-fix | ||
``` | ||
|
||
If the above fixes any CS issues, please re-run the tests to ensure | ||
they pass, and make sure you add and commit the changes after verification. | ||
|
||
## Recommended Workflow for Contributions | ||
|
||
Your first step is to establish a public repository from which we can | ||
pull your work into the master repository. We recommend using | ||
[GitHub](https://github.com), as that is where the component is already hosted. | ||
|
||
1. Setup a [GitHub account](https://github.com/), if you haven't yet | ||
2. Fork the repository (https://github.com/zendframework/zend-coding-standard) | ||
3. Clone the canonical repository locally and enter it. | ||
|
||
```console | ||
$ git clone git://github.com/zendframework/zend-coding-standard.git | ||
$ cd zend-coding-standard | ||
``` | ||
|
||
4. Add a remote to your fork; substitute your GitHub username in the command | ||
below. | ||
|
||
```console | ||
$ git remote add {username} git@github.com:{username}/zend-coding-standard.git | ||
$ git fetch {username} | ||
``` | ||
|
||
### Keeping Up-to-Date | ||
|
||
Periodically, you should update your fork or personal repository to | ||
match the canonical ZF repository. Assuming you have setup your local repository | ||
per the instructions above, you can do the following: | ||
|
||
|
||
```console | ||
$ git checkout master | ||
$ git fetch origin | ||
$ git rebase origin/master | ||
# OPTIONALLY, to keep your remote up-to-date - | ||
$ git push {username} master:master | ||
``` | ||
|
||
If you're tracking other branches -- for example, the "develop" branch, where | ||
new feature development occurs -- you'll want to do the same operations for that | ||
branch; simply substitute "develop" for "master". | ||
|
||
### Working on a patch | ||
|
||
We recommend you do each new feature or bugfix in a new branch. This simplifies | ||
the task of code review as well as the task of merging your changes into the | ||
canonical repository. | ||
|
||
A typical workflow will then consist of the following: | ||
|
||
1. Create a new local branch based off either your master or develop branch. | ||
2. Switch to your new local branch. (This step can be combined with the | ||
previous step with the use of `git checkout -b`.) | ||
3. Do some work, commit, repeat as necessary. | ||
4. Push the local branch to your remote repository. | ||
5. Send a pull request. | ||
|
||
The mechanics of this process are actually quite trivial. Below, we will | ||
create a branch for fixing an issue in the tracker. | ||
|
||
```console | ||
$ git checkout -b hotfix/9295 | ||
Switched to a new branch 'hotfix/9295' | ||
``` | ||
|
||
... do some work ... | ||
|
||
|
||
```console | ||
$ git commit | ||
``` | ||
|
||
... write your log message ... | ||
|
||
|
||
```console | ||
$ git push {username} hotfix/9295:hotfix/9295 | ||
Counting objects: 38, done. | ||
Delta compression using up to 2 threads. | ||
Compression objects: 100% (18/18), done. | ||
Writing objects: 100% (20/20), 8.19KiB, done. | ||
Total 20 (delta 12), reused 0 (delta 0) | ||
To ssh://git@github.com/{username}/zend-coding-standard.git | ||
b5583aa..4f51698 HEAD -> master | ||
``` | ||
|
||
To send a pull request, you have two options. | ||
|
||
If using GitHub, you can do the pull request from there. Navigate to | ||
your repository, select the branch you just created, and then select the | ||
"Pull Request" button in the upper right. Select the user/organization | ||
"zendframework" (or whatever the upstream organization is) as the recipient. | ||
|
||
#### What branch to issue the pull request against? | ||
|
||
Which branch should you issue a pull request against? | ||
|
||
- For fixes against the stable release, issue the pull request against the | ||
"master" branch. | ||
- For new features, or fixes that introduce new elements to the public API (such | ||
as new public methods or properties), issue the pull request against the | ||
"develop" branch. | ||
|
||
### Branch Cleanup | ||
|
||
As you might imagine, if you are a frequent contributor, you'll start to | ||
get a ton of branches both locally and on your remote. | ||
|
||
Once you know that your changes have been accepted to the master | ||
repository, we suggest doing some cleanup of these branches. | ||
|
||
- Local branch cleanup | ||
|
||
```console | ||
$ git branch -d <branchname> | ||
``` | ||
|
||
- Remote branch removal | ||
|
||
```console | ||
$ git push {username} :<branchname> | ||
``` |
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,19 @@ | ||
- [ ] I was not able to find an [open](https://github.com/zendframework/zend-coding-standard/issues?q=is%3Aopen) or [closed](https://github.com/zendframework/zend-coding-standard/issues?q=is%3Aclosed) issue matching what I'm seeing. | ||
- [ ] This is not a question. (Questions should be asked on [chat](https://zendframework.slack.com/) ([Signup here](https://zendframework-slack.herokuapp.com/)) or our [forums](https://discourse.zendframework.com/).) | ||
|
||
Provide a narrative description of what you are trying to accomplish. | ||
|
||
### Code to reproduce the issue | ||
|
||
<!-- Please provide the minimum code necessary to recreate the issue --> | ||
|
||
```php | ||
``` | ||
|
||
### Expected results | ||
|
||
<!-- What do you think should have happened? --> | ||
|
||
### Actual results | ||
|
||
<!-- What did you actually observe? --> |
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,25 @@ | ||
Provide a narrative description of what you are trying to accomplish: | ||
|
||
- [ ] Are you fixing a bug? | ||
- [ ] Detail how the bug is invoked currently. | ||
- [ ] Detail the original, incorrect behavior. | ||
- [ ] Detail the new, expected behavior. | ||
- [ ] Base your feature on the `master` branch, and submit against that branch. | ||
- [ ] Add a regression test that demonstrates the bug, and proves the fix. | ||
- [ ] Add a `CHANGELOG.md` entry for the fix. | ||
|
||
- [ ] Are you creating a new feature? | ||
- [ ] Why is the new feature needed? What purpose does it serve? | ||
- [ ] How will users use the new feature? | ||
- [ ] Base your feature on the `develop` branch, and submit against that branch. | ||
- [ ] Add only one feature per pull request; split multiple features over multiple pull requests | ||
- [ ] Add tests for the new feature. | ||
- [ ] Add documentation for the new feature. | ||
- [ ] Add a `CHANGELOG.md` entry for the new feature. | ||
|
||
- [ ] Is this related to quality assurance? | ||
<!-- Detail why the changes are necessary --> | ||
|
||
- [ ] Is this related to documentation? | ||
<!-- Is it a typographical and/or grammatical fix? --> | ||
<!-- Is it new documentation? --> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! 👍