PHP_CodeSniffer::isPharFile PHP Method

isPharFile() public static method

Return TRUE, if the path is a phar file.
public static isPharFile ( string $path ) : mixed
$path string The path to use.
return mixed
    public static function isPharFile($path)
    {
        if (strpos($path, 'phar://') === 0) {
            return true;
        }
        return false;
    }

Usage Example

Esempio n. 1
0
 /**
  * Get a list of default values for all possible command line arguments.
  *
  * @return array
  */
 public function getDefaults()
 {
     if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
         return array();
     }
     // The default values for config settings.
     $defaults['files'] = array();
     $defaults['standard'] = null;
     $defaults['verbosity'] = 0;
     $defaults['interactive'] = false;
     $defaults['colors'] = false;
     $defaults['explain'] = false;
     $defaults['local'] = false;
     $defaults['showSources'] = false;
     $defaults['extensions'] = array();
     $defaults['sniffs'] = array();
     $defaults['ignored'] = array();
     $defaults['reportFile'] = null;
     $defaults['generator'] = '';
     $defaults['reports'] = array();
     $defaults['bootstrap'] = array();
     $defaults['errorSeverity'] = null;
     $defaults['warningSeverity'] = null;
     $defaults['stdin'] = null;
     $reportFormat = PHP_CodeSniffer::getConfigData('report_format');
     if ($reportFormat !== null) {
         $defaults['reports'][$reportFormat] = null;
     }
     $tabWidth = PHP_CodeSniffer::getConfigData('tab_width');
     if ($tabWidth === null) {
         $defaults['tabWidth'] = 0;
     } else {
         $defaults['tabWidth'] = (int) $tabWidth;
     }
     $encoding = PHP_CodeSniffer::getConfigData('encoding');
     if ($encoding === null) {
         $defaults['encoding'] = 'iso-8859-1';
     } else {
         $defaults['encoding'] = strtolower($encoding);
     }
     $severity = PHP_CodeSniffer::getConfigData('severity');
     if ($severity !== null) {
         $defaults['errorSeverity'] = (int) $severity;
         $defaults['warningSeverity'] = (int) $severity;
     }
     $severity = PHP_CodeSniffer::getConfigData('error_severity');
     if ($severity !== null) {
         $defaults['errorSeverity'] = (int) $severity;
     }
     $severity = PHP_CodeSniffer::getConfigData('warning_severity');
     if ($severity !== null) {
         $defaults['warningSeverity'] = (int) $severity;
     }
     $showWarnings = PHP_CodeSniffer::getConfigData('show_warnings');
     if ($showWarnings !== null) {
         $showWarnings = (bool) $showWarnings;
         if ($showWarnings === false) {
             $defaults['warningSeverity'] = 0;
         }
     }
     $reportWidth = PHP_CodeSniffer::getConfigData('report_width');
     if ($reportWidth !== null) {
         $defaults['reportWidth'] = $this->_validateReportWidth($reportWidth);
     } else {
         // Use function defaults.
         $defaults['reportWidth'] = null;
     }
     $showProgress = PHP_CodeSniffer::getConfigData('show_progress');
     if ($showProgress === null) {
         $defaults['showProgress'] = false;
     } else {
         $defaults['showProgress'] = (bool) $showProgress;
     }
     $colors = PHP_CodeSniffer::getConfigData('colors');
     if ($colors === null) {
         $defaults['colors'] = false;
     } else {
         $defaults['colors'] = (bool) $colors;
     }
     if (PHP_CodeSniffer::isPharFile(dirname(dirname(__FILE__))) === true) {
         // If this is a phar file, check for the standard in the config.
         $standard = PHP_CodeSniffer::getConfigData('standard');
         if ($standard !== null) {
             $defaults['standard'] = $standard;
         }
     }
     return $defaults;
 }