Skip to content

Commit 4b9ac85

Browse files
committed
Update the docs for constant usage in params
The docs said you can use `::JSON_THROW_ON_ERROR` in allowed param values which is incorrect as you have to use `::constant(JSON_THROW_ON_ERROR)` but only if PHPStan uses an older version of nette/di, which it currently does. If one day PHPStan will start using a newer version, it may break, but consider yourself warned. Close #361 See also #250
1 parent d58cc29 commit 4b9ac85

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

disallowed-loose-calls.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ parameters:
99
function: 'htmlspecialchars()'
1010
message: 'set the $flags parameter to `ENT_QUOTES` to also convert single quotes to entities to prevent some HTML injection bugs'
1111
allowParamFlagsAnywhere:
12-
2: 3 # ENT_QUOTES
12+
2: 3 # ENT_QUOTES; using ::constant(ENT_QUOTES) is discouraged as it may break when PHPStan updates nette/di

docs/allow-with-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ parameters:
146146
-
147147
position: 4
148148
name: 'flags'
149-
value: ::JSON_THROW_ON_ERROR
149+
value: 4194304 # JSON_THROW_ON_ERROR; using ::constant(JSON_THROW_ON_ERROR) is discouraged as it may break when PHPStan updates nette/di
150150
```
151151

152152
This format allows to detect the value in both cases whether it's used with a traditional positional parameter (e.g. `json_decode($foo, null, 512, JSON_THROW_ON_ERROR)`) or a named parameter (e.g. `json_decode($foo, flags: JSON_THROW_ON_ERROR)`).

0 commit comments

Comments
 (0)