Skip to content

Commit 172c298

Browse files
authored
Declare tentative return types for ext/zip (#7053)
1 parent 5beba0b commit 172c298

File tree

2 files changed

+142
-131
lines changed

2 files changed

+142
-131
lines changed

ext/zip/php_zip.stub.php

Lines changed: 88 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -79,164 +79,162 @@ class ZipArchive implements Countable
7979
/** @readonly */
8080
public string $comment;
8181

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

196196
/**
197197
* @param int $opsys
198198
* @param int $attr
199-
* @return bool
199+
* @tentative-return-type
200200
*/
201-
public function getExternalAttributesName(string $name, &$opsys, &$attr, int $flags = 0) {}
201+
public function getExternalAttributesName(string $name, &$opsys, &$attr, int $flags = 0): bool {}
202202

203203
/**
204204
* @param int $opsys
205205
* @param int $attr
206-
* @return bool
206+
* @tentative-return-type
207207
*/
208-
public function getExternalAttributesIndex(int $index, &$opsys, &$attr, int $flags = 0) {}
208+
public function getExternalAttributesIndex(int $index, &$opsys, &$attr, int $flags = 0): bool {}
209209
#endif
210210

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

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

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

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

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

230230
#ifdef HAVE_CANCEL_CALLBACK
231-
/** @return bool */
232-
public function registerCancelCallback(callable $callback) {}
231+
/** @tentative-return-type */
232+
public function registerCancelCallback(callable $callback): bool {}
233233
#endif
234234

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

239-
/** @return bool */
240238
public static function isEncryptionMethodSupported(int $method, bool $enc = true): bool {}
241239
#endif
242240
}

0 commit comments

Comments
 (0)