Skip to content

Commit

Permalink
Merge pull request #8474 from kenjis/docs-contrib-pr
Browse files Browse the repository at this point in the history
docs: update contributing/pull_request.md
  • Loading branch information
kenjis authored Jan 30, 2024
2 parents 9c669c3 + d117b8a commit 46b301f
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 91 deletions.
153 changes: 98 additions & 55 deletions contributing/pull_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

## Contributions

We expect all contributions to conform to our
[style guide](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/styleguide.md),
be commented (inside the PHP source files), be documented (in the
[user guide](https://codeigniter4.github.io/userguide/)), and unit tested (in
the [test folder](https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests)).
We expect all contributions to
- conform to our [style guide](./styleguide.md),
- be commented (inside the PHP source files),
- be documented (in the [user guide](https://codeigniter4.github.io/userguide/)),
- and unit tested (in the [test folder](https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests)).

Note, we expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite
to prove the code works. If pull requests are not accompanied by relevant tests, they will likely be closed.
Since we are a team of volunteers, we don't have any more time to work on the framework than you do. Please
make it as painless for your contributions to be included as possible. If you need help with getting tests
running on your local machines, ask for help on the forums. We would be happy to help out.
> [!IMPORTANT]
> We expect all code changes or bug-fixes to be accompanied by one or more tests
> added to our test suite to prove the code works.
The [Open Source Guide](https://opensource.guide/) is a good first read for those new to contributing to open source!
If pull requests are not accompanied by relevant tests, they will likely be closed.
Since we are a team of volunteers, we don't have any more time to work on the
framework than you do. Please make it as painless for your contributions to be
included as possible.

If you need help with getting tests running on your local machines, ask for help
on the [forum](https://forum.codeigniter.com/forumdisplay.php?fid=27). We would
be happy to help out.

The [Open Source Guide](https://opensource.guide/) is a good first read for those
new to contributing to open source!

## CodeIgniter Internals Overview

Expand All @@ -29,7 +37,8 @@ Your Pull Requests (PRs) need to meet our guidelines.

If your Pull Requests fail to pass these guidelines, they will be declined,
and you will need to re-submit when you've made the changes.
This might sound a bit tough, but it is required for us to maintain the quality of the codebase.
This might sound a bit tough, but it is required for us to maintain the quality
of the codebase.

### PHP Style

Expand All @@ -38,10 +47,11 @@ This might sound a bit tough, but it is required for us to maintain the quality
All code must conform to our [Style Guide](./styleguide.md), which is
based on PSR-12.

This makes certain that all submitted code is of the same format
as the existing code and ensures that the codebase will be as readable as possible.
This makes certain that all submitted code is of the same format as the existing
code and ensures that the codebase will be as readable as possible.

You can fix most of the coding style violations by running this command in your terminal:
You can fix most of the coding style violations by running this command in your
terminal:

```console
composer cs-fix
Expand All @@ -55,7 +65,8 @@ composer cs

### Unit Testing

If you are not familiar with Unit Testing, see [the forum thread](https://forum.codeigniter.com/showthread.php?tid=81830).
If you are not familiar with Unit Testing, see
[the forum thread](https://forum.codeigniter.com/showthread.php?tid=81830).

Unit testing is expected for all CodeIgniter components. We use PHPUnit,
and run unit tests using GitHub Actions for each PR submitted or changed.
Expand Down Expand Up @@ -93,7 +104,7 @@ See the following for more information.

Do not add comments that are superficial, duplicated, or stating the obvious.

### Documentation
### User Guide

The User Guide is an essential component of the CodeIgniter framework.

Expand All @@ -106,18 +117,21 @@ then you will need to add to the documentation.
New classes, methods, parameters, changing default values, changing behavior etc.
are all changes that require a change to documentation.

Also, the [Changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html) must be updated for every change,
and [PHPDoc](https://github.com/codeigniter4/CodeIgniter4/blob/develop/phpdoc.dist.xml) blocks must be maintained.
Also, the [Changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html)
must be updated for every change, and PHPDoc blocks must be maintained.

See [Writing CodeIgniter Documentation](./documentation.rst).

#### Changelog

The [Changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html), in the user guide, needs to be kept up-to-date. Not
all changes will need an entry in it, but the following items should.
The [Changelog](https://codeigniter4.github.io/CodeIgniter4/changelogs/index.html)
in the [user guide](https://github.com/codeigniter4/CodeIgniter4/tree/develop/user_guide_src/source/changelogs)
needs to be kept up-to-date. Not all changes will need an entry in it, but the
following items should.

- all breaking changes (BCs)
- all enhancements (new features, new classes, new APIs)
- message changes
- other behavior changes
- deprecations
- major bug fixes
Expand All @@ -127,11 +141,12 @@ all changes will need an entry in it, but the following items should.
If your PR requires users to do something when they upgrade CodeIgniter, or
changes the Config values,
the [Upgrading Guide](https://codeigniter4.github.io/CodeIgniter4/installation/upgrading.html)
is also needed.
in the [installation](https://github.com/codeigniter4/CodeIgniter4/tree/develop/user_guide_src/source/installation)
folder is also needed.

- Add an instruction what to do when upgrading.
- If you add new properties or changes default values in Config files, add the
changes in *"Project Files > Content Changes > Config"*.
changes in *"Project Files > Content Changes > Config"*.

### CSS

Expand All @@ -154,12 +169,19 @@ break with earlier versions of the framework.

#### Breaking Changes

In general, any change that would disrupt existing uses of the framework is considered a "Breaking Change" (BC) and will not be favorably considered. A few specific examples to pay attention to:
In general, any change that would disrupt existing uses of the framework is
considered a "Breaking Change" (BC) and will not be favorably considered. A few
specific examples to pay attention to:

1. New classes/properties/constants in `system` are acceptable, but anything in the `app` directory that will be used in `system` should be backwards-compatible.
2. Any changes to non-private methods must be backwards-compatible with the original definition.
3. Deleting non-private properties or methods without prior deprecation notices is frowned upon and will likely be closed.
4. Deleting or renaming public classes and interfaces, as well as those not marked as `@internal`, without prior deprecation notices or not providing fallback solutions will also not be favorably considered.
1. New classes/properties/constants in `system` are acceptable, but anything in
the `app` directory that will be used in `system` should be backwards-compatible.
2. Any changes to non-private methods must be backwards-compatible with the original
definition.
3. Deleting non-private properties or methods without prior deprecation notices
is frowned upon and will likely be closed.
4. Deleting or renaming public classes and interfaces, as well as those not marked
as `@internal`, without prior deprecation notices or not providing fallback
solutions will also not be favorably considered.

### Mergeability

Expand All @@ -174,48 +196,57 @@ working on your contribution.

### Branching

All bug fixes should be sent to the __"develop"__ branch, this is where the next bug fix version will be developed.
All bug fixes should be sent to the __"develop"__ branch, this is where the next
bug fix version will be developed.

PRs with any enhancement should be sent to next minor version branch, e.g. __"4.3"__
PRs with any enhancement should be sent to next minor version branch, e.g. __"4.5"__

The __"master"__ branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g. an
emergency security patch) can be applied to the "master" branch to create a new version, without worrying
about other features holding it up. Any sent to the "master" branch will be closed automatically.
The __"master"__ branch will always contain the latest stable version and is kept
clean so a "hotfix" (e.g. an emergency security patch) can be applied to the
"master" branch to create a new version, without worrying about other features
holding it up. Any sent to the "master" branch will be closed automatically.

If you have multiple changes to submit,
please place all changes into their own branch on your fork.

**One thing at a time:** A pull request should only contain one change. That does not mean only one commit,
but one change - however many commits it took. The reason for this is that if you change X and Y,
but send a pull request for both at the same time, we might really want X but disagree with Y,
meaning we cannot merge the request. Using the Git-Flow branching model you can create new
branches for both of these features and send two requests.
**One thing at a time:** A pull request should only contain one change. That does
not mean only one commit, but one change - however many commits it took. The reason
for this is that if you change X and Y, but send a pull request for both at the
same time, we might really want X but disagree with Y, meaning we cannot merge
the request. Using the Git-Flow branching model you can create new branches for
both of these features and send two requests.

A reminder: **please use separate branches for each of your PRs** - it will make it easier for you to keep
changes separate from each other and from whatever else you are doing with your repository!
> [!IMPORTANT]
> **Please use separate branches for each of your PRs** - it will make it easier
> for you to keep changes separate from each other and from whatever else you are
> doing with your repository!
### Signing

You must [GPG-sign](./signing.md) your work, certifying that you either wrote the work or
otherwise have the right to pass it on to an open-source project. See [Developer's Certificate of Origin](./DCO.md).
otherwise have the right to pass it on to an open-source project. See
[Developer's Certificate of Origin](./DCO.md).

This is *not* just a "signed-off-by" commit, but instead, a digitally signed one.

See [Contribution signing](./signing.md) for details.

### Static Analysis on PHP code

We cannot, at all times, guarantee that all PHP code submitted on pull requests to be working well without
actually running the code. For this reason, we make use of two static analysis tools, [PHPStan][1]
and [Rector][2] to do the analysis for us.
We cannot, at all times, guarantee that all PHP code submitted on pull requests
to be working well without actually running the code. For this reason, we make
use of two static analysis tools, [PHPStan][1] and [Rector][2] to do the analysis
for us.

These tools have already been integrated into our CI/CD workflow to minimize unannounced bugs. Pull requests
are expected that their code will pass these two. In your local machine, you can manually run these tools
so that you can fix whatever errors that pop up with your submission.
These tools have already been integrated into our CI/CD workflow to minimize
unannounced bugs. Pull requests are expected that their code will pass these two.
In your local machine, you can manually run these tools so that you can fix
whatever errors that pop up with your submission.

#### PHPStan

PHPStan is expected to scan the entire framework by running this command in your terminal:
PHPStan is expected to scan the entire framework by running this command in your
terminal:

```console
vendor/bin/phpstan analyse
Expand Down Expand Up @@ -252,7 +283,10 @@ vendor/bin/rector process path/to/file

## How-to Guide

The best way to contribute is to fork the CodeIgniter4 repository, and "clone" that to your development area. That sounds like some jargon, but "forking" on GitHub means "making a copy of that repo to your account" and "cloning" means "copying that code to your environment so you can work on it".
The best way to contribute is to fork the CodeIgniter4 repository, and "clone"
that to your development area. That sounds like some jargon, but "forking" on
GitHub means "making a copy of that repo to your account" and "cloning" means
"copying that code to your environment so you can work on it".

1. Set up Git ([Windows](https://git-scm.com/download/win), [Mac](https://git-scm.com/download/mac), & [Linux](https://git-scm.com/download/linux)).
2. Go to the [CodeIgniter4 repository](https://github.com/codeigniter4/CodeIgniter4).
Expand All @@ -266,16 +300,21 @@ The best way to contribute is to fork the CodeIgniter4 repository, and "clone" t
- If your PR is for bug fixes:
- `> git switch develop`
- `> git switch -c <new-branch-name>`
- If your PR has any enhancement, create new branch from next minor version branch, e.g. __"4.3"__:
- If your PR has any enhancement, create new branch from next minor version branch, e.g. __"4.5"__:
- `> git switch <next-minor-version-branch>`
- `> git switch -c <new-branch-name>`
7. Fix existing bugs on the [Issue tracker](https://github.com/codeigniter4/CodeIgniter4/issues) after confirming that no one else is working on them.
7. Fix existing bugs on the [Issue tracker](https://github.com/codeigniter4/CodeIgniter4/issues) after confirming that no one
else is working on them.
8. [Commit](https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project) the changed files in your contribution branch.
- `> git commit`
- Commit messages are expected to be descriptive of why and what you changed specifically. Commit messages like "Fixes #1234" would be asked by the reviewer to be revised. [Atomic commit](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) is recommended. See [Contribution Workflow](./workflow.md#commit-messages) for details.
- Commit messages are expected to be descriptive of why and what you changed
specifically. Commit messages like "Fixes #1234" would be asked by the reviewer
to be revised. [Atomic commit](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) is recommended. See
[Contribution Workflow](./workflow.md#commit-messages) for details.
9. If you have touched PHP code, run static analysis.
- `> composer analyze`
10. Run unit tests on the specific file you modified. If there are no existing tests yet, please create one.
10. Run unit tests on the specific file you modified. If there are no existing
tests yet, please create one.
- `> vendor/bin/phpunit tests/system/path/to/file/you/modified`
- Make sure the tests pass to have a higher chance of merging.
11. [Push](https://docs.github.com/en/github/using-git/pushing-commits-to-a-remote-repository) your contribution branch to your fork.
Expand All @@ -285,9 +324,13 @@ The best way to contribute is to fork the CodeIgniter4 repository, and "clone" t

See [Contribution workflow](./workflow.md) for Git workflow details.

The codebase maintainers will now be alerted to the submission and someone from the team will respond. If your change fails to meet the guidelines, it will be rejected or feedback will be provided to help you improve it.
The codebase maintainers will now be alerted to the submission and someone from
the team will respond. If your change fails to meet the guidelines, it will be
rejected or feedback will be provided to help you improve it.

Once the maintainer handling your pull request is satisfied with it, they will approve the pull request and merge it into the "develop" branch. Your patch will now be part of the next release!
Once the maintainer handling your pull request is satisfied with it, they will
approve the pull request and merge it into the "develop" branch. Your patch will
now be part of the next release!

## Translating System Messages

Expand Down
4 changes: 2 additions & 2 deletions contributing/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This document declares a set of coding conventions and rules to be followed when contributing PHP code
to the CodeIgniter project.

**Note:**
> [!NOTE]
> While we would recommend it, there's no requirement that you follow these conventions and rules in your
own projects. Usage is discretionary within your projects but strictly enforceable within the framework.

Expand Down Expand Up @@ -200,7 +200,7 @@ conditions MUST always be at the beginning or at the end of the line, not a mix
- The conditional operator, also known simply as the ternary operator, MUST be preceded and followed by at least one space around both the `?` and `:` characters.
- When the middle operand of the conditional operator is omitted, the operator MUST follow the same style rules as other binary comparison operators.

**Note:**
> [!NOTE]
> All the preceding rules are quoted from PSR-12. You may visit its website to view the code block samples.
## Custom Conventions
Expand Down
Loading

0 comments on commit 46b301f

Please sign in to comment.