diff --git a/contributing/pull_request.md b/contributing/pull_request.md index f0950a408283..38f32d40c1be 100644 --- a/contributing/pull_request.md +++ b/contributing/pull_request.md @@ -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 @@ -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 @@ -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 @@ -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. @@ -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. @@ -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 @@ -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 @@ -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 @@ -174,30 +196,36 @@ 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. @@ -205,17 +233,20 @@ 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 @@ -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). @@ -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 ` - - 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 ` - `> git switch -c ` -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. @@ -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 diff --git a/contributing/styleguide.md b/contributing/styleguide.md index 1b8b499048a2..95e68bb37ddb 100644 --- a/contributing/styleguide.md +++ b/contributing/styleguide.md @@ -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. @@ -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 diff --git a/contributing/workflow.md b/contributing/workflow.md index d91b450499cd..da1f53d4743c 100644 --- a/contributing/workflow.md +++ b/contributing/workflow.md @@ -16,8 +16,9 @@ values for when you try these: ## Branching -- All bug fix PRs 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"__ +- All bug fix PRs 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.5"__ The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security @@ -111,23 +112,25 @@ This local branch should be named appropriately, for instance "fix/problem123" or "new/mind-reader". The slashes in these branch names is optional, and implies a sort of namespacing if used. -- All bug fix PRs 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"__ +- All bug fix PRs 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.5"__ -For instance, if you send a PR to __"develop"__ branch, make sure you are in the *develop* branch, and create a -new bugfix branch, based on *develop*, for a new feature you are -creating: +For instance, if you send a PR to __"develop"__ branch, make sure you are in the +*develop* branch, and create a new bugfix branch, based on *develop*, for a new +feature you are creating: ```console > git switch develop > git switch -c fix/problem123 ``` -If you send a PR with an enhancement, make sure you are in the *next minor version* branch, -and create a new feature branch, based on, e.g., *4.3*, for a new feature you are creating: +If you send a PR with an enhancement, make sure you are in the *next minor version* +branch, and create a new feature branch, based on, e.g., __"4.5"__, for a new +feature you are creating: ```console -> git switch 4.3 +> git switch 4.5 > git switch -c new/mind-reader ``` @@ -151,14 +154,14 @@ There are some references for writing good commit messages: If there are intermediate commits that are not meaningful to the overall PR, such as "Fix error on style guide", "Fix phpstan error", "Fix mistake in code", -and other related commits, you can squash your commits so that we can have a clean commit history. -But it is not a must. +and other related commits, you can squash your commits so that we can have a +clean commit history. But it is not a must. ### Commit Messages -Commit messages are important. They communicate the intent of a specific change, concisely. -They make it easier to review code, and to find out why a change was made -if the code history is examined later. +Commit messages are important. They communicate the intent of a specific change, +concisely. They make it easier to review code, and to find out why a change was +made if the code history is examined later. The audience for your commit messages will be the codebase maintainers, any code reviewers, and debuggers trying to figure out when a bug might @@ -166,8 +169,9 @@ have been introduced. Make your commit messages meaningful. -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. +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. You can have as many commits in a branch as you need to "get it right". For instance, to commit your work from a debugging session: @@ -185,7 +189,8 @@ Just make sure that your commits in a feature branch are all related. ### GPG-Signing Old Commits -Any developer can forget GPG-signing their commits with the option `-S`, like `git commit -S -m 'Signed GPG'`. In such a case, all you need to do is the following: +Any developer can forget GPG-signing their commits with the option `-S`, like +`git commit -S -m 'Signed GPG'`. In such a case, all you need to do is the following: Latest commit only: ```console @@ -235,7 +240,7 @@ are working in. At some point, you will decide that your feature branch is complete, or that it could benefit from a review by fellow developers. -> **Note** +> [!NOTE] > Remember to sync your local repo with the shared one before pushing! It is a lot easier to resolve conflicts at this stage. @@ -267,16 +272,16 @@ On GitHub, you propose your changes one feature branch at a time, by switching to the branch you wish to contribute, and then clicking on "New pull request". -Make sure the pull request is for the shared __"develop"__ or next minor version branch, e.g. __"4.3"__, or it -may be rejected. +Make sure the pull request is for the shared __"develop"__ or next minor version +branch, e.g. __"4.5"__, or it may be rejected. Make sure that the PR title is helpful for the maintainers and other developers. Add any comments appropriate, for instance asking for review. -> **Note** -> If you do not provide a title or description for your PR, the odds of it being summarily rejected -rise astronomically. +> [!NOTE] +> If you do not provide a title or description for your PR, the odds of it being +> summarily rejected rise astronomically. When your PR is submitted, a continuous integration task will be triggered, running all the unit tests as well as any other checking we @@ -306,9 +311,11 @@ And if your PRs have the breaking changes, label the following label: ## Updating Your Branch -If you are asked for changes in the review, commit the fix in your branch and push it to GitHub again. +If you are asked for changes in the review, commit the fix in your branch and +push it to GitHub again. -If the __"develop"__ or next minor version branch, e.g. __"4.3"__, progresses and conflicts arise that prevent merging, or if you are asked to *rebase*, +If the __"develop"__ or next minor version branch, e.g. __"4.5"__, progresses +and conflicts arise that prevent merging, or if you are asked to *rebase*, do the following: Synchronize your repository: @@ -347,7 +354,7 @@ And finally push your local branch to your GitHub repository: If you have sent a PR to the wrong branch, you need to create a new PR branch. -When you have the PR branch `feat-abc` and you should have sent the PR to `4.3`, +When you have the PR branch `feat-abc` and you should have sent the PR to __"4.5"__, but you created the PR branch from `develop` and sent a PR. Copy the IDs of any commits you made that you want to keep: @@ -356,13 +363,13 @@ Copy the IDs of any commits you made that you want to keep: > git log ``` -Update your `4.3` branch: +Update your __"4.5"__ branch: ```console > git fetch upstream -> git switch 4.3 -> git merge upstream/4.3 -> git push origin 4.3 +> git switch 4.5 +> git merge upstream/4.5 +> git push origin 4.5 ``` (Optional) Create a new branch as a backup, just in case: @@ -371,10 +378,10 @@ Update your `4.3` branch: > git branch feat-abc.bk feat-abc ``` -Rebase your PR branch from `develop` onto `4.3`: +Rebase your PR branch from `develop` onto __"4.5"__: ```console -> git rebase --onto 4.3 develop feat-abc +> git rebase --onto 4.5 develop feat-abc ``` Force push. @@ -383,7 +390,7 @@ Force push. > git push --force-with-lease origin feat-abc ``` -On the GitHub PR page, change the base branch to the correct branch `4.3`. +On the GitHub PR page, change the base branch to the correct branch __"4.5"__. ## Cleanup