Skip to content

Commit 9c6049f

Browse files
committed
update CONTRIBUTING.md
1 parent f0961cb commit 9c6049f

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,23 @@
66
- All PHP files are required to be linted with PSR-12 and formatted with `phpcbf`.
77
- Note: Some changes have been made to PSR-12, see `.phpcs-ruleset-pure.php`
88
- All pure PHP files are required to be formatted with Prettier as well as above.
9-
- The maximum line length for any PHP file is 100 characters.
9+
- The maximum line length for any pure PHP file is 100 characters.
1010
- Comments should be used sparingly.
1111
- Empty lines should be used sparingly.
12-
- No code should fail quietly, instead exceptions should be thrown.
13-
PHP builtin functions that fail quietly (ex: `json_encode`) should be replaced with a wrapper in `resources/utils.php`.
1412
- No code should call `die()` or `exit()`, instead `UnityHTTPD::die()`.
15-
This will avoid the premature death of our automated testing processes.
13+
- This will avoid the premature death of our automated testing processes.
1614
- No code should call `assert()`, instead `\ensure()`.
17-
This will enforce conditions even in production.
18-
- No code should call `json_encode()`, instead `\jsonEncode()`.
19-
This will throw errors and escape slashes by default.
20-
- No code should call `json_decode()`, instead `\jsonDecode()`.
21-
This will throw an exception rather than returning `null`.
22-
- No code should call `mb_convert_encoding()`, instead `\mbConvertEncoding()`.
23-
This will throw an exception rather than returning `false`.
24-
- No code should call `mb_detect_encoding()`, instead `\mbDetectEncoding()`.
25-
This will enable strict mode and throw an exception rather than returning `false`.
26-
- No code should call `intval()`, instead `\str2int()`.
27-
This will enable strict mode and throw an exception rather than issuing a warning.
15+
- This will enforce conditions even in production.
16+
- No code should fail quietly, instead exceptions should be thrown. PHP builtin functions that fail quietly (ex: `json_encode`) should be replaced with a wrapper in `resources/utils.php`. Current wrappers:
17+
- `json_encode` -> `jsonEncode`
18+
- `json_decode` -> `jsonDecode`
19+
- `mb_convert_encoding` -> `mbConvertEncoding`
20+
- `mb_detect_encoding` -> `mbDetectEncoding`
21+
- `intval` -> `digits2int`
2822
- `UnityHTTPD`'s user-facing error functionality (ex: `badRequest`) should only be called from `webroot/**/*.php`.
2923
`resources/**/*.php` should throw exceptions instead.
3024
- all pages under `webroot/admin/` must check for `$USER->getFlag(UserFlag::ADMIN)` and call `UnityHTTPD::forbidden()` if not admin.
31-
32-
This repository will automatically check PRs for linting compliance.
25+
- All these conventions should be enforced with `pre-commit` / github CI if possible
3326

3427
## Development Environment
3528

0 commit comments

Comments
 (0)