Skip to content

Declare tentative return types for ext/zip #7053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 88 additions & 90 deletions ext/zip/php_zip.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,164 +79,162 @@ class ZipArchive implements Countable
/** @readonly */
public string $comment;

/** @return bool|int */
public function open(string $filename, int $flags = 0) {}
/** @tentative-return-type */
public function open(string $filename, int $flags = 0): bool|int {}

/** @return bool */
public function setPassword(string $password) {}
/** @tentative-return-type */
public function setPassword(string $password): bool {}

/** @return bool */
public function close() {}
/** @tentative-return-type */
public function close(): bool {}

/** @return int */
public function count() {}
/** @tentative-return-type */
public function count(): int {}

/** @return string */
public function getStatusString() {}
/** @tentative-return-type */
public function getStatusString(): string {}

/** @return bool */
public function addEmptyDir(string $dirname, int $flags = 0) {}
/** @tentative-return-type */
public function addEmptyDir(string $dirname, int $flags = 0): bool {}

/** @return bool */
public function addFromString(string $name, string $content, int $flags = ZipArchive::FL_OVERWRITE) {}
/** @tentative-return-type */
public function addFromString(string $name, string $content, int $flags = ZipArchive::FL_OVERWRITE): bool {}

/** @return bool */
public function addFile(string $filepath, string $entryname = "", int $start = 0, int $length = 0, int $flags = ZipArchive::FL_OVERWRITE) {}
/** @tentative-return-type */
public function addFile(string $filepath, string $entryname = "", int $start = 0, int $length = 0, int $flags = ZipArchive::FL_OVERWRITE): bool {}

/** @return bool */
public function replaceFile(string $filepath, string $index, int $start = 0, int $length = 0, int $flags = 0) {}
/** @tentative-return-type */
public function replaceFile(string $filepath, string $index, int $start = 0, int $length = 0, int $flags = 0): bool {}

/** @return array|false */
public function addGlob(string $pattern, int $flags = 0, array $options = []) {}
/** @tentative-return-type */
public function addGlob(string $pattern, int $flags = 0, array $options = []): array|false {}

/** @return array|false */
public function addPattern(string $pattern, string $path = ".", array $options = []) {}
/** @tentative-return-type */
public function addPattern(string $pattern, string $path = ".", array $options = []): array|false {}

/** @return bool */
public function renameIndex(int $index, string $new_name) {}
/** @tentative-return-type */
public function renameIndex(int $index, string $new_name): bool {}

/** @return bool */
public function renameName(string $name, string $new_name) {}
/** @tentative-return-type */
public function renameName(string $name, string $new_name): bool {}

/** @return bool */
public function setArchiveComment(string $comment) {}
/** @tentative-return-type */
public function setArchiveComment(string $comment): bool {}

/** @return string|false */
public function getArchiveComment(int $flags = 0) {}
/** @tentative-return-type */
public function getArchiveComment(int $flags = 0): string|false {}

/** @return bool */
public function setCommentIndex(int $index, string $comment) {}
/** @tentative-return-type */
public function setCommentIndex(int $index, string $comment): bool {}

/** @return bool */
public function setCommentName(string $name, string $comment) {}
/** @tentative-return-type */
public function setCommentName(string $name, string $comment): bool {}

#ifdef HAVE_SET_MTIME
/** @return bool */
public function setMtimeIndex(int $index, int $timestamp, int $flags = 0) {}
/** @tentative-return-type */
public function setMtimeIndex(int $index, int $timestamp, int $flags = 0): bool {}

/** @return bool */
public function setMtimeName(string $name, int $timestamp, int $flags = 0) {}
/** @tentative-return-type */
public function setMtimeName(string $name, int $timestamp, int $flags = 0): bool {}
#endif

/** @return string|false */
public function getCommentIndex(int $index, int $flags = 0) {}
/** @tentative-return-type */
public function getCommentIndex(int $index, int $flags = 0): string|false {}

/** @return string|false */
public function getCommentName(string $name, int $flags = 0) {}
/** @tentative-return-type */
public function getCommentName(string $name, int $flags = 0): string|false {}

/** @return bool */
public function deleteIndex(int $index) {}
/** @tentative-return-type */
public function deleteIndex(int $index): bool {}

/** @return bool */
public function deleteName(string $name) {}
/** @tentative-return-type */
public function deleteName(string $name): bool {}

/** @return array|false */
public function statName(string $name, int $flags = 0) {}
/** @tentative-return-type */
public function statName(string $name, int $flags = 0): array|false {}

