Skip to content

Commit 22b89d9

Browse files
committed
docs: update README.md and zstd.stub.php
1 parent 214a63f commit 22b89d9

File tree

2 files changed

+86
-42
lines changed

2 files changed

+86
-42
lines changed

README.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension=zstd.so
6767
Name | Default | Changeable
6868
------------------------------- | ------- | ----------
6969
zstd.output\_compression | 0 | PHP\_INI\_ALL
70-
zstd.output\_compression\_level | -1 | PHP\_INI\_ALL
70+
zstd.output\_compression\_level | 3 | PHP\_INI\_ALL
7171
zstd.output\_compression\_dict | "" | PHP\_INI\_ALL
7272

7373
* zstd.output\_compression _boolean_/_integer_
@@ -82,8 +82,8 @@ zstd.output\_compression\_dict | "" | PHP\_INI\_ALL
8282
* zstd.output\_compression\_level _integer_
8383

8484
Compression level used for transparent output compression.
85-
Specify a value between 0 to 22.
86-
The default value of -1 uses internally defined values (3).
85+
Specify a value between 1 to 22.
86+
The default value of `ZSTD_COMPRESS_LEVEL_DEFAULT` (11).
8787

8888
* zstd.output\_compression\_dict _string_
8989

@@ -97,8 +97,8 @@ Name | Description
9797
ZSTD\_COMPRESS\_LEVEL\_MIN | Minimal compress level value
9898
ZSTD\_COMPRESS\_LEVEL\_MAX | Maximal compress level value
9999
ZSTD\_COMPRESS\_LEVEL\_DEFAULT | Default compress level value
100-
LIBZSTD\_VERSION\_NUMBER | libzstd version number
101-
LIBZSTD\_VERSION\_STRING | libzstd version string
100+
ZSTD\_VERSION\_NUMBER | libzstd version number
101+
ZSTD\_VERSION\_TEXT | libzstd version string
102102

103103
## Function
104104

@@ -111,12 +111,14 @@ LIBZSTD\_VERSION\_STRING | libzstd version string
111111
* zstd\_uncompress\_init — Initialize an incremental uncompress context
112112
* zstd\_uncompress\_add — Incrementally uncompress data
113113

114-
114+
---
115115
### zstd\_compress — Zstandard compression
116116

117117
#### Description
118118

119-
string **zstd\_compress** ( string _$data_ [, int _$level_ = 3 ] )
119+
``` php
120+
zstd_compress ( string $data, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): string|false
121+
```
120122

121123
Zstandard compression.
122124

@@ -128,8 +130,8 @@ Zstandard compression.
128130

129131
* _level_
130132

131-
The level of compression (1-22).
132-
(Defaults to 3)
133+
The level of compression (e.g. 1-22).
134+
(Defaults to `ZSTD_COMPRESS_LEVEL_DEFAULT`)
133135

134136
A value smaller than 0 means a faster compression level.
135137
(Zstandard library 1.3.4 or later)
@@ -138,12 +140,14 @@ Zstandard compression.
138140

139141
Returns the compressed data or FALSE if an error occurred.
140142

141-
143+
---
142144
### zstd\_uncompress — Zstandard decompression
143145

144146
#### Description
145147

146-
string **zstd\_uncompress** ( string _$data_ )
148+
``` php
149+
zstd_uncompress ( string $data ): string|false
150+
```
147151

148152
Zstandard decompression.
149153

@@ -159,12 +163,14 @@ Zstandard decompression.
159163

160164
Returns the decompressed data or FALSE if an error occurred.
161165

162-
166+
---
163167
### zstd\_compress\_dict — Zstandard compression using a digested dictionary
164168

165169
#### Description
166170

167-
string **zstd\_compress\_dict** ( string _$data_ , string _$dict_ [, int _$level_ = 3 ])
171+
``` php
172+
zstd_compress_dict ( string $data , string $dict, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): string|false
173+
```
168174

169175
Zstandard compression using a digested dictionary.
170176

@@ -182,19 +188,21 @@ Zstandard compression using a digested dictionary.
182188

183189
* _level_
184190

185-
The level of compression (1-22).
186-
(Defaults to 3)
191+
The level of compression (e.g. 1-22).
192+
(Defaults to `ZSTD_COMPRESS_LEVEL_DEFAULT`)
187193

188194
#### Return Values
189195

190196
Returns the compressed data or FALSE if an error occurred.
191197

192-
198+
---
193199
### zstd\_uncompress\_dict — Zstandard decompression using a digested dictionary
194200

195201
#### Description
196202

197-
string **zstd\_uncompress\_dict** ( string _$data_ , string _$dict_ )
203+
``` php
204+
zstd_uncompress_dict ( string $data , string $dict ): string|false
205+
```
198206

199207
Zstandard decompression using a digested dictionary.
200208

@@ -215,31 +223,36 @@ Zstandard decompression using a digested dictionary.
215223

216224
Returns the decompressed data or FALSE if an error occurred.
217225

218-
226+
---
219227
### zstd\_compress\_init — Initialize an incremental compress context
220228

221229
#### Description
222230

223-
Zstd\\Compress\\Context **zstd\_compress\_init** ( [ int _$level_ = ZSTD_COMPRESS_LEVEL_DEFAULT ] )
231+
``` php
232+
zstd_compress_init ( int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): Zstd\Compress\Context|false
233+
```
224234

225235
Initialize an incremental compress context
226236

227237
#### Parameters
228238

229239
* _level_
230240

231-
The higher the level, the slower the compression. (Defaults to `ZSTD_COMPRESS_LEVEL_DEFAULT`)
241+
The higher the level, the slower the compression.
242+
(Defaults to `ZSTD_COMPRESS_LEVEL_DEFAULT`)
232243

