|
1 | 1 | # Contributing to StringFormatter |
2 | 2 |
|
3 | | -Thank you for considering contributing to StringFormatter! This document provides guidelines and information for contributors. |
| 3 | +Thank you for considering contributing to StringFormatter! This document provides an overview of the contribution process. |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +For detailed guidelines, see the [contributing documentation](docs/contributing/): |
6 | 6 |
|
7 | | -### Prerequisites |
8 | | - |
9 | | -- PHP 8.5 or higher |
10 | | -- Composer |
11 | | -- Git |
12 | | - |
13 | | -### Setting Up the Development Environment |
14 | | - |
15 | | -1. **Fork the repository** |
16 | | - |
17 | | -```bash |
18 | | -# Fork the repository on GitHub, then clone your fork |
19 | | -git clone https://github.com/yourusername/StringFormatter.git |
20 | | -cd StringFormatter |
21 | | -``` |
22 | | - |
23 | | -2. **Install dependencies** |
24 | | - |
25 | | -```bash |
26 | | -composer install |
27 | | -``` |
28 | | - |
29 | | -3. **Run tests** |
30 | | - |
31 | | -```bash |
32 | | -composer test |
33 | | -``` |
34 | | - |
35 | | -## How to Contribute |
36 | | - |
37 | | -### Adding New Formatters |
38 | | - |
39 | | -StringFormatter is designed to be extensible. All formatters must implement the `Respect\StringFormatter\Formatter` interface. |
40 | | - |
41 | | -**Steps to add a new formatter:** |
42 | | - |
43 | | -1. **Create the formatter class** |
44 | | - |
45 | | -```php |
46 | | -<?php |
47 | | - |
48 | | -declare(strict_types=1); |
49 | | - |
50 | | -namespace Respect\StringFormatter; |
51 | | - |
52 | | -final readonly class YourFormatter implements Formatter |
53 | | -{ |
54 | | - public function format(string $input): string |
55 | | - { |
56 | | - // Your formatting implementation |
57 | | - return $formattedInput; |
58 | | - } |
59 | | -} |
60 | | -``` |
61 | | - |
62 | | -2. **Create tests** |
63 | | - |
64 | | -```php |
65 | | -<?php |
66 | | -// tests/Unit/YourFormatterTest.php |
67 | | - |
68 | | -declare(strict_types=1); |
69 | | - |
70 | | -namespace Respect\StringFormatter\Test\Unit; |
71 | | - |
72 | | -use PHPUnit\Framework\TestCase; |
73 | | -use Respect\StringFormatter\YourFormatter; |
74 | | - |
75 | | -final class YourFormatterTest extends TestCase |
76 | | -{ |
77 | | - // Test your formatter implementation |
78 | | -} |
79 | | -``` |
80 | | - |
81 | | -3. **Add documentation** |
82 | | - - Create `docs/YourFormatter.md` following the template used by MaskFormatter |
83 | | - - Include usage examples, API reference, and any special considerations |
84 | | - |
85 | | -4. **Update README.md** |
86 | | - - Add your formatter to the "Formatters" table |
87 | | - |
88 | | -### Testing |
89 | | - |
90 | | -- **Unit tests**: Located in `tests/Unit/` |
91 | | -- **Run all tests**: `composer test` |
92 | | - |
93 | | -All contributions must include tests that pass. |
94 | | - |
95 | | -### Code Style |
96 | | - |
97 | | -This project follows the PSR-12 coding standard via the Respect Coding Standard. Run the following command before submitting: |
98 | | - |
99 | | -```bash |
100 | | -composer lint # Check coding style |
101 | | -composer format # Fix coding style automatically |
102 | | -``` |
103 | | - |
104 | | -### Static Analysis |
105 | | - |
106 | | -This project uses PHPStan for static analysis. Run: |
107 | | - |
108 | | -```bash |
109 | | -composer analyze # Run static analysis |
110 | | -``` |
111 | | - |
112 | | -### Submitting Changes |
113 | | - |
114 | | -1. **Create a feature branch** |
115 | | - |
116 | | -```bash |
117 | | -git checkout -b feature/your-feature-name |
118 | | -``` |
119 | | - |
120 | | -2. **Make your changes** |
121 | | - - Add your formatter implementation |
122 | | - - Include comprehensive tests |
123 | | - - Update documentation |
124 | | - - Follow PSR-12 coding standards |
125 | | - |
126 | | -3. **Test your changes** |
127 | | - |
128 | | -```bash |
129 | | -composer test # Run tests |
130 | | -composer lint # Check code style |
131 | | -composer format # Fix coding style automatically |
132 | | -composer analyze # Run static analysis |
133 | | -``` |
134 | | - |
135 | | -4. **Commit your changes** |
136 | | - |
137 | | -```bash |
138 | | -git add . |
139 | | -git commit -m "Add YourFormatter for [purpose]" |
140 | | -``` |
141 | | - |
142 | | -5. **Push and create a pull request** |
143 | | - |
144 | | -```bash |
145 | | -git push origin feature/your-feature-name |
146 | | -``` |
147 | | - |
148 | | -Then create a pull request on GitHub with: |
149 | | - |
150 | | -- Clear description of the changes |
151 | | -- Link to any relevant issues |
152 | | -- Explain the use case and benefits |
153 | | - |
154 | | -## Development Commands |
155 | | - |
156 | | -| Command | Description | |
157 | | -| ------------------ | -------------------------------- | |
158 | | -| `composer install` | Install dependencies | |
159 | | -| `composer test` | Run all tests | |
160 | | -| `composer lint` | Check PSR-12 compliance | |
161 | | -| `composer format` | Fix coding style automatically | |
162 | | -| `composer analyze` | Run static analysis with PHPStan | |
163 | | - |
164 | | -## Guidelines |
165 | | - |
166 | | -### Do |
167 | | - |
168 | | -- Write clear, well-documented code |
169 | | -- Include comprehensive tests |
170 | | -- Follow PSR-12 coding standards |
171 | | -- Use type declarations everywhere |
172 | | -- Write commit messages that explain the "why" not just the "what" |
173 | | - |
174 | | -### Don't |
175 | | - |
176 | | -- Submit changes without tests |
177 | | -- Break backward compatibility unless necessary |
178 | | -- Use PHP without strict typing |
179 | | -- Commit sensitive information |
180 | | -- Mix multiple concerns in a single PR |
181 | | - |
182 | | -## Reporting Issues |
183 | | - |
184 | | -When reporting issues, please include: |
185 | | - |
186 | | -- PHP version |
187 | | -- Library version |
188 | | -- Complete error messages |
189 | | -- Minimal reproducible example |
190 | | -- Expected vs actual behavior |
191 | | - |
192 | | -## Questions |
193 | | - |
194 | | -If you have questions about contributing, feel free to: |
195 | | - |
196 | | -- Open an issue with the "question" label |
197 | | -- Start a discussion in the repository discussions |
| 7 | +- [Getting Started](docs/contributing/getting-started.md) - Set up your development environment |
| 8 | +- [Guidelines](docs/contributing/guidelines.md) - Best practices |
| 9 | +- [Adding Formatters](docs/contributing/adding-formatters.md) - How to create new formatters |
| 10 | +- [Development](docs/contributing/development.md) - Testing, linting, and static analysis |
| 11 | +- [Submitting Changes](docs/contributing/submitting-changes.md) - Pull request process |
| 12 | +- [Commit Guidelines](docs/contributing/commit-guidelines.md) - How to write good commit messages |
198 | 13 |
|
199 | 14 | Thank you for contributing to StringFormatter! 🎉 |
0 commit comments