6
6
* Time: 上午11:41
7
7
*/
8
8
9
- namespace MyLib \ FileParse ;
9
+ namespace Toolkit \ File \ Parse ;
10
10
11
11
use Symfony \Component \Yaml \Parser ;
12
12
13
13
/**
14
14
* Class YmlParser
15
- * @package MyLib\FileParse
15
+ * @package Toolkit\File\Parse
16
16
*/
17
17
class YmlParser extends BaseParser
18
18
{
@@ -36,7 +36,7 @@ protected static function doParse($string, $enhancement = false, callable $pathH
36
36
throw new \InvalidArgumentException ('param type error! must is string. ' );
37
37
}
38
38
39
- if (!class_exists (Parser::class)) {
39
+ if (!\ class_exists (Parser::class)) {
40
40
throw new \UnexpectedValueException ('yml format parser Class ' . Parser::class . " don't exists! please install package 'symfony/yaml'. " );
41
41
}
42
42
@@ -60,14 +60,14 @@ protected static function doParse($string, $enhancement = false, callable $pathH
60
60
}
61
61
62
62
// if $importFile is not exists AND $importFile is not a absolute path AND have $parentFile
63
- if ($ fileDir && !file_exists ($ extendFile ) && $ extendFile [0 ] !== '/ ' ) {
63
+ if ($ fileDir && !\ file_exists ($ extendFile ) && $ extendFile [0 ] !== '/ ' ) {
64
64
$ extendFile = $ fileDir . '/ ' . trim ($ extendFile , './ ' );
65
65
}
66
66
67
67
// $importFile is file
68
- if (is_file ($ extendFile )) {
69
- $ data = file_get_contents ($ extendFile );
70
- $ array = array_merge ($ parser ->parse (trim ($ data )), $ array );
68
+ if (\ is_file ($ extendFile )) {
69
+ $ data = \ file_get_contents ($ extendFile );
70
+ $ array = \ array_merge ($ parser ->parse (trim ($ data )), $ array );
71
71
} else {
72
72
throw new \UnexpectedValueException ("needed extended file $ extendFile don't exists! " );
73
73
}
@@ -78,22 +78,22 @@ protected static function doParse($string, $enhancement = false, callable $pathH
78
78
continue ;
79
79
}
80
80
81
- if (0 === strpos ($ item , self ::IMPORT_KEY . '# ' )) {
82
- $ importFile = trim (substr ($ item , 6 ));
81
+ if (0 === \ strpos ($ item , self ::IMPORT_KEY . '# ' )) {
82
+ $ importFile = \ trim (\ substr ($ item , 6 ));
83
83
84
84
// if needed custom handle $importFile path. e.g: Maybe it uses custom alias path
85
85
if ($ pathHandler && \is_callable ($ pathHandler )) {
86
86
$ importFile = $ pathHandler ($ importFile );
87
87
}
88
88
89
89
// if $importFile is not exists AND $importFile is not a absolute path AND have $parentFile
90
- if ($ fileDir && !file_exists ($ importFile ) && $ importFile [0 ] !== '/ ' ) {
90
+ if ($ fileDir && !\ file_exists ($ importFile ) && $ importFile [0 ] !== '/ ' ) {
91
91
$ importFile = $ fileDir . '/ ' . trim ($ importFile , './ ' );
92
92
}
93
93
94
94
// $importFile is file
95
- if (is_file ($ importFile )) {
96
- $ data = file_get_contents ($ importFile );
95
+ if (\ is_file ($ importFile )) {
96
+ $ data = \ file_get_contents ($ importFile );
97
97
$ array [$ key ] = $ parser ->parse (trim ($ data ));
98
98
} else {
99
99
throw new \UnexpectedValueException ("needed imported file $ importFile don't exists! " );
0 commit comments