Commit 9188516f authored by catch's avatar catch

Issue #2572699 by rajeshwari10, andriyun, mfernea, pashupathi nath gajawada,...

Issue #2572699 by rajeshwari10, andriyun, mfernea, pashupathi nath gajawada, marvin_B8, attiks, andypost, alexpott: Fix 'Drupal.ControlStructures.InlineControlStructure' coding standard
parent 64fa6ad7
......@@ -264,7 +264,9 @@ public static function truncateBytes($string, $len) {
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);
}
......
......@@ -503,8 +503,9 @@ public function makeSequenceName($table, $field) {
* A sanitized comment string.
*/
public function makeComment($comments) {
if (empty($comments))
if (empty($comments)) {
return '';
}
// Flatten the array of comments.
$comment = implode('. ', $comments);
......
......@@ -497,8 +497,9 @@ public function fetchCol($index = 0) {
* {@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];
......
......@@ -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;
}
......
......@@ -41,7 +41,10 @@ public static function addRouteProvider(ContainerBuilder $container) {
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);
......
......@@ -25,7 +25,9 @@ public function testTaxonomyPageLocalTasks($route, $subtask = []) {
$tasks = [
0 => ['entity.taxonomy_term.canonical', 'entity.taxonomy_term.edit_form'],
];
if ($subtask) $tasks[] = $subtask;
if ($subtask) {
$tasks[] = $subtask;
}
$this->assertLocalTasks($route, $tasks);
}
......
......@@ -69,7 +69,9 @@ public function testUserPageLocalTasks($route, $subtask = []) {
$tasks = [
0 => ['entity.user.canonical', 'entity.user.edit_form'],
];
if ($subtask) $tasks[] = $subtask;
if ($subtask) {
$tasks[] = $subtask;
}
$this->assertLocalTasks($route, $tasks);
}
......
......@@ -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"/>
......
......@@ -136,7 +136,9 @@ protected function setUpEntityTypeDefinitions($definitions = []) {
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);
......
......@@ -115,7 +115,9 @@ protected function setUpEntityTypeDefinitions($definitions = []) {
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);
......
......@@ -73,7 +73,9 @@ protected function setUpEntityTypeDefinitions($definitions = []) {
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);
}
......
......@@ -101,7 +101,9 @@ protected function setUpEntityManager($definitions = []) {
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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment