Skip to content

Commit 4ca8287

Browse files
committed
ext/phar: changing few methods returning true to void ones.
1 parent 3821938 commit 4ca8287

File tree

5 files changed

+36
-48
lines changed

5 files changed

+36
-48
lines changed

UPGRADING

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ PHP 8.3 UPGRADE NOTES
8686
Underscores must be encoded as "=5F" in such MIME encoded words.
8787
(Alex Dowad)
8888

89+
- Phar:
90+
. Phar::delete, Phar::decompress, Phar::decompressFiles, Phar::copy,
91+
Phar::delMetadata, Phar::setStub, Phar::unlinkArchive,
92+
PharFileInfo::compress, PharFileInfo::decompress, PharFileInfo::delMetadata
93+
no longer return true on success.
94+
8995
- Standard:
9096
. E_NOTICEs emitted by unserialized() have been promoted to E_WARNING.
9197
RFC: https://wiki.php.net/rfc/improve_unserialize_error_handling

ext/phar/phar_object.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,6 @@ PHP_METHOD(Phar, unlinkArchive)
13311331
phar_archive_delref(phar);
13321332
unlink(fname);
13331333
efree(fname);
1334-
RETURN_TRUE;
13351334
}
13361335
/* }}} */
13371336

@@ -2609,7 +2608,7 @@ PHP_METHOD(Phar, delete)
26092608
if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint32_t) fname_len))) {
26102609
if (entry->is_deleted) {
26112610
/* entry is deleted, but has not been flushed to disk yet */
2612-
RETURN_TRUE;
2611+
return;
26132612
} else {
26142613
entry->is_deleted = 1;
26152614
entry->is_modified = 1;
@@ -2626,8 +2625,6 @@ PHP_METHOD(Phar, delete)
26262625
efree(error);
26272626
RETURN_THROWS();
26282627
}
2629-
2630-
RETURN_TRUE;
26312628
}
26322629
/* }}} */
26332630

@@ -2872,7 +2869,7 @@ PHP_METHOD(Phar, setStub)
28722869
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
28732870
efree(error);
28742871
}
2875-
RETURN_TRUE;
2872+
return;
28762873
} else {
28772874
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
28782875
"Cannot change stub, unable to read from input stream");
@@ -2890,7 +2887,7 @@ PHP_METHOD(Phar, setStub)
28902887
RETURN_THROWS();
28912888
}
28922889

2893-
RETURN_TRUE;
2890+
return;
28942891
}
28952892

28962893
RETURN_THROWS();
@@ -3362,7 +3359,7 @@ PHP_METHOD(Phar, decompressFiles)
33623359
}
33633360

33643361
if (phar_obj->archive->is_tar) {
3365-
RETURN_TRUE;
3362+
return;
33663363
} else {
33673364
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
33683365
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
@@ -3378,8 +3375,6 @@ PHP_METHOD(Phar, decompressFiles)
33783375
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
33793376
efree(error);
33803377
}
3381-
3382-
RETURN_TRUE;
33833378
}
33843379
/* }}} */
33853380

@@ -3473,8 +3468,6 @@ PHP_METHOD(Phar, copy)
34733468
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
34743469
efree(error);
34753470
}
3476-
3477-
RETURN_TRUE;
34783471
}
34793472
/* }}} */
34803473

@@ -4062,7 +4055,7 @@ PHP_METHOD(Phar, delMetadata)
40624055
}
40634056

40644057
if (!phar_metadata_tracker_has_data(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent)) {
4065-
RETURN_TRUE;
4058+
return;
40664059
}
40674060

40684061
phar_metadata_tracker_free(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent);
@@ -4073,8 +4066,6 @@ PHP_METHOD(Phar, delMetadata)
40734066
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
40744067
efree(error);
40754068
RETURN_THROWS();
4076-
} else {
4077-
RETURN_TRUE;
40784069
}
40794070
}
40804071
/* }}} */
@@ -4771,12 +4762,7 @@ PHP_METHOD(PharFileInfo, delMetadata)
47714762
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
47724763
efree(error);
47734764
RETURN_THROWS();
4774-
} else {
4775-
RETURN_TRUE;
47764765
}
4777-
4778-
} else {
4779-
RETURN_TRUE;
47804766
}
47814767
}
47824768
/* }}} */
@@ -4879,7 +4865,7 @@ PHP_METHOD(PharFileInfo, compress)
48794865
switch (method) {
48804866
case PHAR_ENT_COMPRESSED_GZ:
48814867
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) {
4882-
RETURN_TRUE;
4868+
return;
48834869
}
48844870

48854871
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
@@ -4910,7 +4896,7 @@ PHP_METHOD(PharFileInfo, compress)
49104896
break;
49114897
case PHAR_ENT_COMPRESSED_BZ2:
49124898
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
4913-
RETURN_TRUE;
4899+
return;
49144900
}
49154901

49164902
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
@@ -4952,8 +4938,6 @@ PHP_METHOD(PharFileInfo, compress)
49524938
efree(error);
49534939
RETURN_THROWS();
49544940
}
4955-
4956-
RETURN_TRUE;
49574941
}
49584942
/* }}} */
49594943

@@ -4976,7 +4960,7 @@ PHP_METHOD(PharFileInfo, decompress)
49764960
}
49774961

49784962
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
4979-
RETURN_TRUE;
4963+
return;
49804964
}
49814965

49824966
if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
@@ -5044,8 +5028,6 @@ PHP_METHOD(PharFileInfo, decompress)
50445028
efree(error);
50455029
RETURN_THROWS();
50465030
}
5047-
5048-
RETURN_TRUE;
50495031
}
50505032
/* }}} */
50515033

