Skip to content

Commit

Permalink
Now using short array syntax + generic array indenting
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Nov 21, 2017
1 parent 4e95f24 commit a9d8185
Show file tree
Hide file tree
Showing 471 changed files with 7,899 additions and 7,881 deletions.
6 changes: 3 additions & 3 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class Autoload
*
* @var array<string, string>
*/
private static $loadedClasses = array();
private static $loadedClasses = [];

/**
* A mapping of class names to file names.
*
* @var array<string, string>
*/
private static $loadedFiles = array();
private static $loadedFiles = [];

/**
* A list of additional directories to search during autoloading.
Expand All @@ -48,7 +48,7 @@ class Autoload
*
* @var string[]
*/
private static $searchPaths = array();
private static $searchPaths = [];


/**
Expand Down
10 changes: 6 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Previously, STDIN files using fake file paths were excluded from checking
- Ignore patterns are now checked on symlink target paths instead of symlink source paths
-- Restores previous behaviour of this feature
- The Squiz standard now ensures array keys are indented 4 spaces from the main statement
-- Previously, this standard aligned keys 1 space from the start of the array keyword
- The Squiz standard now ensures array end braces are aligned with the main statement
-- Previously, this standard aligned the close brace with the start of the array keyword
- Added AbstractArraySniff to make it easier to create sniffs that check array formatting
-- Allows for checking of single and multi line arrays easily
-- Provides a parsed structure of the array including positions of keys, values, and double arrows
Expand All @@ -90,6 +86,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Default remains at 1
-- Thanks to Nikola Kovacs for the patch
- PEAR.Functions.FunctionCallSignature now requires the function keyword to be indented to an exact tab stop
- The Squiz standard now ensures array keys are indented 4 spaces from the main statement
-- Previously, this standard aligned keys 1 space from the start of the array keyword
- The Squiz standard now ensures array end braces are aligned with the main statement
-- Previously, this standard aligned the close brace with the start of the array keyword
- The standrd for PHP_CodeSniffer itself now enforces short array syntax
- The standrd for PHP_CodeSniffer itself now uses the Generic.Arrays/ArrayIndent sniff rules
- Fixed bug #1462 : Error processing cyrillic strings in Tokenizer
- Fixed bug #1590 : InlineControlStructure CBF issue while adding braces to an if thats returning a nested function
- Fixed bug #1718 : Unclosed strings at EOF sometimes tokenized as T_WHITESPACE by the JS tokenizer
Expand Down
16 changes: 16 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<rule ref="Squiz.WhiteSpace.FunctionSpacing" />
<rule ref="Squiz.WhiteSpace.OperatorSpacing" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
Expand All @@ -66,6 +67,21 @@
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="Zend.Files.ClosingTag"/>

<!-- We use custom indent rules for arrays -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
<severity>0</severity>
</rule>

<!-- Check var names, but we don't want leading underscores for private vars -->
<rule ref="Squiz.NamingConventions.ValidVariableName" />
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
Expand Down
140 changes: 70 additions & 70 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,43 @@ class Config
*
* @var array<string, mixed>
*/
private $settings = array(
'files' => null,
'standards' => null,
'verbosity' => null,
'interactive' => null,
'parallel' => null,
'cache' => null,
'cacheFile' => null,
'colors' => null,
'explain' => null,
'local' => null,
'showSources' => null,
'showProgress' => null,
'quiet' => null,
'annotations' => null,
'tabWidth' => null,
'encoding' => null,
'extensions' => null,
'sniffs' => null,
'exclude' => null,
'ignored' => null,
'reportFile' => null,
'generator' => null,
'filter' => null,
'bootstrap' => null,
'reports' => null,
'basepath' => null,
'reportWidth' => null,
'errorSeverity' => null,
'warningSeverity' => null,
'recordErrors' => null,
'suffix' => null,
'stdin' => null,
'stdinContent' => null,
'stdinPath' => null,
'unknown' => null,
);
private $settings = [
'files' => null,
'standards' => null,
'verbosity' => null,
'interactive' => null,
'parallel' => null,
'cache' => null,
'cacheFile' => null,
'colors' => null,
'explain' => null,
'local' => null,
'showSources' => null,
'showProgress' => null,
'quiet' => null,
'annotations' => null,
'tabWidth' => null,
'encoding' => null,
'extensions' => null,
'sniffs' => null,
'exclude' => null,
'ignored' => null,
'reportFile' => null,
'generator' => null,
'filter' => null,
'bootstrap' => null,
'reports' => null,
'basepath' => null,
'reportWidth' => null,
'errorSeverity' => null,
'warningSeverity' => null,
'recordErrors' => null,
'suffix' => null,
'stdin' => null,
'stdinContent' => null,
'stdinPath' => null,
'unknown' => null,
];

/**
* Whether or not to kill the process when an unknown command line arg is found.
Expand All @@ -151,14 +151,14 @@ class Config
*
* @var string[]
*/
private $cliArgs = array();
private $cliArgs = [];

