Skip to content

Commit 24191ef

Browse files
committed
Rewrap the PHP specs to 80 columns
Except for one doc-ref URL, since there's no reasonable way to wrap it.
1 parent bc2a53a commit 24191ef

File tree

2 files changed

+217
-59
lines changed

2 files changed

+217
-59
lines changed

archive/phar_without_stub.ksy

+121-30
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,45 @@ meta:
1111
- /serialization/php_serialized_value
1212
endian: le
1313
doc: |
14-
A phar (PHP archive) file. The phar format is a custom archive format from the PHP ecosystem that is used to package a complete PHP library or application into a single self-contained archive. All phar archives start with an executable PHP stub, which can be used to allow executing or including phar files as if they were regular PHP scripts. PHP 5.3 and later include the phar extension, which adds native support for reading and manipulating phar files.
14+
A phar (PHP archive) file. The phar format is a custom archive format
15+
from the PHP ecosystem that is used to package a complete PHP library
16+
or application into a single self-contained archive.
17+
All phar archives start with an executable PHP stub, which can be used to
18+
allow executing or including phar files as if they were regular PHP scripts.
19+
PHP 5.3 and later include the phar extension, which adds native support for
20+
reading and manipulating phar files.
1521
16-
The phar format was originally developed as part of the PEAR library PHP_Archive, first released in 2005. Later, a native PHP extension named "phar" was developed, which was first released on PECL in 2007, and is included with PHP 5.3 and later. The phar extension has effectively superseded the PHP_Archive library, which has not been updated since 2010. The phar extension is also no longer released independently on PECL; it is now developed and released as part of PHP itself.
22+
The phar format was originally developed as part of the PEAR library
23+
PHP_Archive, first released in 2005. Later, a native PHP extension
24+
named "phar" was developed, which was first released on PECL in 2007,
25+
and is included with PHP 5.3 and later. The phar extension has effectively
26+
superseded the PHP_Archive library, which has not been updated since 2010.
27+
The phar extension is also no longer released independently on PECL;
28+
it is now developed and released as part of PHP itself.
1729
18-
Because of current limitations in Kaitai Struct (see kaitai-io/kaitai_struct#158 and kaitai-io/kaitai_struct#538), the executable PHP stub that precedes the rest of the archive is not handled by this spec. Before parsing a phar using this spec, the stub must be removed manually.
30+
Because of current limitations in Kaitai Struct
31+
(seekaitai-io/kaitai_struct#158 and kaitai-io/kaitai_struct#538),
32+
the executable PHP stub that precedes the rest of the archive is not handled
33+
by this spec. Before parsing a phar using this spec, the stub must be
34+
removed manually.
1935
20-
A phar's stub is terminated by the special token `__HALT_COMPILER();` (which may be followed by at most one space, the PHP tag end `?>`, and an optional line terminator). The stub termination sequence is immediately followed by the remaining parts of the phar format, as described in this spec.
36+
A phar's stub is terminated by the special token `__HALT_COMPILER();`
37+
(which may be followed by at most one space, the PHP tag end `?>`,
38+
and an optional line terminator). The stub termination sequence is
39+
immediately followed by the remaining parts of the phar format,
40+
as described in this spec.
2141
22-
The phar stub usually contains code that loads the phar and runs a contained PHP file, but this is not required. A minimal valid phar stub is `<?php __HALT_COMPILER();` - such a stub makes it impossible to execute the phar directly, but still allows loading or manipulating it using the phar extension.
42+
The phar stub usually contains code that loads the phar and runs
43+
a contained PHP file, but this is not required. A minimal valid phar stub
44+
is `<?php __HALT_COMPILER();` - such a stub makes it impossible to execute
45+
the phar directly, but still allows loading or manipulating it using the
46+
phar extension.
2347
24-
Note: The phar format does not specify any encoding for text fields (stub, alias name, and all file names), so these fields may contain arbitrary binary data. The actual text encoding used in a specific phar file usually depends on the application that created the phar, and on the standard encoding of the system on which the phar was created.
48+
Note: The phar format does not specify any encoding for text fields
49+
(stub, alias name, and all file names), so these fields may contain arbitrary
50+
binary data. The actual text encoding used in a specific phar file usually
51+
depends on the application that created the phar, and on the
52+
standard encoding of the system on which the phar was created.
2553
doc-ref:
2654
- 'https://www.php.net/manual/en/phar.fileformat.php'
2755
- 'https://github.com/php/php-src/tree/master/ext/phar'
@@ -30,20 +58,29 @@ doc-ref:
3058
seq:
3159
- id: manifest
3260
type: manifest
33-
doc: The archive's manifest, containing general metadata about the archive and its files.
61+
doc: |
62+
The archive's manifest, containing general metadata about the archive
63+
and its files.
3464
- id: files
3565
size: manifest.file_entries[_index].len_data_compressed
3666
repeat: expr
3767
repeat-expr: manifest.num_files
38-
doc: The contents of each file in the archive (possibly compressed, as indicated by the file's flags in the manifest). The files are stored in the same order as they appear in the manifest.
68+
doc: |
69+
The contents of each file in the archive (possibly compressed,
70+
as indicated by the file's flags in the manifest). The files are stored
71+
in the same order as they appear in the manifest.
3972
- id: signature
4073
type: signature
4174
size-eos: true
4275
if: manifest.flags.has_signature
4376
doc: |
44-
The archive's signature - a digest of all archive data before the signature itself.
77+
The archive's signature - a digest of all archive data before
78+
the signature itself.
4579
46-
Note: Almost all of the available "signature" types are actually hashes, not signatures, and cannot be used to verify that the archive has not been tampered with. Only the OpenSSL signature type is a true cryptographic signature.
80+
Note: Almost all of the available "signature" types are actually hashes,
81+
not signatures, and cannot be used to verify that the archive has not
82+
been tampered with. Only the OpenSSL signature type is a true
83+
cryptographic signature.
4784
enums:
4885
signature_type:
4986
0x1:
@@ -57,18 +94,27 @@ enums:
5794
0x4:
5895
id: sha256
5996
-orig-id: PHAR_SIG_SHA256
60-
doc: Indicates a SHA-256 hash. Available since API version 1.1.0, PHP_Archive 0.12.0 and phar extension 1.1.0.
97+
doc: |
98+
Indicates a SHA-256 hash. Available since API version 1.1.0,
99+
PHP_Archive 0.12.0 and phar extension 1.1.0.
61100
0x8:
62101
id: sha512
63102
-orig-id: PHAR_SIG_SHA512
64-
doc: Indicates a SHA-512 hash. Available since API version 1.1.0, PHP_Archive 0.12.0 and phar extension 1.1.0.
103+
doc: |
104+
Indicates a SHA-512 hash. Available since API version 1.1.0,
105+
PHP_Archive 0.12.0 and phar extension 1.1.0.
65106
0x10:
66107
id: openssl
67108
-orig-id: PHAR_SIG_OPENSSL
68109
doc: |
69-
Indicates an OpenSSL signature. Available since API version 1.1.1, PHP_Archive 0.12.0 (even though it claims to only support API version 1.1.0) and phar extension 1.3.0. This type is not documented in the phar extension's documentation of the phar format.
110+
Indicates an OpenSSL signature. Available since API version 1.1.1,
111+
PHP_Archive 0.12.0 (even though it claims to only support
112+
API version 1.1.0) and phar extension 1.3.0. This type is not
113+
documented in the phar extension's documentation of the phar format.
70114
71-
Note: In older versions of the phar extension, this value was used for an undocumented and unimplemented "PGP" signature type (`PHAR_SIG_PGP`).
115+
Note: In older versions of the phar extension, this value was used
116+
for an undocumented and unimplemented "PGP" signature type
117+
(`PHAR_SIG_PGP`).
72118
types:
73119
serialized_value:
74120
seq:
@@ -105,13 +151,20 @@ types:
105151
doc: The length of the file name, in bytes.
106152
- id: filename
107153
size: len_filename
108-
doc: The name of this file. If the name ends with a slash, this entry represents a directory, otherwise a regular file. Directory entries are supported since phar API version 1.1.1. (Explicit directory entries are only needed for empty directories. Non-empty directories are implied by the files located inside them.)
154+
doc: |
155+
The name of this file. If the name ends with a slash, this entry
156+
represents a directory, otherwise a regular file. Directory entries
157+
are supported since phar API version 1.1.1.
158+
(Explicit directory entries are only needed for empty directories.
159+
Non-empty directories are implied by the files located inside them.)
109160
- id: len_data_uncompressed
110161
type: u4
111162
doc: The length of the file's data when uncompressed, in bytes.
112163
- id: timestamp
113164
type: u4
114-
doc: The time at which the file was added or last updated, as a Unix timestamp.
165+
doc: |
166+
The time at which the file was added or last updated, as a
167+
Unix timestamp.
115168
- id: len_data_compressed
116169
type: u4
117170
doc: The length of the file's data when compressed, in bytes.
@@ -128,7 +181,11 @@ types:
128181
size: len_metadata
129182
type: serialized_value
130183
if: len_metadata != 0
131-
doc: Metadata for this file, in the format used by PHP's `serialize` function. The meaning of the serialized data is not specified further, it may be used to store arbitrary custom data about the file.
184+
doc: |
185+
Metadata for this file, in the format used by PHP's
186+
`serialize` function. The meaning of the serialized data is not
187+
specified further, it may be used to store arbitrary custom data
188+
about the file.
132189
api_version:
133190
meta:
134191
endian: be
@@ -142,16 +199,38 @@ types:
142199
- id: unused
143200
type: b4
144201
doc: |
145-
A phar API version number. This version number is meant to indicate which features are used in a specific phar, so that tools reading the phar can easily check that they support all necessary features.
202+
A phar API version number. This version number is meant to indicate
203+
which features are used in a specific phar, so that tools reading
204+
the phar can easily check that they support all necessary features.
146205
147206
The following API versions exist so far:
148207
149-
* 0.5, 0.6, 0.7, 0.7.1: The first official API versions. At this point, the phar format was only used by the PHP_Archive library, and the API version numbers were identical to the PHP_Archive versions that supported them. Development of the native phar extension started around API version 0.7. These API versions could only be queried using the `PHP_Archive::APIversion()` method, but were not stored physically in archives. These API versions are not supported by this spec.
150-
* 0.8.0: Used by PHP_Archive 0.8.0 (released 2006-07-18) and later development versions of the phar extension. This is the first version number to be physically stored in archives. This API version is not supported by this spec.
151-
* 0.9.0: Used by later development/early beta versions of the phar extension. Also temporarily used by PHP_Archive 0.9.0 (released 2006-12-15), but reverted back to API version 0.8.0 in PHP_Archive 0.9.1 (released 2007-01-05).
152-
* 1.0.0: Supported since PHP_Archive 0.10.0 (released 2007-05-29) and phar extension 1.0.0 (released 2007-03-28). This is the first stable, forwards-compatible and documented version of the format.
153-
* 1.1.0: Supported since PHP_Archive 0.12.0 (released 2015-07-06) and phar extension 1.1.0 (released 2007-04-12). Adds SHA-256 and SHA-512 signature types.
154-
* 1.1.1: Supported since phar extension 2.0.0 (released 2009-07-29 and included with PHP 5.3 and later). (PHP_Archive 0.12.0 also supports all features from API verison 1.1.1, but it reports API version 1.1.0.) Adds the OpenSSL signature type and support for storing empty directories.
208+
* 0.5, 0.6, 0.7, 0.7.1: The first official API versions. At this point,
209+
the phar format was only used by the PHP_Archive library, and the
210+
API version numbers were identical to the PHP_Archive versions that
211+
supported them. Development of the native phar extension started around
212+
API version 0.7. These API versions could only be queried using the
213+
`PHP_Archive::APIversion()` method, but were not stored physically
214+
in archives. These API versions are not supported by this spec.
215+
* 0.8.0: Used by PHP_Archive 0.8.0 (released 2006-07-18) and
216+
later development versions of the phar extension. This is the first
217+
version number to be physically stored in archives. This API version
218+
is not supported by this spec.
219+
* 0.9.0: Used by later development/early beta versions of the
220+
phar extension. Also temporarily used by PHP_Archive 0.9.0
221+
(released 2006-12-15), but reverted back to API version 0.8.0 in
222+
PHP_Archive 0.9.1 (released 2007-01-05).
223+
* 1.0.0: Supported since PHP_Archive 0.10.0 (released 2007-05-29)
224+
and phar extension 1.0.0 (released 2007-03-28). This is the first
225+
stable, forwards-compatible and documented version of the format.
226+
* 1.1.0: Supported since PHP_Archive 0.12.0 (released 2015-07-06)
227+
and phar extension 1.1.0 (released 2007-04-12). Adds SHA-256 and
228+
SHA-512 signature types.
229+
* 1.1.1: Supported since phar extension 2.0.0 (released 2009-07-29 and
230+
included with PHP 5.3 and later). (PHP_Archive 0.12.0 also supports
231+
all features from API verison 1.1.1, but it reports API version 1.1.0.)
232+
Adds the OpenSSL signature type and support for storing
233+
empty directories.
155234
global_flags:
156235
seq:
157236
- id: value
@@ -161,11 +240,15 @@ types:
161240
any_zlib_compressed:
162241
value: (value & 0x1000) != 0
163242
-orig-id: PHAR_HDR_COMPRESSED_GZ
164-
doc: Whether any of the files in this phar are stored using zlib compression.
243+
doc: |
244+
Whether any of the files in this phar are stored using
245+
zlib compression.
165246
any_bzip2_compressed:
166247
value: (value & 0x2000) != 0
167248
-orig-id: PHAR_HDR_COMPRESSED_BZ2
168-
doc: Whether any of the files in this phar are stored using bzip2 compression.
249+
doc: |
250+
Whether any of the files in this phar are stored using
251+
bzip2 compression.
169252
has_signature:
170253
value: (value & 0x10000) != 0
171254
-orig-id: PHAR_HDR_SIGNATURE
@@ -177,7 +260,8 @@ types:
177260
doc: |
178261
The length of the manifest, in bytes.
179262
180-
Note: The phar extension does not allow reading manifests larger than 100 MiB.
263+
Note: The phar extension does not allow reading manifests
264+
larger than 100 MiB.
181265
- id: num_files
182266
type: u4
183267
doc: The number of files in this phar.
@@ -192,15 +276,20 @@ types:
192276
doc: The length of the alias, in bytes.
193277
- id: alias
194278
size: len_alias
195-
doc: The phar's alias, i. e. the name under which it is loaded into PHP.
279+
doc: |
280+
The phar's alias, i. e. the name under which it is loaded into PHP.
196281
- id: len_metadata
197282
type: u4
198283
doc: The size of the metadata, in bytes, or 0 if there is none.
199284
- id: metadata
200285
size: len_metadata
201286
type: serialized_value
202287
if: len_metadata != 0
203-
doc: Metadata for this phar, in the format used by PHP's `serialize` function. The meaning of the serialized data is not specified further, it may be used to store arbitrary custom data about the archive.
288+
doc: |
289+
Metadata for this phar, in the format used by PHP's
290+
`serialize` function. The meaning of the serialized data is not
291+
specified further, it may be used to store arbitrary custom data
292+
about the archive.
204293
- id: file_entries
205294
type: file_entry
206295
repeat: expr
@@ -210,7 +299,9 @@ types:
210299
seq:
211300
- id: data
212301
size: _io.size - _io.pos - 8
213-
doc: The signature data. The size and contents depend on the signature type.
302+
doc: |
303+
The signature data. The size and contents depend on the
304+
signature type.
214305
- id: type
215306
type: u4
216307
enum: signature_type

0 commit comments

Comments
 (0)