@@ -209,14 +209,14 @@ public static function getContents(
209
209
* save contents to file use file_put_contents()
210
210
*
211
211
* @param string $filename
212
- * @param string|array|resource $data string, array(仅一维数组) 或者是 stream 资源
212
+ * @param string|array|resource|mixed $data string, array(仅一维数组) 或者是 stream 资源
213
213
* @param int $flags
214
- * @param null $context
214
+ * @param resource| null $context
215
215
*
216
216
* @return int
217
217
* @see file_put_contents()
218
218
*/
219
- public static function putContents (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
219
+ public static function putContents (string $ filename , mixed $ data , int $ flags = 0 , $ context = null ): int
220
220
{
221
221
$ number = file_put_contents ($ filename , $ data , $ flags , $ context );
222
222
if ($ number === false ) {
@@ -236,7 +236,7 @@ public static function putContents(string $filename, $data, int $flags = 0, $con
236
236
*
237
237
* @return int
238
238
*/
239
- public static function save (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
239
+ public static function save (string $ filename , mixed $ data , int $ flags = 0 , $ context = null ): int
240
240
{
241
241
return self ::putContents ($ filename , $ data , $ flags , $ context );
242
242
}
@@ -247,11 +247,11 @@ public static function save(string $filename, $data, int $flags = 0, $context =
247
247
* @param string $filename
248
248
* @param string|array|resource $data
249
249
* @param int $flags
250
- * @param null|mixed $context
250
+ * @param null|resource $context
251
251
*
252
252
* @return int
253
253
*/
254
- public static function mkdirSave (string $ filename , $ data , int $ flags = 0 , $ context = null ): int
254
+ public static function mkdirSave (string $ filename , mixed $ data , int $ flags = 0 , $ context = null ): int
255
255
{
256
256
if (!is_dir ($ dir = dirname ($ filename ))) {
257
257
self ::mkdir ($ dir );
@@ -474,7 +474,7 @@ public static function getContentsV2(
474
474
bool $ useIncludePath = false ,
475
475
$ streamContext = null ,
476
476
int $ curlTimeout = 5
477
- ) {
477
+ ): bool | string {
478
478
$ isUrl = preg_match ('/^https?:\/\// ' , $ file );
479
479
if (null === $ streamContext && $ isUrl ) {
480
480
$ streamContext = @stream_context_create (['http ' => ['timeout ' => $ curlTimeout ]]);
@@ -524,16 +524,14 @@ public static function getContentsV2(
524
524
}
525
525
526
526
/**
527
- * @param $inFile
528
- * @param $outFile
527
+ * @param array|string $inFile
528
+ * @param string $outFile
529
529
*
530
- * @return mixed
531
- * @throws InvalidArgumentException
532
- * @throws FileNotFoundException
530
+ * @return string
533
531
*/
534
- public static function combine ($ inFile , $ outFile )
532
+ public static function combine (array | string $ inFile , string $ outFile ): string
535
533
{
536
- self ::check ($ inFile );
534
+ // self::check($inFile);
537
535
538
536
$ data = '' ;
539
537
if (is_array ($ inFile )) {
@@ -544,13 +542,10 @@ public static function combine($inFile, $outFile)
544
542
throw new FileNotFoundException ('File: ' . $ value . ' not exists! ' );
545
543
}
546
544
}
547
- }
548
-
549
- /*if (is_string($inFile) && is_file($value)) {
550
- $data .= trim( file_get_contents($inFile) );
551
545
} else {
552
- Trigger::error('文件'.$value.'不存在!!');
553
- }*/
546
+ self ::check ($ inFile );
547
+ $ data = trim (file_get_contents ($ inFile ));
548
+ }
554
549
555
550
$ preg_arr = [
556
551
'/\/\*.*?\*\/\s*/is ' , // 去掉所有多行注释/* .... */
0 commit comments