/**
* Command line values that the user has supplied directly.
*
* @var array<string, TRUE>
*/
private $overriddenDefaults = array();
private $overriddenDefaults = [];

/**
* Config file data that has been loaded for the run.
Expand All @@ -179,7 +179,7 @@ class Config
*
* @var array<string, string>
*/
private static $executablePaths = array();
private static $executablePaths = [];


/**
Expand Down Expand Up @@ -226,7 +226,7 @@ public function __set($name, $value)
}
break;
case 'standards' :
$cleaned = array();
$cleaned = [];

// Check if the standard name is valid, or if the case is invalid.
$installedStandards = Util\Standards::getInstalledStandards();
Expand Down Expand Up @@ -316,7 +316,7 @@ public function setSettings($settings)
*
* @return void
*/
public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true)
public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
{
if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
// Let everything through during testing so that we can
Expand All @@ -341,18 +341,18 @@ public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true)
// Look for a default ruleset in the current directory or higher.
$currentDir = getcwd();

$defaultFiles = array(
'.phpcs.xml',
'phpcs.xml',
'.phpcs.xml.dist',
'phpcs.xml.dist',
);
$defaultFiles = [
'.phpcs.xml',
'phpcs.xml',
'.phpcs.xml.dist',
'phpcs.xml.dist',
];

do {
foreach ($defaultFiles as $defaultFilename) {
$default = $currentDir.DIRECTORY_SEPARATOR.$defaultFilename;
if (is_file($default) === true) {
$this->standards = array($default);
$this->standards = [$default];
break(2);
}
}
Expand Down Expand Up @@ -444,8 +444,8 @@ public function setCommandLineValues($args)
*/
public function restoreDefaults()
{
$this->files = array();
$this->standards = array('PEAR');
$this->files = [];
$this->standards = ['PEAR'];
$this->verbosity = 0;
$this->interactive = false;
$this->cache = false;
Expand All @@ -460,21 +460,21 @@ public function restoreDefaults()
$this->parallel = 1;
$this->tabWidth = 0;
$this->encoding = 'utf-8';
$this->extensions = array(
'php' => 'PHP',
'inc' => 'PHP',
'js' => 'JS',
'css' => 'CSS',
);
$this->sniffs = array();
$this->exclude = array();
$this->ignored = array();
$this->extensions = [
'php' => 'PHP',
'inc' => 'PHP',
'js' => 'JS',
'css' => 'CSS',
];
$this->sniffs = [];
$this->exclude = [];
$this->ignored = [];
$this->reportFile = null;
$this->generator = null;
$this->filter = null;
$this->bootstrap = array();
$this->bootstrap = [];
$this->basepath = null;
$this->reports = array('full' => null);
$this->reports = ['full' => null];
$this->reportWidth = 'auto';
$this->errorSeverity = 5;
$this->warningSeverity = 5;
Expand All @@ -483,7 +483,7 @@ public function restoreDefaults()
$this->stdin = false;
$this->stdinContent = null;
$this->stdinPath = null;
$this->unknown = array();
$this->unknown = [];

$standard = self::getConfigData('default_standard');
if ($standard !== null) {
Expand All @@ -492,7 +492,7 @@ public function restoreDefaults()

$reportFormat = self::getConfigData('report_format');
if ($reportFormat !== null) {
$this->reports = array($reportFormat => null);
$this->reports = [$reportFormat => null];
}

$tabWidth = self::getConfigData('tab_width');
Expand Down Expand Up @@ -891,7 +891,7 @@ public function processLongArgument($arg, $pos)
}
} else if (substr($arg, 0, 10) === 'bootstrap=') {
$files = explode(',', substr($arg, 10));
$bootstrap = array();
$bootstrap = [];
foreach ($files as $file) {
$path = Util\Common::realpath($file);
if ($path === false) {
Expand Down Expand Up @@ -1008,7 +1008,7 @@ public function processLongArgument($arg, $pos)
throw new DeepExitException($error, 3);
}
} else if ((substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-')) {
$reports = array();
$reports = [];

if ($arg[6] === '-') {
// This is a report with file output.
Expand Down Expand Up @@ -1083,7 +1083,7 @@ public function processLongArgument($arg, $pos)
}

$extensions = explode(',', substr($arg, 11));
$newExtensions = array();
$newExtensions = [];
foreach ($extensions as $ext) {
$slash = strpos($ext, '/');
if ($slash !== false) {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ public function processLongArgument($arg, $pos)
substr($arg, 7)
);

$ignored = array();
$ignored = [];
foreach ($patterns as $pattern) {
$pattern = trim($pattern);
if ($pattern === '') {
Expand Down Expand Up @@ -1619,8 +1619,8 @@ public static function getAllConfigData()
}

if (is_file($configFile) === false) {
self::$configData = array();
return array();
self::$configData = [];
return [];
}

if (is_readable($configFile) === false) {
Expand Down
Loading

0 comments on commit a9d8185

Please sign in to comment.