ext/phar/phar_object.stub.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function buildFromIterator(Traversable $iterator, ?string $baseDirectory
112112
public function compressFiles(int $compression): void {}
113113

114114
/** @return bool */
115-
public function decompressFiles() {} // TODO make return type void
115+
public function decompressFiles() {}
116116

117117
/** @tentative-return-type */
118118
public function compress(int $compression, ?string $extension = null): ?Phar {}
@@ -127,16 +127,16 @@ public function convertToExecutable(?int $format = null, ?int $compression = nul
127127
public function convertToData(?int $format = null, ?int $compression = null, ?string $extension = null): ?PharData {}
128128

129129
/** @return bool */
130-
public function copy(string $from, string $to) {} // TODO make return type void
130+
public function copy(string $from, string $to) {}
131131

132132
/** @tentative-return-type */
133133
public function count(int $mode = COUNT_NORMAL): int {}
134134

135135
/** @return bool */
136-
public function delete(string $localName) {} // TODO make return type void
136+
public function delete(string $localName) {}
137137

138138
/** @return bool */
139-
public function delMetadata() {} // TODO make return type void
139+
public function delMetadata() {}
140140

141141
/** @tentative-return-type */
142142
public function extractTo(string $directory, array|string|null $files = null, bool $overwrite = false): bool {}
@@ -218,7 +218,7 @@ public function setSignatureAlgorithm(int $algo, ?string $privateKey = null): vo
218218
* @param resource|string $stub
219219
* @return bool
220220
*/
221-
public function setStub($stub, int $length = UNKNOWN) {} // TODO make return type void
221+
public function setStub($stub, int $length = UNKNOWN) {}
222222

223223
/** @tentative-return-type */
224224
public function startBuffering(): void {}
@@ -252,7 +252,7 @@ final public static function mount(string $pharPath, string $externalPath): void
252252

253253
final public static function mungServer(array $variables): void {}
254254

255-
final public static function unlinkArchive(string $filename): bool {} // TODO make return type void
255+
final public static function unlinkArchive(string $filename): bool {}
256256

257257
final public static function webPhar(
258258
?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null,
@@ -310,7 +310,7 @@ public function compressFiles(int $compression): void {}
310310
* @return bool
311311
* @implementation-alias Phar::decompressFiles
312312
*/
313-
public function decompressFiles() {} // TODO make return type void
313+
public function decompressFiles() {}
314314

315315
/**
316316
* @tentative-return-type
@@ -342,7 +342,7 @@ public function convertToData(?int $format = null, ?int $compression = null, ?st
342342
* @return bool
343343
* @implementation-alias Phar::copy
344344
*/
345-
public function copy(string $from, string $to) {} // TODO make return type void
345+
public function copy(string $from, string $to) {}
346346

347347
/**
348348
* @tentative-return-type
@@ -354,13 +354,13 @@ public function count(int $mode = COUNT_NORMAL): int {}
354354
* @return bool
355355
* @implementation-alias Phar::delete
356356
*/
357-
public function delete(string $localName) {} // TODO make return type void
357+
public function delete(string $localName) {}
358358

359359
/**
360360
* @return bool
361361
* @implementation-alias Phar::delMetadata
362362
*/
363-
public function delMetadata() {} // TODO make return type void
363+
public function delMetadata() {}
364364

365365
/**
366366
* @tentative-return-type
@@ -498,7 +498,7 @@ public function setSignatureAlgorithm(int $algo, ?string $privateKey = null): vo
498498
* @return bool
499499
* @implementation-alias Phar::setStub
500500
*/
501-
public function setStub($stub, int $length = UNKNOWN) {} // TODO make return type void
501+
public function setStub($stub, int $length = UNKNOWN) {}
502502

503503
/**
504504
* @tentative-return-type
@@ -552,7 +552,7 @@ final public static function mount(string $pharPath, string $externalPath): void
552552
final public static function mungServer(array $variables): void {}
553553

554554
/** @implementation-alias Phar::unlinkArchive */
555-
final public static function unlinkArchive(string $filename): bool {} // TODO make return type void
555+
final public static function unlinkArchive(string $filename): bool {}
556556

557557
/** @implementation-alias Phar::webPhar */
558558
final public static function webPhar(
@@ -570,13 +570,13 @@ public function __destruct() {}
570570
public function chmod(int $perms): void {}
571571

572572
/** @return bool */
573-
public function compress(int $compression) {} // TODO make return type void
573+
public function compress(int $compression) {}
574574

575575
/** @return bool */
576-
public function decompress() {} // TODO make return type void
576+
public function decompress() {}
577577

578578
/** @return bool */
579-
public function delMetadata() {} // TODO make return type void
579+
public function delMetadata() {}
580580

581581
/** @tentative-return-type */
582582
public function getCompressedSize(): int {}

ext/phar/phar_object_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/phar/tests/phar_metadata_read.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ string(1) "c"
5353
string(1) "d"
5454
bool(true)
5555
string(8) "hi there"
56-
bool(true)
5756
NULL
58-
bool(true)
57+
NULL
58+
NULL
5959
NULL
6060
meta a
6161
bool(false)
6262
NULL
63-
bool(true)
63+
NULL
6464
NULL
6565
meta b
6666
bool(false)
6767
NULL
68-
bool(true)
68+
NULL
6969
NULL
7070
meta c
7171
bool(true)
@@ -75,7 +75,7 @@ array(2) {
7575
[1]=>
7676
string(5) "there"
7777
}
78-
bool(true)
78+
NULL
7979
NULL
8080
meta d
8181
bool(true)
@@ -85,7 +85,7 @@ array(2) {
8585
["foo"]=>
8686
string(3) "bar"
8787
}
88-
bool(true)
88+
NULL
8989
NULL
9090
string(1) "a"
9191
string(1) "b"

0 commit comments

Comments
 (0)