@@ -114,30 +114,42 @@ static · Returns `string`
114114
115115** Throws:** ` BaseJsonException `
116116
117- #### [ ` assertAllArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L27-L32 )
117+ #### [ ` assertAllArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L30-L35 )
118118
119119static · Returns ` void `
120120
121+ This method throws an InputException if any of the expected keys are absent.
122+
123+ It does not return anything.
124+
121125** Parameters:**
122126
123127- ` $target ` : ` array `
124128- ` ...$arrayKeys ` : ` string `
125129
126130** Throws:** ` InputException `
127131
128- #### [ ` allArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L34-L41 )
132+ #### [ ` allArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L43-L50 )
129133
130134static · Returns ` bool `
131135
136+ This method returns true if every expected array key is found in the target array.
137+
138+ Otherwise, it returns false. This is useful for input validation.
139+
132140** Parameters:**
133141
134142- ` $target ` : ` array `
135143- ` ...$arrayKeys ` : ` string `
136144
137- #### [ ` constantTimeSelect ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L48- L65 )
145+ #### [ ` constantTimeSelect ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L65-L82 )
138146
139147Returns ` string `
140148
149+ This is a constant-time conditional select. It should be read like a ternary operation.
150+
151+ $result = ClassWithTrait::constantTimeSelect(1, $left, $right); -> $result === $left. $result = ClassWithTrait::constantTimeSelect(0, $left, $right); -> $result === $right.
152+
141153** Parameters:**
142154
143155- ` $select ` : ` int `
@@ -146,49 +158,63 @@ Returns `string`
146158
147159** Throws:** ` CryptoException `
148160
149- #### [ ` dos2unix ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L73-L76 )
161+ #### [ ` dos2unix ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L92-L95 )
150162
151163static · Returns ` string `
152164
153165Normalize line-endings to UNIX-style (LF rather than CRLF).
154166
167+ This is mostly used for PEM-encoded strings.
168+
155169** Parameters:**
156170
157171- ` $in ` : ` string `
158172
159- #### [ ` preAuthEncode ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L84-L97 )
173+ #### [ ` preAuthEncode ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L113-L126 )
160174
161175static · Returns ` string `
162176
177+ This is an implementation of PAE() from PASETO. It encodes an array of strings into a flat string consisting of:
178+
179+ 1 . The number of pieces. 2. For each piece: 1. The length of the piece (in bytes). 2. The contents of the piece. This allows multipart messages to have an injective canonical representation before passing ot a hash function (or other cryptographic function).
180+
163181** Parameters:**
164182
165183- ` $pieces ` : ` array `
166184
167- #### [ ` sortByKey ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L99-L107 )
185+ #### [ ` sortByKey ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L133-L141 )
168186
169187static · Returns ` void `
170188
189+ This sorts the target array in-place, by its keys, including child arrays.
190+
191+ Used for ensuring arrays are sorted before JSON encoding.
192+
171193** Parameters:**
172194
173195- ` $arr ` : ` array `
174196
175- #### [ ` LE64 ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L111-L114 )
197+ #### [ ` LE64 ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L148-L151 )
176198
177199static · Returns ` string `
178200
201+ Mostly used by preAuthEncode() above. This packs an integer as 8 bytes.
202+
179203** Parameters:**
180204
181205- ` $n ` : ` int `
182206
183- #### [ ` stringToByteArray ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L116-L123 )
207+ #### [ ` stringToByteArray ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L156-L163 )
184208
185209Returns ` array `
186210
211+ Get an array of bytes representing the input string.
212+
187213** Parameters:**
188214
189215- ` $str ` : ` string `
190216
191- #### [ ` stripNewlines ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L131-L165 )
217+ #### [ ` stripNewlines ` ] ( ../../../src/RateLimit/Storage/Filesystem.php#L171-L205 )
192218
193219static · Returns ` string `
194220
@@ -293,30 +319,42 @@ static · Returns `string`
293319
294320** Throws:** ` BaseJsonException `
295321
296- #### [ ` assertAllArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Redis.php#L27-L32 )
322+ #### [ ` assertAllArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Redis.php#L30-L35 )
297323
298324static · Returns ` void `
299325
326+ This method throws an InputException if any of the expected keys are absent.
327+
328+ It does not return anything.
329+
300330** Parameters:**
301331
302332- ` $target ` : ` array `
303333- ` ...$arrayKeys ` : ` string `
304334
305335** Throws:** ` InputException `
306336
307- #### [ ` allArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Redis.php#L34-L41 )
337+ #### [ ` allArrayKeysExist ` ] ( ../../../src/RateLimit/Storage/Redis.php#L43-L50 )
308338
309339static · Returns ` bool `
310340
341+ This method returns true if every expected array key is found in the target array.
342+
343+ Otherwise, it returns false. This is useful for input validation.
344+
311345** Parameters:**
312346
313347- ` $target ` : ` array `
314348- ` ...$arrayKeys ` : ` string `
315349
316- #### [ ` constantTimeSelect ` ] ( ../../../src/RateLimit/Storage/Redis.php#L48- L65 )
350+ #### [ ` constantTimeSelect ` ] ( ../../../src/RateLimit/Storage/Redis.php#L65-L82 )
317351
318352Returns ` string `
319353
354+ This is a constant-time conditional select. It should be read like a ternary operation.
355+
356+ $result = ClassWithTrait::constantTimeSelect(1, $left, $right); -> $result === $left. $result = ClassWithTrait::constantTimeSelect(0, $left, $right); -> $result === $right.
357+
320358** Parameters:**
321359
322360- ` $select ` : ` int `
@@ -325,49 +363,63 @@ Returns `string`
325363
326364** Throws:** ` CryptoException `
327365
328- #### [ ` dos2unix ` ] ( ../../../src/RateLimit/Storage/Redis.php#L73-L76 )
366+ #### [ ` dos2unix ` ] ( ../../../src/RateLimit/Storage/Redis.php#L92-L95 )
329367
330368static · Returns ` string `
331369
332370Normalize line-endings to UNIX-style (LF rather than CRLF).
333371
372+ This is mostly used for PEM-encoded strings.
373+
334374** Parameters:**
335375
336376- ` $in ` : ` string `
337377
338- #### [ ` preAuthEncode ` ] ( ../../../src/RateLimit/Storage/Redis.php#L84-L97 )
378+ #### [ ` preAuthEncode ` ] ( ../../../src/RateLimit/Storage/Redis.php#L113-L126 )
339379
340380static · Returns ` string `
341381
382+ This is an implementation of PAE() from PASETO. It encodes an array of strings into a flat string consisting of:
383+
384+ 1 . The number of pieces. 2. For each piece: 1. The length of the piece (in bytes). 2. The contents of the piece. This allows multipart messages to have an injective canonical representation before passing ot a hash function (or other cryptographic function).
385+
342386** Parameters:**
343387
344388- ` $pieces ` : ` array `
345389
346- #### [ ` sortByKey ` ] ( ../../../src/RateLimit/Storage/Redis.php#L99-L107 )
390+ #### [ ` sortByKey ` ] ( ../../../src/RateLimit/Storage/Redis.php#L133-L141 )
347391
348392static · Returns ` void `
349393
394+ This sorts the target array in-place, by its keys, including child arrays.
395+
396+ Used for ensuring arrays are sorted before JSON encoding.
397+
350398** Parameters:**
351399
352400- ` $arr ` : ` array `
353401
354- #### [ ` LE64 ` ] ( ../../../src/RateLimit/Storage/Redis.php#L111-L114 )
402+ #### [ ` LE64 ` ] ( ../../../src/RateLimit/Storage/Redis.php#L148-L151 )
355403
356404static · Returns ` string `
357405
406+ Mostly used by preAuthEncode() above. This packs an integer as 8 bytes.
407+
358408** Parameters:**
359409
360410- ` $n ` : ` int `
361411
362- #### [ ` stringToByteArray ` ] ( ../../../src/RateLimit/Storage/Redis.php#L116-L123 )
412+ #### [ ` stringToByteArray ` ] ( ../../../src/RateLimit/Storage/Redis.php#L156-L163 )
363413
364414Returns ` array `
365415
416+ Get an array of bytes representing the input string.
417+
366418** Parameters:**
367419
368420- ` $str ` : ` string `
369421
370- #### [ ` stripNewlines ` ] ( ../../../src/RateLimit/Storage/Redis.php#L131-L165 )
422+ #### [ ` stripNewlines ` ] ( ../../../src/RateLimit/Storage/Redis.php#L171-L205 )
371423
372424static · Returns ` string `
373425
0 commit comments