Skip to content

Commit cb5eaea

Browse files
committed
Docs: Correct PHPDoc types in the AVIF info parser.
Several types in the bundled copy of libavifinfo are not PHPDoc types: `binary string`, `stream`, and `Status`, the last of which stands for the integer status constants. In the `Avifinfo` namespace each one resolves to a nonexistent class, and four methods also documented a `$handle` parameter that they do not take. These are replaced with `string`, `resource`, and `int`, and the stale tags are removed. Only docblocks change. The file is excluded from PHPStan analysis as third-party code, so the baselines do not record the resulting errors. They do reach the php-stubs/wordpress-stubs package, whose generator has to rewrite the `binary string` tags before generating the stubs. Developed in #15198. Follow-up to r57524. Props westonruter, mukesh27, adamsilverstein, szepeviktor. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@65047 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 072110f commit cb5eaea

1 file changed

Lines changed: 25 additions & 29 deletions

File tree

‎src/wp-includes/class-avif-info.php‎

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
/**
3636
* Reads an unsigned integer with most significant bits first.
3737
*
38-
* @param binary string $input Must be at least $num_bytes-long.
39-
* @param int $num_bytes Number of parsed bytes.
40-
* @return int Value.
38+
* @param string $input Must be at least $num_bytes-long.
39+
* @param int $num_bytes Number of parsed bytes.
40+
* @return int Value.
4141
*/
4242
function read_big_endian( $input, $num_bytes ) {
4343
if ( $num_bytes == 1 ) {
@@ -57,9 +57,9 @@ function read_big_endian( $input, $num_bytes ) {
5757
/**
5858
* Reads bytes and advances the stream position by the same count.
5959
*
60-
* @param stream $handle Bytes will be read from this resource.
61-
* @param int $num_bytes Number of bytes read. Must be greater than 0.
62-
* @return binary string|false The raw bytes or false on failure.
60+
* @param resource $handle Bytes will be read from this resource.
61+
* @param int $num_bytes Number of bytes read. Must be greater than 0.
62+
* @return string|false The raw bytes or false on failure.
6363
*/
6464
function read( $handle, $num_bytes ) {
6565
$data = fread( $handle, $num_bytes );
@@ -69,9 +69,9 @@ function read( $handle, $num_bytes ) {
6969
/**
7070
* Advances the stream position by the given offset.
7171
*
72-
* @param stream $handle Bytes will be skipped from this resource.
73-
* @param int $num_bytes Number of skipped bytes. Can be 0.
74-
* @return bool True on success or false on failure.
72+
* @param resource $handle Bytes will be skipped from this resource.
73+
* @param int $num_bytes Number of skipped bytes. Can be 0.
74+
* @return bool True on success or false on failure.
7575
*/
7676
// Skips 'num_bytes' from the 'stream'. 'num_bytes' can be zero.
7777
function skip( $handle, $num_bytes ) {
@@ -123,9 +123,9 @@ class Features {
123123
/**
124124
* Binds the width, height, bit depth and number of channels from stored internal features.
125125
*
126-
* @param int $target_item_id Id of the item whose features will be bound.
127-
* @param int $tile_depth Maximum recursion to search within tile-parent relations.
128-
* @return Status FOUND on success or NOT_FOUND on failure.
126+
* @param int $target_item_id Id of the item whose features will be bound.
127+
* @param int $tile_depth Maximum recursion to search within tile-parent relations.
128+
* @return int FOUND on success or NOT_FOUND on failure.
129129
*/
130130
private function get_item_features( $target_item_id, $tile_depth ) {
131131
foreach ( $this->props as $prop ) {
@@ -187,7 +187,7 @@ private function get_item_features( $target_item_id, $tile_depth ) {
187187
/**
188188
* Finds the width, height, bit depth and number of channels of the primary item.
189189
*
190-
* @return Status FOUND on success or NOT_FOUND on failure.
190+
* @return int FOUND on success or NOT_FOUND on failure.
191191
*/
192192
public function get_primary_item_features() {
193193
// Nothing to do without the primary item ID.
@@ -223,10 +223,10 @@ class Box {
223223
/**
224224
* Reads the box header.
225225
*
226-
* @param stream $handle The resource the header will be parsed from.
227-
* @param int $num_parsed_boxes The total number of parsed boxes. Prevents timeouts.
228-
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
229-
* @return Status FOUND on success or an error on failure.
226+
* @param resource $handle The resource the header will be parsed from.
227+
* @param int $num_parsed_boxes The total number of parsed boxes. Prevents timeouts.
228+
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
229+
* @return int FOUND on success or an error on failure.
230230
*/
231231
public function parse( $handle, &$num_parsed_boxes, $num_remaining_bytes = MAX_SIZE ) {
232232
// See ISO/IEC 14496-12:2012(E) 4.2
@@ -336,9 +336,8 @@ function __construct( $handle ) {
336336
* "ispe" is used for width and height, "pixi" and "av1C" are used for bit depth
337337
* and number of channels, and "auxC" is used for alpha.
338338
*
339-
* @param stream $handle The resource the box will be parsed from.
340-
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
341-
* @return Status FOUND on success or an error on failure.
339+
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
340+
* @return int FOUND on success or an error on failure.
342341
*/
343342
private function parse_ipco( $num_remaining_bytes ) {
344343
$box_index = 1; // 1-based index. Used for iterating over properties.
@@ -492,9 +491,8 @@ private function parse_ipco( $num_remaining_bytes ) {
492491
*
493492
* The "ipco" box contains the properties which are linked to items by the "ipma" box.
494493
*
495-
* @param stream $handle The resource the box will be parsed from.
496-
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
497-
* @return Status FOUND on success or an error on failure.
494+
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
495+
* @return int FOUND on success or an error on failure.
498496
*/
499497
private function parse_iprp( $num_remaining_bytes ) {
500498
do {
@@ -598,9 +596,8 @@ private function parse_iprp( $num_remaining_bytes ) {
598596
* can be used to infer bit depth and number of channels for the primary item
599597
* when the latter does not have these properties.
600598
*
601-
* @param stream $handle The resource the box will be parsed from.
602-
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
603-
* @return Status FOUND on success or an error on failure.
599+
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
600+
* @return int FOUND on success or an error on failure.
604601
*/
605602
private function parse_iref( $num_remaining_bytes ) {
606603
while ( $num_remaining_bytes > 0 ) {
@@ -673,9 +670,8 @@ private function parse_iref( $num_remaining_bytes ) {
673670
* It looks for the primary item ID in the "pitm" box and recurses into other boxes
674671
* to find its features.
675672
*
676-
* @param stream $handle The resource the box will be parsed from.
677-
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
678-
* @return Status FOUND on success or an error on failure.
673+
* @param int $num_remaining_bytes The number of bytes that should be available from the resource.
674+
* @return int FOUND on success or an error on failure.
679675
*/
680676
private function parse_meta( $num_remaining_bytes ) {
681677
do {

0 commit comments

Comments
 (0)