Issue #2572699 by rajeshwari10, andriyun, mfernea, pashupathi nath gajawada, marvin_B8, attiks, andypost, alexpott: Fix 'Drupal.ControlStructures.InlineControlStructure' coding standard

8.5.x
Nathaniel Catchpole 2017-10-10 16:14:44 +01:00
parent 64fa6ad712
commit 9188516f1b
12 changed files with 48 additions and 16 deletions

View File

@ -264,7 +264,9 @@ EOD;
return substr($string, 0, $len);
}
// Scan backwards to beginning of the byte sequence.
while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0);
// @todo Make the code more readable in https://www.drupal.org/node/2911497.
while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0) {
}
return substr($string, 0, $len);
}

View File

@ -503,8 +503,9 @@ abstract class Connection {
* A sanitized comment string.
*/
public function makeComment($comments) {
if (empty($comments))
if (empty($comments)) {
return '';
}
// Flatten the array of comments.
$comment = implode('. ', $comments);

View File

@ -497,8 +497,9 @@ class StatementPrefetch implements \Iterator, StatementInterface {
* {@inheritdoc}
*/
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index]))
if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index])) {
return [];
}
$key = $this->columnNames[$key_index];
$value = $this->columnNames[$value_index];

View File

@ -796,9 +796,15 @@ function _color_hsl2rgb($hsl) {
*/
function _color_hue2rgb($m1, $m2, $h) {
$h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
if ($h * 2 < 1) return $m2;
if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
if ($h * 6 < 1) {
return $m1 + ($m2 - $m1) * $h * 6;
}
if ($h * 2 < 1) {
return $m2;
}
if ($h * 3 < 2) {
return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
}
return $m1;
}
@ -822,9 +828,15 @@ function _color_rgb2hsl($rgb) {
$h = 0;
if ($delta > 0) {
if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
if ($max == $r && $max != $g) {
$h += ($g - $b) / $delta;
}
if ($max == $g && $max != $b) {
$h += (2 + ($b - $r) / $delta);
}
if ($max == $b && $max != $r) {
$h += (4 + ($r - $g) / $delta);
}
$h /= 6;
}

View File

@ -41,7 +41,10 @@ class TestServiceProvider implements ServiceProviderInterface, ServiceModifierIn
foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
// While $container->get() does a recursive resolve, getDefinition() does
// not, so do it ourselves.
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id));
// @todo Make the code more readable in
// https://www.drupal.org/node/2911498.
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id)) {
}
$definition = $container->getDefinition($id);
$definition->clearTag('needs_destruction');
$container->setDefinition("simpletest.$original_id", $definition);

View File

@ -25,7 +25,9 @@ class TaxonomyLocalTasksTest extends LocalTaskIntegrationTestBase {
$tasks = [
0 => ['entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'],
];
if ($subtask) $tasks[] = $subtask;
if ($subtask) {
$tasks[] = $subtask;
}
$this->assertLocalTasks($route, $tasks);
}

View File

@ -69,7 +69,9 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
$tasks = [
0 => ['entity.user.canonical', 'entity.user.edit_form'],
];
if ($subtask) $tasks[] = $subtask;
if ($subtask) {
$tasks[] = $subtask;
}
$this->assertLocalTasks($route, $tasks);
}

View File

@ -74,6 +74,7 @@
</rule>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php"/>

View File

@ -136,7 +136,9 @@ class EntityTypeBundleInfoTest extends UnitTestCase {
elseif (!$exception_on_invalid) {
return NULL;
}
else throw new PluginNotFoundException($entity_type_id);
else {
throw new PluginNotFoundException($entity_type_id);
}
});
$this->entityTypeManager->getDefinitions()->willReturn($definitions);

View File

@ -115,7 +115,9 @@ class EntityTypeManagerTest extends UnitTestCase {
elseif (!$exception_on_invalid) {
return NULL;
}
else throw new PluginNotFoundException($entity_type_id);
else {
throw new PluginNotFoundException($entity_type_id);
}
});
$this->discovery->getDefinitions()->willReturn($definitions);

View File

@ -73,7 +73,9 @@ class EntityTypeRepositoryTest extends UnitTestCase {
elseif (!$exception_on_invalid) {
return NULL;
}
else throw new PluginNotFoundException($entity_type_id);
else {
throw new PluginNotFoundException($entity_type_id);
}
});
$this->entityTypeManager->getDefinitions()->willReturn($definitions);
}

View File

@ -101,7 +101,9 @@ class FieldDefinitionListenerTest extends UnitTestCase {
elseif (!$exception_on_invalid) {
return NULL;
}
else throw new PluginNotFoundException($entity_type_id);
else {
throw new PluginNotFoundException($entity_type_id);
}
});
$this->entityTypeManager->getDefinitions()->willReturn($definitions);
}