You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
6.5 KiB

3 years ago
  1. # Contributing to Carbon
  2. ## Issue Contributions
  3. Please report any security issue using [Tidelift security contact](https://tidelift.com/security).
  4. Tidelift will coordinate the fix and disclosure.
  5. Please don't disclose security bugs publicly until they have been handled by us.
  6. For any other bug or issue, please click this link and follow the template:
  7. [Create new issue](https://github.com/briannesbitt/Carbon/issues/new)
  8. You may think this template does not apply to your case but please think again. A long description will never be as
  9. clear as a code chunk with the output you expect from it (for either bug report or new features).
  10. ## Code Contributions
  11. ### Where to begin
  12. We use the label **good first issue** to tag issues that could be a good fit for new contributors, see if there are such issues now following this link:
  13. https://github.com/briannesbitt/Carbon/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
  14. Else, check the roadmap to see what we plan to do in next releases:
  15. https://github.com/briannesbitt/Carbon/issues/1681
  16. ### Develop locally, then submit changes
  17. Fork the [GitHub project](https://github.com/briannesbitt/Carbon) and download it locally:
  18. ```shell
  19. git clone https://github.com/<username>/Carbon.git
  20. cd Carbon
  21. git remote add upstream https://github.com/briannesbitt/Carbon.git
  22. ```
  23. Replace `<username>` with your GitHub username.
  24. Then, you can work on the master or create a specific branch for your development:
  25. ```shell
  26. git checkout -b my-feature-branch -t origin/master
  27. ```
  28. You can now edit the "Carbon" directory contents.
  29. Before committing, please set your name and your e-mail (use the same e-mail address as in your GitHub account):
  30. ```shell
  31. git config --global user.name "Your Name"
  32. git config --global user.email "your.email.address@example.com"
  33. ```
  34. The ```--global``` argument will apply this setting for all your git repositories, remove it to set only your Carbon
  35. fork with those settings.
  36. Now you can commit your modifications as you usually do with git:
  37. ```shell
  38. git add --all
  39. git commit -m "The commit message log"
  40. ```
  41. If your patch fixes an open issue, please insert ```#``` immediately followed by the issue number:
  42. ```shell
  43. git commit -m "#21 Fix this or that"
  44. ```
  45. Use git rebase (not git merge) to sync your work from time to time:
  46. ```shell
  47. git fetch origin
  48. git rebase origin/master
  49. ```
  50. Please add some tests for bug fixes and features (so it will ensure next developments will not break your code),
  51. then check all is right with phpunit:
  52. Install PHP if you haven't yet, then install composer:
  53. https://getcomposer.org/download/
  54. Update dependencies:
  55. ```
  56. ./composer.phar update
  57. ```
  58. Or if you installed composer globally:
  59. ```
  60. composer update
  61. ```
  62. Then call phpunit:
  63. ```
  64. ./vendor/bin/phpunit
  65. ```
  66. Make sure all tests succeed before submitting your pull-request, else we will not be able to merge it.
  67. Push your work on your remote GitHub fork with:
  68. ```
  69. git push origin my-feature-branch
  70. ```
  71. Go to https://github.com/yourusername/Carbon and select your feature branch. Click the 'Pull Request' button and fill
  72. out the form.
  73. We will review it within a few days. And we thank you in advance for your help.
  74. ## Versioning
  75. ### Note about Semantic Versioning and breaking changes
  76. As a developer, you must understand every change is a breaking change. What is a bug for someone
  77. is expected in someone else's workflow. The consequence of a change strongly depends on the usage.
  78. [Semantic Versioning](https://semver.org/) relies to public API. In PHP, the public API of a class is its public
  79. methods. However, if you extend a class, you can access protected methods, then if you use reflexion, you can
  80. access private methods. So anything can become a public API if you force it to be. That doesn't mean we should handle
  81. any possible usage, else we would have to publish a major release for each change and it would no longer make sense.
  82. So before any complain about a breaking change, be warned, we do not guarantee a strict Semantic Versioning as you
  83. may expect, we're following a pragmatic interpretation of Semantic Versioning that allows the software to evolve in a
  84. reliable way with reasonable maintenance effort.
  85. Concretely, we consider a change as breaking if it makes fail one of our unit test. We will do our best to avoid
  86. incompatibilities with libraries that extends Carbon classes (such as Laravel that is continuously tested thanks to
  87. Travis CI, [see the compatibility matrix](https://github.com/kylekatarnls/carbon-laravel/tree/master#carbon-1-dev-version-1next)).
  88. If you're the owner of a library that strongly depends on Carbon, we recommend you to run unit tests daily requiring
  89. `"nesbot/carbon": "dev-master"` (for `^2`) or `"nesbot/carbon": "dev-version-1.next"` (for `^1`), this way you can
  90. detect incompatibilities earlier and report it to us before we tag a release. We'll pay attention and try to fix it to
  91. make update to next minor releases as soft as possible.
  92. We reserve the right to publish emergency patches within 24 hours after a release if a tag that does not respect
  93. this pattern would have been released despite our vigilance. In this very rare and particular case, we would mark the
  94. tag as broken on GitHub and backward compatibility would be based on previous stable tag.
  95. Last, you must understand that Carbon extends PHP natives classes, that means Carbon can be impacted by any change
  96. that occurs in the date/time API of PHP. We watch new PHP versions and handle those changes as quickly as possible
  97. when detected, but as PHP does not follow the semantic versioning pattern, it basically means any releases (including
  98. patches) can have unexpected consequences on Carbon methods results.
  99. ### Long term support
  100. To benefit the better support, require Carbon using major version range (`^1` or `^2`). By requiring `1.26.*`,
  101. `~1.26.0` or limited range such as `>=1.20 <1.33`, you fall to low priority support (only security and critical issues
  102. will be fixed), our prior support goes to next minor releases of each major version. It applies to bug fixes and
  103. low-cost features. Other new features will only be added in the last stable release. At the opposite, we recommend you
  104. to restrain to a major number, as there is no compatibility guarantee from a major version to the next. It means
  105. requiring `>=2`, as it allows any newer version, will probably leads to errors on releasing our next major version.
  106. Open milestones can be patched if a minor bug is detected while if you're on a closed milestone, we'll more likely
  107. ask you to update first to an open one. See currently open milestones:
  108. https://github.com/briannesbitt/Carbon/milestones