diff --git a/UPGRADING b/UPGRADING index 21fd5018a96e5..11b3ee4d63653 100644 --- a/UPGRADING +++ b/UPGRADING @@ -86,6 +86,12 @@ PHP 8.3 UPGRADE NOTES Underscores must be encoded as "=5F" in such MIME encoded words. (Alex Dowad) +- Phar: + . Phar::delete, Phar::decompress, Phar::decompressFiles, Phar::copy, + Phar::delMetadata, Phar::setStub, Phar::unlinkArchive, + PharFileInfo::compress, PharFileInfo::decompress, PharFileInfo::delMetadata + no longer return true on success. + - Standard: . E_NOTICEs emitted by unserialized() have been promoted to E_WARNING. RFC: https://wiki.php.net/rfc/improve_unserialize_error_handling diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index ba47cd88439c5..25311f4be5002 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1331,7 +1331,6 @@ PHP_METHOD(Phar, unlinkArchive) phar_archive_delref(phar); unlink(fname); efree(fname); - RETURN_TRUE; } /* }}} */ @@ -2609,7 +2608,7 @@ PHP_METHOD(Phar, delete) if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint32_t) fname_len))) { if (entry->is_deleted) { /* entry is deleted, but has not been flushed to disk yet */ - RETURN_TRUE; + return; } else { entry->is_deleted = 1; entry->is_modified = 1; @@ -2626,8 +2625,6 @@ PHP_METHOD(Phar, delete) efree(error); RETURN_THROWS(); } - - RETURN_TRUE; } /* }}} */ @@ -2872,7 +2869,7 @@ PHP_METHOD(Phar, setStub) zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } - RETURN_TRUE; + return; } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub, unable to read from input stream"); @@ -2890,7 +2887,7 @@ PHP_METHOD(Phar, setStub) RETURN_THROWS(); } - RETURN_TRUE; + return; } RETURN_THROWS(); @@ -3362,7 +3359,7 @@ PHP_METHOD(Phar, decompressFiles) } if (phar_obj->archive->is_tar) { - RETURN_TRUE; + return; } else { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { 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) zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error); efree(error); } - - RETURN_TRUE; } /* }}} */ @@ -3473,8 +3468,6 @@ PHP_METHOD(Phar, copy) zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } - - RETURN_TRUE; } /* }}} */ @@ -4062,7 +4055,7 @@ PHP_METHOD(Phar, delMetadata) } if (!phar_metadata_tracker_has_data(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent)) { - RETURN_TRUE; + return; } phar_metadata_tracker_free(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent); @@ -4073,8 +4066,6 @@ PHP_METHOD(Phar, delMetadata) zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_THROWS(); - } else { - RETURN_TRUE; } } /* }}} */ @@ -4771,12 +4762,7 @@ PHP_METHOD(PharFileInfo, delMetadata) zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_THROWS(); - } else { - RETURN_TRUE; } - - } else { - RETURN_TRUE; } } /* }}} */ @@ -4879,7 +4865,7 @@ PHP_METHOD(PharFileInfo, compress) switch (method) { case PHAR_ENT_COMPRESSED_GZ: if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) { - RETURN_TRUE; + return; } if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) { @@ -4910,7 +4896,7 @@ PHP_METHOD(PharFileInfo, compress) break; case PHAR_ENT_COMPRESSED_BZ2: if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) { - RETURN_TRUE; + return; } if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) { @@ -4952,8 +4938,6 @@ PHP_METHOD(PharFileInfo, compress) efree(error); RETURN_THROWS(); } - - RETURN_TRUE; } /* }}} */ @@ -4976,7 +4960,7 @@ PHP_METHOD(PharFileInfo, decompress) } if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) { - RETURN_TRUE; + return; } if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) { @@ -5044,8 +5028,6 @@ PHP_METHOD(PharFileInfo, decompress) efree(error); RETURN_THROWS(); } - - RETURN_TRUE; } /* }}} */ diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index 3004a1ee83f43..6ce9a9c90b6c8 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -112,7 +112,7 @@ public function buildFromIterator(Traversable $iterator, ?string $baseDirectory public function compressFiles(int $compression): void {} /** @return bool */ - public function decompressFiles() {} // TODO make return type void + public function decompressFiles(): void {} /** @tentative-return-type */ public function compress(int $compression, ?string $extension = null): ?Phar {} @@ -127,16 +127,16 @@ public function convertToExecutable(?int $format = null, ?int $compression = nul public function convertToData(?int $format = null, ?int $compression = null, ?string $extension = null): ?PharData {} /** @return bool */ - public function copy(string $from, string $to) {} // TODO make return type void + public function copy(string $from, string $to): void {} /** @tentative-return-type */ public function count(int $mode = COUNT_NORMAL): int {} /** @return bool */ - public function delete(string $localName) {} // TODO make return type void + public function delete(string $localName): void {} /** @return bool */ - public function delMetadata() {} // TODO make return type void + public function delMetadata(): void {} /** @tentative-return-type */ 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 * @param resource|string $stub * @return bool */ - public function setStub($stub, int $length = UNKNOWN) {} // TODO make return type void + public function setStub($stub, int $length = UNKNOWN): void {} /** @tentative-return-type */ public function startBuffering(): void {} @@ -252,7 +252,7 @@ final public static function mount(string $pharPath, string $externalPath): void final public static function mungServer(array $variables): void {} - final public static function unlinkArchive(string $filename): bool {} // TODO make return type void + final public static function unlinkArchive(string $filename): void {} final public static function webPhar( ?string $alias = null, ?string $index = null, ?string $fileNotFoundScript = null, @@ -310,7 +310,7 @@ public function compressFiles(int $compression): void {} * @return bool * @implementation-alias Phar::decompressFiles */ - public function decompressFiles() {} // TODO make return type void + public function decompressFiles(): void {} /** * @tentative-return-type @@ -342,7 +342,7 @@ public function convertToData(?int $format = null, ?int $compression = null, ?st * @return bool * @implementation-alias Phar::copy */ - public function copy(string $from, string $to) {} // TODO make return type void + public function copy(string $from, string $to): void {} /** * @tentative-return-type @@ -354,13 +354,13 @@ public function count(int $mode = COUNT_NORMAL): int {} * @return bool * @implementation-alias Phar::delete */ - public function delete(string $localName) {} // TODO make return type void + public function delete(string $localName): void {} /** * @return bool * @implementation-alias Phar::delMetadata */ - public function delMetadata() {} // TODO make return type void + public function delMetadata(): void {} /** * @tentative-return-type @@ -498,7 +498,7 @@ public function setSignatureAlgorithm(int $algo, ?string $privateKey = null): vo * @return bool * @implementation-alias Phar::setStub */ - public function setStub($stub, int $length = UNKNOWN) {} // TODO make return type void + public function setStub($stub, int $length = UNKNOWN): void {} /** * @tentative-return-type @@ -552,7 +552,7 @@ final public static function mount(string $pharPath, string $externalPath): void final public static function mungServer(array $variables): void {} /** @implementation-alias Phar::unlinkArchive */ - final public static function unlinkArchive(string $filename): bool {} // TODO make return type void + final public static function unlinkArchive(string $filename): void {} /** @implementation-alias Phar::webPhar */ final public static function webPhar( @@ -570,13 +570,13 @@ public function __destruct() {} public function chmod(int $perms): void {} /** @return bool */ - public function compress(int $compression) {} // TODO make return type void + public function compress(int $compression): void {} /** @return bool */ - public function decompress() {} // TODO make return type void + public function decompress(): void {} /** @return bool */ - public function delMetadata() {} // TODO make return type void + public function delMetadata(): void {} /** @tentative-return-type */ public function getCompressedSize(): int {} diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index 17d96a94a0eb8..3caaeda4ad835 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 799b653b10dbdfa58747e41715700cfd5300fa4f */ + * Stub hash: 41840da6ed7a777dfec290a67751f6e812ad91eb */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -38,7 +38,8 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_compressFil ZEND_ARG_TYPE_INFO(0, compression, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Phar_decompressFiles arginfo_class_Phar___destruct +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_decompressFiles, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_Phar_compress, 0, 1, Phar, 1) ZEND_ARG_TYPE_INFO(0, compression, IS_LONG, 0) @@ -61,7 +62,7 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_Phar_convertToDat ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extension, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_copy, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_copy, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -70,11 +71,11 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_count, 0, 0 ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "COUNT_NORMAL") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_delete, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_delete, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Phar_delMetadata arginfo_class_Phar___destruct +#define arginfo_class_Phar_delMetadata arginfo_class_Phar_decompressFiles ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_extractTo, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 0) @@ -150,7 +151,7 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Phar_setSignatur ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, privateKey, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setStub, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_setStub, 0, 1, IS_VOID, 0) ZEND_ARG_INFO(0, stub) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -180,8 +181,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_Phar_getSupportedSignatures arginfo_class_Phar_getSupportedCompression -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_interceptFileFuncs, 0, 0, IS_VOID, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_Phar_interceptFileFuncs arginfo_class_Phar_decompressFiles ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_isValidPharFilename, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -211,7 +211,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_mungServer, 0, 1, IS_ ZEND_ARG_TYPE_INFO(0, variables, IS_ARRAY, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_unlinkArchive, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_unlinkArchive, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -244,7 +244,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharData_compressFiles arginfo_class_Phar_compressFiles -#define arginfo_class_PharData_decompressFiles arginfo_class_Phar___destruct +#define arginfo_class_PharData_decompressFiles arginfo_class_Phar_decompressFiles ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_PharData_compress, 0, 1, PharData, 1) ZEND_ARG_TYPE_INFO(0, compression, IS_LONG, 0) @@ -265,7 +265,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharData_delete arginfo_class_Phar_delete -#define arginfo_class_PharData_delMetadata arginfo_class_Phar___destruct +#define arginfo_class_PharData_delMetadata arginfo_class_Phar_decompressFiles #define arginfo_class_PharData_extractTo arginfo_class_Phar_extractTo @@ -327,7 +327,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharData_getSupportedSignatures arginfo_class_Phar_getSupportedCompression -#define arginfo_class_PharData_interceptFileFuncs arginfo_class_Phar_interceptFileFuncs +#define arginfo_class_PharData_interceptFileFuncs arginfo_class_Phar_decompressFiles #define arginfo_class_PharData_isValidPharFilename arginfo_class_Phar_isValidPharFilename @@ -355,13 +355,13 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_PharFileInfo_chm ZEND_ARG_TYPE_INFO(0, perms, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_compress, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_PharFileInfo_compress, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, compression, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_PharFileInfo_decompress arginfo_class_Phar___destruct +#define arginfo_class_PharFileInfo_decompress arginfo_class_Phar_decompressFiles -#define arginfo_class_PharFileInfo_delMetadata arginfo_class_Phar___destruct +#define arginfo_class_PharFileInfo_delMetadata arginfo_class_Phar_decompressFiles ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_PharFileInfo_getCompressedSize, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/phar/tests/bug76584.phpt b/ext/phar/tests/bug76584.phpt index 6e729ce0b7321..0d9f8b480f623 100644 --- a/ext/phar/tests/bug76584.phpt +++ b/ext/phar/tests/bug76584.phpt @@ -19,9 +19,9 @@ var_dump($phar->extractTo(__DIR__ . '/76584')); echo file_get_contents(__DIR__ . '/76584/76584.txt'); ?> --EXPECT-- +NULL bool(true) -bool(true) -bool(true) +NULL bool(false) bool(true) This is a test file. diff --git a/ext/phar/tests/bug79912.phpt b/ext/phar/tests/bug79912.phpt index dba9fd17a1b25..69bcabf4bdb4d 100644 --- a/ext/phar/tests/bug79912.phpt +++ b/ext/phar/tests/bug79912.phpt @@ -19,10 +19,10 @@ var_dump($phar->extractTo(__DIR__ . "/bug79912")); //true var_dump(file_get_contents(__DIR__ . "/bug79912/test.txt")); //the extracted file in the folder should be decompressed ?> --EXPECT-- -bool(true) +NULL string(60) "This is a test file.This is a test file.This is a test file." bool(true) -bool(true) +NULL bool(false) bool(true) string(60) "This is a test file.This is a test file.This is a test file." diff --git a/ext/phar/tests/phar_metadata_read.phpt b/ext/phar/tests/phar_metadata_read.phpt index f8b0f670bcbb9..37c9194c0b807 100644 --- a/ext/phar/tests/phar_metadata_read.phpt +++ b/ext/phar/tests/phar_metadata_read.phpt @@ -53,19 +53,19 @@ string(1) "c" string(1) "d" bool(true) string(8) "hi there" -bool(true) NULL -bool(true) +NULL +NULL NULL meta a bool(false) NULL -bool(true) +NULL NULL meta b bool(false) NULL -bool(true) +NULL NULL meta c bool(true) @@ -75,7 +75,7 @@ array(2) { [1]=> string(5) "there" } -bool(true) +NULL NULL meta d bool(true) @@ -85,7 +85,7 @@ array(2) { ["foo"]=> string(3) "bar" } -bool(true) +NULL NULL string(1) "a" string(1) "b" diff --git a/ext/phar/tests/pharfileinfo_compression.phpt b/ext/phar/tests/pharfileinfo_compression.phpt index ec016cc9d2b8c..ffed7c25c7d75 100644 --- a/ext/phar/tests/pharfileinfo_compression.phpt +++ b/ext/phar/tests/pharfileinfo_compression.phpt @@ -79,12 +79,12 @@ Unknown compression type specified Cannot compress with Gzip compression, not possible with tar-based phar archives Phar entry is a directory, cannot set compression Phar is readonly, cannot change compression -bool(true) -bool(true) -bool(true) -bool(true) +NULL +NULL +NULL +NULL decompress Phar is readonly, cannot decompress Phar entry is a directory, cannot set compression -bool(true) -bool(true) +NULL +NULL