@@ -235,14 +235,15 @@ public static function getContents(
235235 }
236236
237237 /**
238- * save content use file_put_contents()
238+ * save contents to file use file_put_contents()
239239 *
240240 * @param string $filename
241- * @param mixed $data string, array(仅一维数组) 或者是 stream 资源
241+ * @param string|array|resource $data string, array(仅一维数组) 或者是 stream 资源
242242 * @param int $flags
243243 * @param null $context
244244 *
245245 * @return int
246+ * @see file_put_contents()
246247 */
247248 public static function putContents (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
248249 {
@@ -255,31 +256,47 @@ public static function putContents(string $filename, $data, int $flags = 0, $con
255256 }
256257
257258 /**
258- * save content
259+ * save contents to file.
259260 *
260261 * @param string $filename
261- * @param mixed $data string, array(仅一维数组) 或者是 stream 资源
262+ * @param string|array|resource $data string, array(仅一维数组) 或者是 stream 资源
262263 * @param int $flags
263- * @param mixed $context
264+ * @param null|resource $context
264265 *
265266 * @return int
266267 */
267- public static function save (string $ filename , string $ data , int $ flags = 0 , $ context = null ): int
268+ public static function save (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
269+ {
270+ return self ::putContents ($ filename , $ data , $ flags , $ context );
271+ }
272+
273+ /**
274+ * save contents to file. if dir is not exists, will create it.
275+ *
276+ * @param string $filename
277+ * @param string|array|resource $data
278+ * @param int $flags
279+ * @param null|mixed $context
280+ *
281+ * @return int
282+ */
283+ public static function mkdirSave (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
268284 {
269285 return self ::putContents ($ filename , $ data , $ flags , $ context );
270286 }
271287
272288 /**
273289 * @param string $content
274290 * @param string $path
291+ *
292+ * @return bool
275293 */
276- public static function write (string $ content , string $ path ): void
294+ public static function write (string $ content , string $ path ): bool
277295 {
278296 $ stream = static ::streamOpen ($ path );
279-
280297 static ::streamWrite ($ stream , $ content );
281298
282- fclose ($ stream );
299+ return fclose ($ stream );
283300 }
284301
285302 /**
0 commit comments