PSR2: Automatic fixes

This commit is contained in:
Damian Mooyman 2016-11-29 12:33:28 +13:00
parent 1b1e921e3d
commit 4b7d31377b
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
12 changed files with 73 additions and 59 deletions

View File

@ -402,14 +402,15 @@ class GDBackend extends Object implements Image_Backend, Flushable
switch ($angle) { switch ($angle) {
case 90: case 90:
imagesetpixel($rotate, $y, $destHeight - $x - 1, $color); imagesetpixel($rotate, $y, $destHeight - $x - 1, $color);
break; break;
case 180: case 180:
imagesetpixel($rotate, $destWidth - $x - 1, $destHeight - $y - 1, $color); imagesetpixel($rotate, $destWidth - $x - 1, $destHeight - $y - 1, $color);
break; break;
case 270: case 270:
imagesetpixel($rotate, $destWidth - $y - 1, $x, $color); imagesetpixel($rotate, $destWidth - $y - 1, $x, $color);
break; break;
default: $rotate = $this->gd; default:
$rotate = $this->gd;
}; };
} }
} }

View File

@ -744,16 +744,16 @@ class Email extends ViewableData
public static function obfuscate($email, $method = 'visible') public static function obfuscate($email, $method = 'visible')
{ {
switch ($method) { switch ($method) {
case 'direction' : case 'direction':
Requirements::customCSS( Requirements::customCSS(
'span.codedirection { unicode-bidi: bidi-override; direction: rtl; }', 'span.codedirection { unicode-bidi: bidi-override; direction: rtl; }',
'codedirectionCSS' 'codedirectionCSS'
); );
return '<span class="codedirection">' . strrev($email) . '</span>'; return '<span class="codedirection">' . strrev($email) . '</span>';
case 'visible' : case 'visible':
$obfuscated = array('@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] '); $obfuscated = array('@' => ' [at] ', '.' => ' [dot] ', '-' => ' [dash] ');
return strtr($email, $obfuscated); return strtr($email, $obfuscated);
case 'hex' : case 'hex':
$encoded = ''; $encoded = '';
for ($x=0; $x < strlen($email); for ($x=0; $x < strlen($email);
$x++) { $x++) {

View File

@ -489,7 +489,7 @@ class Config
return false; return false;
} }
static protected function check_key_or_value_contained_in_suppress_array($k, $v, $suppresses) protected static function check_key_or_value_contained_in_suppress_array($k, $v, $suppresses)
{ {
foreach ($suppresses as $suppress) { foreach ($suppresses as $suppress) {
list($sk, $sv) = $suppress; list($sk, $sv) = $suppress;
@ -500,7 +500,7 @@ class Config
return false; return false;
} }
static protected function filter_array_by_suppress_array($array, $suppress) protected static function filter_array_by_suppress_array($array, $suppress)
{ {
$res = array(); $res = array();

View File

@ -237,13 +237,13 @@ function translate_memstring($memString)
{ {
switch (strtolower(substr($memString, -1))) { switch (strtolower(substr($memString, -1))) {
case "k": case "k":
return round(substr($memString, 0, -1)*1024); return round(substr($memString, 0, -1)*1024);
case "m": case "m":
return round(substr($memString, 0, -1)*1024*1024); return round(substr($memString, 0, -1)*1024*1024);
case "g": case "g":
return round(substr($memString, 0, -1)*1024*1024*1024); return round(substr($memString, 0, -1)*1024*1024*1024);
default: default:
return round($memString); return round($memString);
} }
} }

View File

@ -89,14 +89,14 @@ trait CustomMethods
); );
} }
} }
case isset($config['wrap']) : case isset($config['wrap']):
array_unshift($arguments, $config['method']); array_unshift($arguments, $config['method']);
return call_user_func_array(array($this, $config['wrap']), $arguments); return call_user_func_array(array($this, $config['wrap']), $arguments);
case isset($config['function']) : case isset($config['function']):
return $config['function']($this, $arguments); return $config['function']($this, $arguments);
default : default:
throw new BadMethodCallException( throw new BadMethodCallException(
"Object->__call(): extra method $method is invalid on $class:" "Object->__call(): extra method $method is invalid on $class:"
. var_export($config, true) . var_export($config, true)

View File

@ -126,19 +126,19 @@ abstract class Object
switch ($argString[0]) { switch ($argString[0]) {
case '"': case '"':
$result = stripcslashes(substr($argString, 1, -1)); $result = stripcslashes(substr($argString, 1, -1));
break; break;
case "'": case "'":
$result = str_replace(array("\\\\", "\\'"), array("\\", "'"), substr($argString, 1, -1)); $result = str_replace(array("\\\\", "\\'"), array("\\", "'"), substr($argString, 1, -1));
break; break;
default: default:
throw new Exception("Bad T_CONSTANT_ENCAPSED_STRING arg $argString"); throw new Exception("Bad T_CONSTANT_ENCAPSED_STRING arg $argString");
} }
break; break;
case T_DNUMBER: case T_DNUMBER:
$result = (double)$token[1]; $result = (double)$token[1];
break; break;
case T_LNUMBER: case T_LNUMBER:
$result = (int)$token[1]; $result = (int)$token[1];
@ -150,25 +150,28 @@ abstract class Object
end($bucket); end($bucket);
$currentKey = current($bucket); $currentKey = current($bucket);
array_pop($bucket); array_pop($bucket);
break; break;
case T_STRING: case T_STRING:
switch ($token[1]) { switch ($token[1]) {
case 'true': $result = true; case 'true':
$result = true;
break; break;
case 'false': $result = false; case 'false':
$result = false;
break; break;
case 'null': $result = null; case 'null':
$result = null;
$forceResult = true; $forceResult = true;
break; break;
default: default:
throw new Exception("Bad T_STRING arg '{$token[1]}'"); throw new Exception("Bad T_STRING arg '{$token[1]}'");
} }
break; break;
case T_ARRAY: case T_ARRAY:
$result = array(); $result = array();

View File

@ -92,21 +92,26 @@ class CliTestReporter extends SapphireTestReporter
{ {
// Status indicator, a la PHPUnit // Status indicator, a la PHPUnit
switch ($this->currentTest['status']) { switch ($this->currentTest['status']) {
case TEST_FAILURE: echo CLI::text("F", "red", null, true); case TEST_FAILURE:
echo CLI::text("F", "red", null, true);
break; break;
case TEST_ERROR: echo CLI::text("E", "red", null, true); case TEST_ERROR:
echo CLI::text("E", "red", null, true);
break; break;
case TEST_INCOMPLETE: echo CLI::text("I", "yellow"); case TEST_INCOMPLETE:
echo CLI::text("I", "yellow");
break; break;
case TEST_SUCCESS: echo CLI::text(".", "green"); case TEST_SUCCESS:
echo CLI::text(".", "green");
break; break;
default: echo CLI::text("?", "yellow"); default:
echo CLI::text("?", "yellow");
break; break;
} }
static $colCount = 0; static $colCount = 0;

View File

@ -452,18 +452,22 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener
foreach ($suite['tests'] as $test) { foreach ($suite['tests'] as $test) {
$testCount++; $testCount++;
switch ($test['status']) { switch ($test['status']) {
case TEST_ERROR: $errorCount++; case TEST_ERROR:
$errorCount++;
break; break;
case TEST_INCOMPLETE: $incompleteCount++; case TEST_INCOMPLETE:
$incompleteCount++;
break; break;
case TEST_SUCCESS: $passCount++; case TEST_SUCCESS:
$passCount++;
break; break;
case TEST_FAILURE: $failCount++; case TEST_FAILURE:
$failCount++;
break; break;
} }
// Report test error // Report test error

View File

@ -331,7 +331,6 @@ abstract class Database
// Switch command type // Switch command type
switch ($writeInfo['command']) { switch ($writeInfo['command']) {
case "update": case "update":
// Build update // Build update
$query = new SQLUpdate("\"$table\"", $this->escapeColumnKeys($fieldValues)); $query = new SQLUpdate("\"$table\"", $this->escapeColumnKeys($fieldValues));

View File

@ -405,12 +405,14 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
// Validate and process arguments // Validate and process arguments
$arguments = func_get_args(); $arguments = func_get_args();
switch (sizeof($arguments)) { switch (sizeof($arguments)) {
case 1: $filters = $arguments[0]; case 1:
$filters = $arguments[0];
break; break;
case 2: $filters = array($arguments[0] => $arguments[1]); case 2:
$filters = array($arguments[0] => $arguments[1]);
break; break;
default: default:
throw new InvalidArgumentException('Incorrect number of arguments passed to filter()'); throw new InvalidArgumentException('Incorrect number of arguments passed to filter()');
} }

View File

@ -392,7 +392,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider
$stageTable = $this->stageTable($table, $stage); $stageTable = $this->stageTable($table, $stage);
$query->renameTable($table, $stageTable); $query->renameTable($table, $stageTable);
} }
break; break;
// Reading a specific stage, but only return items that aren't in any other stage // Reading a specific stage, but only return items that aren't in any other stage
case 'stage_unique': case 'stage_unique':
@ -420,7 +420,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider
$query->addWhere('"'.$baseTable.'"."ID" NOT IN (SELECT "ID" FROM "'.$tempName.'")'); $query->addWhere('"'.$baseTable.'"."ID" NOT IN (SELECT "ID" FROM "'.$tempName.'")');
$query->renameTable($tempName, $excludingTable); $query->renameTable($tempName, $excludingTable);
} }
break; break;
// Return all version instances // Return all version instances
case 'archive': case 'archive':
@ -516,9 +516,9 @@ class Versioned extends DataExtension implements TemplateGlobalProvider
break; break;
} }
} }
break; break;
default: default:
throw new InvalidArgumentException("Bad value for query parameter Versioned.mode: " throw new InvalidArgumentException("Bad value for query parameter Versioned.mode: "
. $dataQuery->getQueryParam('Versioned.mode')); . $dataQuery->getQueryParam('Versioned.mode'));
} }
} }

View File

@ -124,11 +124,11 @@ class ThemeResourceLoader
switch ($package) { switch ($package) {
case 'silverstripe/framework': case 'silverstripe/framework':
$modulePath = FRAMEWORK_DIR; $modulePath = FRAMEWORK_DIR;
break; break;
case 'silverstripe/cms': case 'silverstripe/cms':
$modulePath = CMS_DIR; $modulePath = CMS_DIR;
break; break;
default: default:
list($vendor, $modulePath) = explode('/', $parts[0], 2); list($vendor, $modulePath) = explode('/', $parts[0], 2);