/** @return array|false */
public function statIndex(int $index, int $flags = 0) {}
/** @tentative-return-type */
public function statIndex(int $index, int $flags = 0): array|false {}

/** @return int|false */
public function locateName(string $name, int $flags = 0) {}
/** @tentative-return-type */
public function locateName(string $name, int $flags = 0): int|false {}

/** @return string|false */
public function getNameIndex(int $index, int $flags = 0) {}
/** @tentative-return-type */
public function getNameIndex(int $index, int $flags = 0): string|false {}

/** @return bool */
public function unchangeArchive() {}
/** @tentative-return-type */
public function unchangeArchive(): bool {}

/** @return bool */
public function unchangeAll() {}
/** @tentative-return-type */
public function unchangeAll(): bool {}

/** @return bool */
public function unchangeIndex(int $index) {}
/** @tentative-return-type */
public function unchangeIndex(int $index): bool {}

/** @return bool */
public function unchangeName(string $name) {}
/** @tentative-return-type */
public function unchangeName(string $name): bool {}

/** @return bool */
public function extractTo(string $pathto, array|string|null $files = null) {}
/** @tentative-return-type */
public function extractTo(string $pathto, array|string|null $files = null): bool {}

/** @return string|false */
public function getFromName(string $name, int $len = 0, int $flags = 0) {}
/** @tentative-return-type */
public function getFromName(string $name, int $len = 0, int $flags = 0): string|false {}

/** @return string|false */
public function getFromIndex(int $index, int $len = 0, int $flags = 0) {}
/** @tentative-return-type */
public function getFromIndex(int $index, int $len = 0, int $flags = 0): string|false {}

/** @return resource|false */
public function getStream(string $name) {}

#ifdef ZIP_OPSYS_DEFAULT
/** @return bool */
public function setExternalAttributesName(string $name, int $opsys, int $attr, int $flags = 0) {}
/** @tentative-return-type */
public function setExternalAttributesName(string $name, int $opsys, int $attr, int $flags = 0): bool {}

/** @return bool */
public function setExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = 0) {}
/** @tentative-return-type */
public function setExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = 0): bool {}

/**
* @param int $opsys
* @param int $attr
* @return bool
* @tentative-return-type
*/
public function getExternalAttributesName(string $name, &$opsys, &$attr, int $flags = 0) {}
public function getExternalAttributesName(string $name, &$opsys, &$attr, int $flags = 0): bool {}

/**
* @param int $opsys
* @param int $attr
* @return bool
* @tentative-return-type
*/
public function getExternalAttributesIndex(int $index, &$opsys, &$attr, int $flags = 0) {}
public function getExternalAttributesIndex(int $index, &$opsys, &$attr, int $flags = 0): bool {}
#endif

/** @return bool */
public function setCompressionName(string $name, int $method, int $compflags = 0) {}
/** @tentative-return-type */
public function setCompressionName(string $name, int $method, int $compflags = 0): bool {}

/** @return bool */
public function setCompressionIndex(int $index, int $method, int $compflags = 0) {}
/** @tentative-return-type */
public function setCompressionIndex(int $index, int $method, int $compflags = 0): bool {}

#ifdef HAVE_ENCRYPTION
/** @return bool */
public function setEncryptionName(string $name, int $method, ?string $password = null) {}
/** @tentative-return-type */
public function setEncryptionName(string $name, int $method, ?string $password = null): bool {}

/** @return bool */
public function setEncryptionIndex(int $index, int $method, ?string $password = null) {}
/** @tentative-return-type */
public function setEncryptionIndex(int $index, int $method, ?string $password = null): bool {}
#endif

#ifdef HAVE_PROGRESS_CALLBACK
/** @return bool */
public function registerProgressCallback(float $rate, callable $callback) {}
/** @tentative-return-type */
public function registerProgressCallback(float $rate, callable $callback): bool {}
#endif

#ifdef HAVE_CANCEL_CALLBACK
/** @return bool */
public function registerCancelCallback(callable $callback) {}
/** @tentative-return-type */
public function registerCancelCallback(callable $callback): bool {}
#endif

#ifdef HAVE_METHOD_SUPPORTED
/** @return bool */
public static function isCompressionMethodSupported(int $method, bool $enc = true): bool {}

/** @return bool */
public static function isEncryptionMethodSupported(int $method, bool $enc = true): bool {}
#endif
}
Loading