233244
#### Return Values
234245

235246
Returns a zstd context instance on success, or FALSE on failure
236247

237-
248+
---
238249
### zstd\_compress\_add — Incrementally compress data
239250

240251
#### Description
241252

242-
string **zstd\_compress\_add** ( Zstd\\Compress\\Context _$context_, string _$data_ [, bool _$end_ = false ] )
253+
``` php
254+
zstd_compress_add ( Zstd\Compress\Context $context, string $data, bool $end = false ): string|false
255+
```
243256

244257
Incrementally compress data
245258

@@ -261,25 +274,29 @@ Incrementally compress data
261274

262275
Returns a chunk of compressed data, or FALSE on failure.
263276

264-
277+
---
265278
### zstd\_uncompress\_init — Initialize an incremental uncompress context
266279

267280
#### Description
268281

269-
Zstd\\UnCompress\\Context **zstd\_uncompress\_init** ( void )
282+
``` php
283+
zstd_uncompress_init ( void ): Zstd\UnCompress\Context|false
284+
```
270285

271286
Initialize an incremental uncompress context
272287

273288
#### Return Values
274289

275290
Returns a zstd context instance on success, or FALSE on failure
276291

277-
292+
---
278293
### zstd\_uncompress\_add — Incrementally uncompress data
279294

280295
#### Description
281296

282-
string **zstd\_uncompress\_add** ( Zstd\\UnCompress\\Context _$context_, string _$data_ )
297+
``` php
298+
zstd_uncompress_add ( Zstd\UnCompress\Context $context, string $data ): string|false
299+
```
283300

284301
Incrementally uncompress data
285302

@@ -300,18 +317,17 @@ Returns a chunk of uncompressed data, or FALSE on failure.
300317

301318
## Namespace
302319

303-
```
320+
``` php
304321
Namespace Zstd;
305322

306-
function compress( $data [, $level = 3 ] )
307-
function uncompress( $data )
308-
function compress_dict ( $data, $dict )
309-
function uncompress_dict ( $data, $dict )
310-
function compress_init ( [ $level = 3 ] )
311-
function compress_add ( $context, $data [, $end = false ] )
312-
function uncompress_init ()
313-
function uncompress_add ( $context, $data )
314-
323+
function compress( string $data, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): string|false {}
324+
function uncompress( string $data ): string|false {}
325+
function compress_dict ( string $data, string $dict, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): string|false {}
326+
function uncompress_dict ( string $data, string $dict ): string|false {}
327+
function compress_init ( int $level = ZSTD_COMPRESS_LEVEL_DEFAULT ): \Zstd\Compress\Context|false {}
328+
function compress_add ( \Zstd\Compress\Context $context, string $data, bool $end = false ): string|false {}
329+
function uncompress_init (): \Zstd\UnCompress\Context|false {}
330+
function uncompress_add ( \Zstd\UnCompress\Context $context, string $data ): string|false
315331
```
316332

317333
`zstd_compress`, `zstd_uncompress`, `zstd_compress_dict`,

zstd.stub.php

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,43 @@
22

33
namespace {
44

5-
function zstd_compress(string $data, int $level = 3): string|false {}
5+
/**
6+
* @var int
7+
*/
8+
const ZSTD_COMPRESS_LEVEL_MIN = 1;
9+
10+
/**
11+
* @var int
12+
*/
13+
const ZSTD_COMPRESS_LEVEL_MAX = UNKNOWN;
14+
15+
/**
16+
* @var int
17+
* @cvalue ZSTD_CLEVEL_DEFAULT
18+
*/
19+
const ZSTD_COMPRESS_LEVEL_DEFAULT = UNKNOWN;
20+
21+
/**
22+
* @var int
23+
* @cvalue ZSTD_VERSION_NUMBER
24+
*/
25+
const ZSTD_VERSION_NUMBER = UNKNOWN;
26+
27+
/**
28+
* @var string
29+
* @cvalue ZSTD_VERSION_TEXT
30+
*/
31+
const ZSTD_VERSION_TEXT = UNKNOWN;
32+
33+
function zstd_compress(string $data, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): string|false {}
634

735
function zstd_uncompress(string $data): string|false {}
836

9-
function zstd_compress_dict(string $data, string $dict, int $level = DEFAULT_COMPRESS_LEVEL): string|false {}
37+
function zstd_compress_dict(string $data, string $dict, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): string|false {}
1038

1139
function zstd_uncompress_dict(string $data, string $dict): string|false {}
1240

13-
function zstd_compress_init(int $level = 3): Zstd\Compress\Context|false {}
41+
function zstd_compress_init(int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): Zstd\Compress\Context|false {}
1442

1543
function zstd_compress_add(Zstd\Compress\Context $context, string $data, bool $end = false): string|false {}
1644

@@ -22,15 +50,15 @@ function zstd_uncompress_add(Zstd\UnCompress\Context $context, string $data): st
2250

2351
namespace Zstd {
2452

25-
function compress(string $data, int $level = 3): string|false {}
53+
function compress(string $data, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): string|false {}
2654

2755
function uncompress(string $data): string|false {}
2856

29-
function compress_dict(string $data, string $dict, int $level = 3): string|false {}
57+
function compress_dict(string $data, string $dict, int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): string|false {}
3058

3159
function uncompress_dict(string $data, string $dict): string|false {}
3260

33-
function compress_init(int $level = 3): Compress\Context|false {}
61+
function compress_init(int $level = ZSTD_COMPRESS_LEVEL_DEFAULT): Compress\Context|false {}
3462

3563
function compress_add(Compress\Context $context, string $data, bool $end = false): string|false {}
3664

0 commit comments

Comments
 (0)