66 * Time: 上午11:41
77 */
88
9- namespace MyLib \ FileParse ;
9+ namespace Toolkit \ File \ Parse ;
1010
1111use Symfony \Component \Yaml \Parser ;
1212
1313/**
1414 * Class YmlParser
15- * @package MyLib\FileParse
15+ * @package Toolkit\File\Parse
1616 */
1717class YmlParser extends BaseParser
1818{
@@ -36,7 +36,7 @@ protected static function doParse($string, $enhancement = false, callable $pathH
3636 throw new \InvalidArgumentException ('param type error! must is string. ' );
3737 }
3838
39- if (!class_exists (Parser::class)) {
39+ if (!\ class_exists (Parser::class)) {
4040 throw new \UnexpectedValueException ('yml format parser Class ' . Parser::class . " don't exists! please install package 'symfony/yaml'. " );
4141 }
4242
@@ -60,14 +60,14 @@ protected static function doParse($string, $enhancement = false, callable $pathH
6060 }
6161
6262 // 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 ] !== '/ ' ) {
6464 $ extendFile = $ fileDir . '/ ' . trim ($ extendFile , './ ' );
6565 }
6666
6767 // $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 );
7171 } else {
7272 throw new \UnexpectedValueException ("needed extended file $ extendFile don't exists! " );
7373 }
@@ -78,22 +78,22 @@ protected static function doParse($string, $enhancement = false, callable $pathH
7878 continue ;
7979 }
8080
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 ));
8383
8484 // if needed custom handle $importFile path. e.g: Maybe it uses custom alias path
8585 if ($ pathHandler && \is_callable ($ pathHandler )) {
8686 $ importFile = $ pathHandler ($ importFile );
8787 }
8888
8989 // 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 ] !== '/ ' ) {
9191 $ importFile = $ fileDir . '/ ' . trim ($ importFile , './ ' );
9292 }
9393
9494 // $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 );
9797 $ array [$ key ] = $ parser ->parse (trim ($ data ));
9898 } else {
9999 throw new \UnexpectedValueException ("needed imported file $ importFile don't exists! " );
0 commit comments