1212
1313namespace PHP_CodeSniffer ;
1414
15+ use Exception ;
16+ use Phar ;
1517use PHP_CodeSniffer \Exceptions \DeepExitException ;
1618use PHP_CodeSniffer \Exceptions \RuntimeException ;
1719use PHP_CodeSniffer \Util \Common ;
20+ use PHP_CodeSniffer \Util \Standards ;
1821
1922/**
2023 * Stores the configuration used to run PHPCS and PHPCBF.
@@ -265,7 +268,7 @@ public function __set($name, $value)
265268 $ cleaned = [];
266269
267270 // Check if the standard name is valid, or if the case is invalid.
268- $ installedStandards = Util \ Standards::getInstalledStandards ();
271+ $ installedStandards = Standards::getInstalledStandards ();
269272 foreach ($ value as $ standard ) {
270273 foreach ($ installedStandards as $ validStandard ) {
271274 if (strtolower ($ standard ) === strtolower ($ validStandard )) {
@@ -420,7 +423,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
420423
421424 // Check for content on STDIN.
422425 if ($ this ->stdin === true
423- || (Util \ Common::isStdinATTY () === false
426+ || (Common::isStdinATTY () === false
424427 && feof ($ handle ) === false )
425428 ) {
426429 $ readStreams = [$ handle ];
@@ -649,7 +652,7 @@ public function processShortArgument($arg, $pos)
649652 throw new DeepExitException ($ output , 0 );
650653 case 'i ' :
651654 ob_start ();
652- Util \ Standards::printInstalledStandards ();
655+ Standards::printInstalledStandards ();
653656 $ output = ob_get_contents ();
654657 ob_end_clean ();
655658 throw new DeepExitException ($ output , 0 );
@@ -812,7 +815,7 @@ public function processLongArgument($arg, $pos)
812815
813816 try {
814817 $ this ->setConfigData ($ key , $ value );
815- } catch (\ Exception $ e ) {
818+ } catch (Exception $ e ) {
816819 throw new DeepExitException ($ e ->getMessage ().PHP_EOL , 3 );
817820 }
818821
@@ -840,7 +843,7 @@ public function processLongArgument($arg, $pos)
840843 } else {
841844 try {
842845 $ this ->setConfigData ($ key , null );
843- } catch (\ Exception $ e ) {
846+ } catch (Exception $ e ) {
844847 throw new DeepExitException ($ e ->getMessage ().PHP_EOL , 3 );
845848 }
846849
@@ -922,7 +925,7 @@ public function processLongArgument($arg, $pos)
922925 $ this ->cache = true ;
923926 self ::$ overriddenDefaults ['cache ' ] = true ;
924927
925- $ this ->cacheFile = Util \ Common::realpath (substr ($ arg , 6 ));
928+ $ this ->cacheFile = Common::realpath (substr ($ arg , 6 ));
926929
927930 // It may not exist and return false instead.
928931 if ($ this ->cacheFile === false ) {
@@ -941,9 +944,9 @@ public function processLongArgument($arg, $pos)
941944 } else {
942945 if ($ dir [0 ] === '/ ' ) {
943946 // An absolute path.
944- $ dir = Util \ Common::realpath ($ dir );
947+ $ dir = Common::realpath ($ dir );
945948 } else {
946- $ dir = Util \ Common::realpath (getcwd ().'/ ' .$ dir );
949+ $ dir = Common::realpath (getcwd ().'/ ' .$ dir );
947950 }
948951
949952 if ($ dir !== false ) {
@@ -964,7 +967,7 @@ public function processLongArgument($arg, $pos)
964967 $ files = explode (', ' , substr ($ arg , 10 ));
965968 $ bootstrap = [];
966969 foreach ($ files as $ file ) {
967- $ path = Util \ Common::realpath ($ file );
970+ $ path = Common::realpath ($ file );
968971 if ($ path === false ) {
969972 $ error = 'ERROR: The specified bootstrap file " ' .$ file .'" does not exist ' .PHP_EOL .PHP_EOL ;
970973 $ error .= $ this ->printShortUsage (true );
@@ -978,7 +981,7 @@ public function processLongArgument($arg, $pos)
978981 self ::$ overriddenDefaults ['bootstrap ' ] = true ;
979982 } else if (substr ($ arg , 0 , 10 ) === 'file-list= ' ) {
980983 $ fileList = substr ($ arg , 10 );
981- $ path = Util \ Common::realpath ($ fileList );
984+ $ path = Common::realpath ($ fileList );
982985 if ($ path === false ) {
983986 $ error = 'ERROR: The specified file list " ' .$ fileList .'" does not exist ' .PHP_EOL .PHP_EOL ;
984987 $ error .= $ this ->printShortUsage (true );
@@ -1001,7 +1004,7 @@ public function processLongArgument($arg, $pos)
10011004 break ;
10021005 }
10031006
1004- $ this ->stdinPath = Util \ Common::realpath (substr ($ arg , 11 ));
1007+ $ this ->stdinPath = Common::realpath (substr ($ arg , 11 ));
10051008
10061009 // It may not exist and return false instead, so use whatever they gave us.
10071010 if ($ this ->stdinPath === false ) {
@@ -1014,13 +1017,13 @@ public function processLongArgument($arg, $pos)
10141017 break ;
10151018 }
10161019
1017- $ this ->reportFile = Util \ Common::realpath (substr ($ arg , 12 ));
1020+ $ this ->reportFile = Common::realpath (substr ($ arg , 12 ));
10181021
10191022 // It may not exist and return false instead.
10201023 if ($ this ->reportFile === false ) {
10211024 $ this ->reportFile = substr ($ arg , 12 );
10221025
1023- $ dir = Util \ Common::realpath (dirname ($ this ->reportFile ));
1026+ $ dir = Common::realpath (dirname ($ this ->reportFile ));
10241027 if (is_dir ($ dir ) === false ) {
10251028 $ error = 'ERROR: The specified report file path " ' .$ this ->reportFile .'" points to a non-existent directory ' .PHP_EOL .PHP_EOL ;
10261029 $ error .= $ this ->printShortUsage (true );
@@ -1056,7 +1059,7 @@ public function processLongArgument($arg, $pos)
10561059 break ;
10571060 }
10581061
1059- $ this ->basepath = Util \ Common::realpath (substr ($ arg , 9 ));
1062+ $ this ->basepath = Common::realpath (substr ($ arg , 9 ));
10601063
10611064 // It may not exist and return false instead.
10621065 if ($ this ->basepath === false ) {
@@ -1083,7 +1086,7 @@ public function processLongArgument($arg, $pos)
10831086 if ($ output === false ) {
10841087 $ output = null ;
10851088 } else {
1086- $ dir = Util \ Common::realpath (dirname ($ output ));
1089+ $ dir = Common::realpath (dirname ($ output ));
10871090 if (is_dir ($ dir ) === false ) {
10881091 $ error = 'ERROR: The specified ' .$ report .' report file path " ' .$ output .'" points to a non-existent directory ' .PHP_EOL .PHP_EOL ;
10891092 $ error .= $ this ->printShortUsage (true );
@@ -1317,7 +1320,7 @@ public function processFilePath($path)
13171320 return ;
13181321 }
13191322
1320- $ file = Util \ Common::realpath ($ path );
1323+ $ file = Common::realpath ($ path );
13211324 if (file_exists ($ file ) === false ) {
13221325 if ($ this ->dieOnUnknownArg === false ) {
13231326 return ;
@@ -1608,7 +1611,7 @@ public static function setConfigData($key, $value, $temp=false)
16081611 if ($ temp === false ) {
16091612 $ path = '' ;
16101613 if (is_callable ('\Phar::running ' ) === true ) {
1611- $ path = \ Phar::running (false );
1614+ $ path = Phar::running (false );
16121615 }
16131616
16141617 if ($ path !== '' ) {
@@ -1653,7 +1656,7 @@ public static function setConfigData($key, $value, $temp=false)
16531656 // If the installed paths are being set, make sure all known
16541657 // standards paths are added to the autoloader.
16551658 if ($ key === 'installed_paths ' ) {
1656- $ installedStandards = Util \ Standards::getInstalledStandardDetails ();
1659+ $ installedStandards = Standards::getInstalledStandardDetails ();
16571660 foreach ($ installedStandards as $ name => $ details ) {
16581661 Autoload::addSearchPath ($ details ['path ' ], $ details ['namespace ' ]);
16591662 }
@@ -1679,7 +1682,7 @@ public static function getAllConfigData()
16791682
16801683 $ path = '' ;
16811684 if (is_callable ('\Phar::running ' ) === true ) {
1682- $ path = \ Phar::running (false );
1685+ $ path = Phar::running (false );
16831686 }
16841687
16851688 if ($ path !== '' ) {
0 commit comments