Skip to content

Commit 8c0f372

Browse files
committed
add enforcement, document convention
1 parent 70ad746 commit 8c0f372

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ repos:
103103
entry: bash ./test/assert-utils-used.bash
104104
language: system
105105
files: \.php$
106-
exclude: ^resources/lib/utils\.php$
106+
exclude: |
107+
(?x)^(
108+
^resources/lib/utils\.php$|
109+
^test/.*\.php$|
110+
)$
107111
- id: assert-exceptions-used
108112
name: Assert exceptions are used
109113
entry: bash ./test/assert-exceptions-used.bash

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
This will throw an exception rather than returning `false`.
2121
- No code should call `mb_detect_encoding()`, instead `\mbDetectEncoding()`.
2222
This will enable strict mode and throw an exception rather than returning `false`.
23+
- No code should call `intval()`, instead `\str2int()`.
24+
This will enable strict mode and throw an exception rather than issuing a warning.
2325
- `UnityHTTPD`'s user-facing error functionality (ex: `badRequest`) should only be called from `webroot/**/*.php`.
2426
`resources/**/*.php` should throw exceptions instead.
2527
- all pages under `webroot/admin/` must check for `$USER->isAdmin()` and call `UnityHTTPD::forbidden()` if not admin.

test/assert-utils-used.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ declare -A utils=(
1010
["json_encode"]="jsonEncode"
1111
["mb_detect_encoding"]="mbDetectEncoding"
1212
["mb_convert_encoding"]="mbConvertEncoding"
13+
["intval"]="str2int"
1314
)
1415

1516
rc=0

0 commit comments

Comments
 (0)