@@ -326,6 +326,7 @@ public function setModifies($modifies): self
326326 * @throws \UnexpectedValueException
327327 * @throws \BadMethodCallException
328328 * @throws \RuntimeException
329+ * @throws \Exception
329330 */
330331 public function pack (string $ pharFile , $ refresh = true ): string
331332 {
@@ -461,7 +462,6 @@ private function packFile(\Phar $phar, \SplFileInfo $file)
461462 // skip error
462463 if (!\file_exists ($ file )) {
463464 $ this ->reportError ("File $ file is not exists! " );
464-
465465 return ;
466466 }
467467
@@ -613,7 +613,6 @@ private function createIteratorFilter(): \Closure
613613 return true ;
614614 }
615615 }
616-
617616 return false ;
618617 }
619618
@@ -636,18 +635,18 @@ private function stripWhitespace(string $source): string
636635 }
637636
638637 $ output = '' ;
639- foreach (token_get_all ($ source ) as $ token ) {
638+ foreach (\ token_get_all ($ source ) as $ token ) {
640639 if (\is_string ($ token )) {
641640 $ output .= $ token ;
642- } elseif (\in_array ($ token [0 ], [T_COMMENT , T_DOC_COMMENT ], true )) {
643- $ output .= str_repeat ("\n" , substr_count ($ token [1 ], "\n" ));
644- } elseif (T_WHITESPACE === $ token [0 ]) {
641+ } elseif (\in_array ($ token [0 ], [\ T_COMMENT , \ T_DOC_COMMENT ], true )) {
642+ $ output .= \ str_repeat ("\n" , \ substr_count ($ token [1 ], "\n" ));
643+ } elseif (\ T_WHITESPACE === $ token [0 ]) {
645644 // reduce wide spaces
646- $ whitespace = preg_replace ('{[ \t]+} ' , ' ' , $ token [1 ]);
645+ $ whitespace = \ preg_replace ('{[ \t]+} ' , ' ' , $ token [1 ]);
647646 // normalize newlines to \n
648- $ whitespace = preg_replace ('{(?:\r\n|\r|\n)} ' , "\n" , $ whitespace );
647+ $ whitespace = \ preg_replace ('{(?:\r\n|\r|\n)} ' , "\n" , $ whitespace );
649648 // trim leading spaces
650- $ whitespace = preg_replace ('{\n +} ' , "\n" , $ whitespace );
649+ $ whitespace = \ preg_replace ('{\n +} ' , "\n" , $ whitespace );
651650 $ output .= $ whitespace ;
652651 } else {
653652 $ output .= $ token [1 ];
@@ -677,7 +676,7 @@ private function collectInformation()
677676 );
678677 }
679678
680- $ this ->version = trim ($ ret );
679+ $ this ->version = \ trim ($ ret );
681680
682681 list ($ code , $ ret ,) = Sys::run ('git log -n1 --pretty=%ci HEAD ' , $ basePath );
683682
@@ -687,18 +686,18 @@ private function collectInformation()
687686 );
688687 }
689688
690- $ this ->versionDate = new \DateTime (trim ($ ret ));
689+ $ this ->versionDate = new \DateTime (\ trim ($ ret ));
691690 $ this ->versionDate ->setTimezone (new \DateTimeZone ('UTC ' ));
692691
693692 // 获取到最新的 tag
694693 list ($ code , $ ret ,) = Sys::run ('git describe --tags --exact-match HEAD ' , $ basePath );
695694 if ($ code === 0 ) {
696- $ this ->version = trim ($ ret );
695+ $ this ->version = \ trim ($ ret );
697696 } else {
698697 list ($ code1 , $ ret ,) = Sys::run ('git branch ' , $ basePath );
699698
700699 if ($ code1 === 0 ) {
701- $ this ->branchAliasVersion = \explode ("\n" , trim ($ ret , "* \n" ), 2 )[0 ];
700+ $ this ->branchAliasVersion = \explode ("\n" , \ trim ($ ret , "* \n" ), 2 )[0 ];
702701 }
703702 }
704703 }
@@ -712,10 +711,10 @@ private function getRelativeFilePath($file): string
712711 $ realPath = $ file ->getRealPath ();
713712 $ pathPrefix = $ this ->basePath . DIRECTORY_SEPARATOR ;
714713
715- $ pos = strpos ($ realPath , $ pathPrefix );
716- $ relativePath = $ pos !== false ? substr_replace ($ realPath , '' , $ pos , \strlen ($ pathPrefix )) : $ realPath ;
714+ $ pos = \ strpos ($ realPath , $ pathPrefix );
715+ $ relativePath = $ pos !== false ? \ substr_replace ($ realPath , '' , $ pos , \strlen ($ pathPrefix )) : $ realPath ;
717716
718- return str_replace ('\\' , '/ ' , $ relativePath );
717+ return \ str_replace ('\\' , '/ ' , $ relativePath );
719718 }
720719
721720 /**
@@ -884,7 +883,6 @@ public function getBranchAliasVersion()
884883 public function setBranchAliasVersion (string $ branchAliasVersion ): PharCompiler
885884 {
886885 $ this ->branchAliasVersion = $ branchAliasVersion ;
887-
888886 return $ this ;
889887 }
890888
0 commit comments