Issue #2572693 by Mile23, andriyun, andypost, attiks: Fix 'Drupal.ControlStructures.ControlSignature' coding standard
parent
e46929c511
commit
a1d3a681f6
|
@ -1595,7 +1595,7 @@ function install_download_additional_translations_operations(&$install_state) {
|
|||
// should download/import translations.
|
||||
$languages = \Drupal::languageManager()->getLanguages();
|
||||
$operations = array();
|
||||
foreach($languages as $langcode => $language) {
|
||||
foreach ($languages as $langcode => $language) {
|
||||
// The installer language was already downloaded. Check downloads for the
|
||||
// other languages if any. Ignore any download errors here, since we
|
||||
// are in the middle of an install process and there is no way back. We
|
||||
|
|
|
@ -181,7 +181,7 @@ class PoItem {
|
|||
if (isset($values['translation'])) {
|
||||
$this->setTranslation($values['translation']);
|
||||
}
|
||||
if (isset($values['comment'])){
|
||||
if (isset($values['comment'])) {
|
||||
$this->setComment($values['comment']);
|
||||
}
|
||||
if (isset($this->_source) &&
|
||||
|
|
|
@ -92,7 +92,6 @@ EOS;
|
|||
// class.
|
||||
if ($parent_interfaces = $interface->getInterfaceNames()) {
|
||||
foreach ($parent_interfaces as $parent_interface) {
|
||||
if (isset($interfaces[$parent_interface])) {}
|
||||
unset($interfaces[$parent_interface]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class PhpTransliteration implements TransliterationInterface {
|
|||
$replacement = $character;
|
||||
if (($range1 && !in_array($code, $exclusions_range1)) || ($range2 && !in_array($code, $exclusions_range2))) {
|
||||
$to_add = $this->lookupReplacement($code, 'xyz');
|
||||
if(strlen($to_add) === 1) {
|
||||
if (strlen($to_add) === 1) {
|
||||
$replacement = $to_add;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class Random {
|
|||
$num_cons = count($cons);
|
||||
$word = '';
|
||||
|
||||
while(strlen($word) < $length){
|
||||
while (strlen($word) < $length) {
|
||||
$word .= $cons[mt_rand(0, $num_cons - 1)] . $vowels[mt_rand(0, $num_vowels - 1)];
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ class UserAgent {
|
|||
$qvalue = $ua_langcodes[$prefix];
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
|
||||
} while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
|
||||
|
||||
// Find the best match.
|
||||
if ($qvalue > $max_qvalue) {
|
||||
|
|
|
@ -76,10 +76,10 @@ class Cache {
|
|||
*/
|
||||
public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT) {
|
||||
// If one of the values is Cache::PERMANENT, return the other value.
|
||||
if ($a === Cache::PERMANENT){
|
||||
if ($a === Cache::PERMANENT) {
|
||||
return $b;
|
||||
}
|
||||
if ($b === Cache::PERMANENT){
|
||||
if ($b === Cache::PERMANENT) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ class CacheContextsManager {
|
|||
$ancestor_found = TRUE;
|
||||
}
|
||||
|
||||
} while(!$ancestor_found && strpos($ancestor, '.') !== FALSE);
|
||||
} while (!$ancestor_found && strpos($ancestor, '.') !== FALSE);
|
||||
if (!$ancestor_found) {
|
||||
$optimized_content_tokens[] = $context_token;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ class PhpBackend implements CacheBackendInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function invalidateAll() {
|
||||
foreach($this->storage()->listAll() as $cidhash) {
|
||||
foreach ($this->storage()->listAll() as $cidhash) {
|
||||
$this->invalidatebyHash($cidhash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
|
|||
// Because get() adds overrides both from $GLOBALS and from
|
||||
// $this->configFactoryOverrides, add cache keys for each.
|
||||
$keys[] = 'global_overrides';
|
||||
foreach($this->configFactoryOverrides as $override) {
|
||||
foreach ($this->configFactoryOverrides as $override) {
|
||||
$keys[] = $override->getCacheSuffix();
|
||||
}
|
||||
return $keys;
|
||||
|
|
|
@ -228,7 +228,7 @@ class ConfigDependencyManager {
|
|||
$graph = $this->getGraph();
|
||||
|
||||
foreach ($entities_to_check as $entity) {
|
||||
if (isset($graph[$entity]) && !empty($graph[$entity]['reverse_paths'])){
|
||||
if (isset($graph[$entity]) && !empty($graph[$entity]['reverse_paths'])) {
|
||||
foreach ($graph[$entity]['reverse_paths'] as $dependency => $value) {
|
||||
$dependent_entities[$dependency] = $this->data[$dependency];
|
||||
}
|
||||
|
|
|
@ -79,7 +79,8 @@ class Connection extends DatabaseConnection {
|
|||
public function query($query, array $args = array(), $options = array()) {
|
||||
try {
|
||||
return parent::query($query, $args, $options);
|
||||
} catch (DatabaseException $e) {
|
||||
}
|
||||
catch (DatabaseException $e) {
|
||||
if ($e->getPrevious()->errorInfo[1] == 1153) {
|
||||
// If a max_allowed_packet error occurs the message length is truncated.
|
||||
// This should prevent the error from recurring if the exception is
|
||||
|
|
|
@ -313,7 +313,7 @@ class Datelist extends DateElementBase {
|
|||
$form_state->setError($element, t('The %field date is required.'));
|
||||
}
|
||||
elseif (!empty($all_empty)) {
|
||||
foreach ($all_empty as $value){
|
||||
foreach ($all_empty as $value) {
|
||||
$form_state->setError($element[$value], t('A value must be selected for %part.', array('%part' => $value)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface {
|
|||
* Returns the called object.
|
||||
*/
|
||||
protected function addSortAggregate() {
|
||||
if(!$this->count) {
|
||||
if (!$this->count) {
|
||||
foreach ($this->sortAggregate as $alias => $sort) {
|
||||
$this->sqlQuery->orderBy($alias, $sort['direction']);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI
|
|||
$definitions[$plugin_id]['base_route'] = $definitions[$task_info['parent_id']]['base_route'];
|
||||
}
|
||||
if ($route_name == $task_info['route_name']) {
|
||||
if(!empty($task_info['base_route'])) {
|
||||
if (!empty($task_info['base_route'])) {
|
||||
$base_routes[$task_info['base_route']] = $task_info['base_route'];
|
||||
}
|
||||
// Tabs that link to the current route are viable parents
|
||||
|
|
|
@ -125,7 +125,7 @@ class VerticalTabs extends RenderElement {
|
|||
// form is rendered, e.g. on preview pages or when form validation
|
||||
// fails.
|
||||
$name = implode('__', $element['#parents']);
|
||||
if ($form_state->hasValue($name . '__active_tab')){
|
||||
if ($form_state->hasValue($name . '__active_tab')) {
|
||||
$element['#default_tab'] = $form_state->getValue($name . '__active_tab');
|
||||
}
|
||||
$element[$name . '__active_tab'] = array(
|
||||
|
|
|
@ -442,7 +442,7 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn
|
|||
*/
|
||||
protected function processFeed($attached_feed) {
|
||||
$html_head_link = [];
|
||||
foreach($attached_feed as $item) {
|
||||
foreach ($attached_feed as $item) {
|
||||
$feed_link = [
|
||||
'href' => $item[0],
|
||||
'rel' => 'alternate',
|
||||
|
|
|
@ -142,7 +142,8 @@ class MatcherDumper implements MatcherDumperInterface {
|
|||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception('Routing', $e);
|
||||
throw $e;
|
||||
|
|
|
@ -358,7 +358,8 @@ class UrlGenerator implements UrlGeneratorInterface {
|
|||
$port = '';
|
||||
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
|
||||
$port = ':' . $this->context->getHttpPort();
|
||||
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
|
||||
}
|
||||
elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
|
||||
$port = ':' . $this->context->getHttpsPort();
|
||||
}
|
||||
if ($collect_bubbleable_metadata) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class TestHttpClientMiddleware {
|
|||
// Call \Drupal\simpletest\WebTestBase::error() with the parameters from
|
||||
// the header.
|
||||
$parameters = unserialize(urldecode($header_value));
|
||||
if (count($parameters) === 3) {
|
||||
if (count($parameters) === 3) {
|
||||
throw new \Exception($parameters[1] . ': ' . $parameters[0] . "\n" . Error::formatBacktrace([$parameters[2]]));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -76,7 +76,7 @@ function color_library_info_alter(&$libraries, $extension) {
|
|||
$color_paths = \Drupal::config('color.theme.' . $extension)->get('stylesheets');
|
||||
if (!empty($color_paths)) {
|
||||
foreach (array_keys($libraries) as $name) {
|
||||
if(isset($libraries[$name]['css'])) {
|
||||
if (isset($libraries[$name]['css'])) {
|
||||
// Override stylesheets.
|
||||
foreach ($libraries[$name]['css'] as $category => $css_assets) {
|
||||
foreach ($css_assets as $path => $metadata) {
|
||||
|
|
|
@ -164,7 +164,7 @@ class ColorTest extends WebTestBase {
|
|||
$edit['palette[bg]'] = $color;
|
||||
$this->drupalPostForm($settings_path, $edit, t('Save configuration'));
|
||||
|
||||
if($is_valid) {
|
||||
if ($is_valid) {
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -388,7 +388,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
|||
if ($config_importer->alreadyImporting()) {
|
||||
drupal_set_message($this->t('Another request may be importing configuration already.'), 'error');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
try {
|
||||
$sync_steps = $config_importer->initialize();
|
||||
$batch = [
|
||||
|
|
|
@ -330,7 +330,7 @@ class ConfigSync extends FormBase {
|
|||
if ($config_importer->alreadyImporting()) {
|
||||
drupal_set_message($this->t('Another request may be synchronizing configuration already.'));
|
||||
}
|
||||
else{
|
||||
else {
|
||||
try {
|
||||
$sync_steps = $config_importer->initialize();
|
||||
$batch = array(
|
||||
|
|
|
@ -195,7 +195,8 @@ class ConfigEntityTest extends WebTestBase {
|
|||
try {
|
||||
$same_id->save();
|
||||
$this->fail('Not possible to overwrite an entity entity.');
|
||||
} catch (EntityStorageException $e) {
|
||||
}
|
||||
catch (EntityStorageException $e) {
|
||||
$this->pass('Not possible to overwrite an entity entity.');
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
\Drupal::service('module_installer')->install(array_keys($all_modules));
|
||||
|
||||
$this->assertModules(array_keys($all_modules), TRUE);
|
||||
foreach($all_modules as $module => $info) {
|
||||
foreach ($all_modules as $module => $info) {
|
||||
$this->assertModuleConfig($module);
|
||||
$this->assertModuleTablesExist($module);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
\Drupal::service('module_installer')->uninstall(array_keys($modules_to_uninstall));
|
||||
|
||||
$this->assertModules(array_keys($modules_to_uninstall), FALSE);
|
||||
foreach($modules_to_uninstall as $module => $info) {
|
||||
foreach ($modules_to_uninstall as $module => $info) {
|
||||
$this->assertNoModuleConfig($module);
|
||||
$this->assertModuleTablesDoNotExist($module);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class ConfigImportAllTest extends ModuleTestBase {
|
|||
|
||||
// Check that all modules that were uninstalled are now reinstalled.
|
||||
$this->assertModules(array_keys($modules_to_uninstall), TRUE);
|
||||
foreach($modules_to_uninstall as $module => $info) {
|
||||
foreach ($modules_to_uninstall as $module => $info) {
|
||||
$this->assertModuleConfig($module);
|
||||
$this->assertModuleTablesExist($module);
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
*/
|
||||
public function getMappers(RouteCollection $collection = NULL) {
|
||||
$mappers = array();
|
||||
foreach($this->getDefinitions() as $id => $definition) {
|
||||
foreach ($this->getDefinitions() as $id => $definition) {
|
||||
$mappers[$id] = $this->createInstance($id);
|
||||
if ($collection) {
|
||||
$mappers[$id]->setRouteCollection($collection);
|
||||
|
|
|
@ -456,7 +456,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
'medium' => 'Default medium date',
|
||||
'custom_medium' => 'Custom medium date',
|
||||
);
|
||||
foreach($formats as $id => $label) {
|
||||
foreach ($formats as $id => $label) {
|
||||
$translation_base_url = 'admin/config/regional/date-time/formats/manage/' . $id . '/translate';
|
||||
|
||||
$this->drupalGet($translation_base_url);
|
||||
|
|
|
@ -440,7 +440,8 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
$this->configNamesMapper->getLangcode();
|
||||
$this->fail();
|
||||
}
|
||||
catch (\RuntimeException $e) {}
|
||||
catch (\RuntimeException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -256,7 +256,7 @@ class ContactSitewideTest extends WebTestBase {
|
|||
|
||||
// Find out in which row the form we want to add a field to is.
|
||||
$i = 0;
|
||||
foreach($this->xpath('//table/tbody/tr') as $row) {
|
||||
foreach ($this->xpath('//table/tbody/tr') as $row) {
|
||||
if (((string) $row->td[0]->a) == $label) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ class ManagedFile extends FormElement {
|
|||
// Temporary files that belong to other users should never be
|
||||
// allowed.
|
||||
if ($file->isTemporary()) {
|
||||
if ($file->getOwnerId() != \Drupal::currentUser()->id()) {
|
||||
if ($file->getOwnerId() != \Drupal::currentUser()->id()) {
|
||||
$force_default = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -372,7 +372,8 @@ class FileWidget extends WidgetBase implements ContainerFactoryPluginInterface {
|
|||
);
|
||||
if (isset($item['display'])) {
|
||||
$element['display']['#value'] = $item['display'] ? '1' : '';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$element['display']['#value'] = $element['#display_default'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,7 +647,7 @@ function _filter_url_escape_comments($match, $escape = NULL) {
|
|||
|
||||
if (isset($escape)) {
|
||||
$mode = $escape;
|
||||
if ($escape){
|
||||
if ($escape) {
|
||||
$comments = array();
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -154,7 +154,7 @@ class FilterHtml extends FilterBase {
|
|||
*/
|
||||
protected function filterElementAttributes(\DOMElement $element, array $allowed_attributes) {
|
||||
$modified_attributes = [];
|
||||
foreach($element->attributes as $name => $attribute) {
|
||||
foreach ($element->attributes as $name => $attribute) {
|
||||
// Remove attributes not in the whitelist.
|
||||
$allowed_value = $this->findAllowedValue($allowed_attributes, $name);
|
||||
if (empty($allowed_value)) {
|
||||
|
|
|
@ -138,7 +138,7 @@ class ForumUninstallTest extends WebTestBase {
|
|||
// Delete all terms in the Forums vocabulary. Uninstalling the forum module
|
||||
// will fail unless this is done.
|
||||
$terms = entity_load_multiple_by_properties('taxonomy_term', array('vid' => 'forums'));
|
||||
foreach($terms as $term) {
|
||||
foreach ($terms as $term) {
|
||||
$term->delete();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class ImageCacheActions extends ProcessPluginBase {
|
|||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$effects = [];
|
||||
|
||||
foreach($row->getSourceProperty('actions') as $action) {
|
||||
foreach ($row->getSourceProperty('actions') as $action) {
|
||||
$id = preg_replace('/^imagecache/', 'image', $action['action']);
|
||||
|
||||
if ($id === 'image_crop') {
|
||||
|
|
|
@ -54,7 +54,7 @@ class ImageCachePreset extends DrupalSqlBase {
|
|||
->condition('presetid', $row->getSourceProperty('presetid'))
|
||||
->execute();
|
||||
|
||||
foreach($results as $key => $result) {
|
||||
foreach ($results as $key => $result) {
|
||||
$actions[$key] = $result;
|
||||
$actions[$key]['data'] = unserialize($result['data']);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ function language_entity_base_field_info_alter(&$fields) {
|
|||
foreach ($fields as $definition) {
|
||||
// Set configurable form display for language fields with display options.
|
||||
if ($definition->getType() == 'language') {
|
||||
foreach (array('form', 'view') as $type) {
|
||||
foreach (array('form', 'view') as $type) {
|
||||
if ($definition->getDisplayOptions($type)) {
|
||||
// The related configurations will be purged manually on Language
|
||||
// module uninstallation. @see language_modules_uninstalled().
|
||||
|
|
|
@ -371,7 +371,7 @@ function menu_ui_form_node_form_submit($form, FormStateInterface $form_state) {
|
|||
$entity->delete();
|
||||
}
|
||||
}
|
||||
elseif (trim($values['title'])) {
|
||||
elseif (trim($values['title'])) {
|
||||
// Decompose the selected menu parent option into 'menu_name' and 'parent',
|
||||
// if the form used the default parent selection widget.
|
||||
if (!empty($values['menu_parent'])) {
|
||||
|
|
|
@ -113,7 +113,7 @@ function rdf_get_namespaces() {
|
|||
// namespace, do not use \Drupal::moduleHandler()->invokeAll().
|
||||
foreach (\Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) {
|
||||
$function = $module . '_rdf_namespaces';
|
||||
foreach($function() as $prefix => $namespace) {
|
||||
foreach ($function() as $prefix => $namespace) {
|
||||
if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) {
|
||||
throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', array('@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix])));
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ function rdf_preprocess_html(&$variables) {
|
|||
if (!isset($variables['html_attributes']['prefix'])) {
|
||||
$variables['html_attributes']['prefix'] = array();
|
||||
}
|
||||
foreach(rdf_get_namespaces() as $prefix => $uri) {
|
||||
foreach (rdf_get_namespaces() as $prefix => $uri) {
|
||||
$variables['html_attributes']['prefix'][] = $prefix . ': ' . $uri . " ";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class ResponsiveImageStyle extends ConfigEntityBase implements ResponsiveImageSt
|
|||
public function getKeyedImageStyleMappings() {
|
||||
if (!$this->keyedImageStyleMappings) {
|
||||
$this->keyedImageStyleMappings = array();
|
||||
foreach($this->image_style_mappings as $mapping) {
|
||||
foreach ($this->image_style_mappings as $mapping) {
|
||||
if (!static::isEmptyImageStyleMapping($mapping)) {
|
||||
$this->keyedImageStyleMappings[$mapping['breakpoint_id']][$mapping['multiplier']] = $mapping;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ class SearchMultilingualEntityTest extends SearchTestBase {
|
|||
$this->assertEqual(count($search_result), 2, 'The search found 2 results');
|
||||
|
||||
// Test to check for the language of result items.
|
||||
foreach($search_result as $result) {
|
||||
foreach ($search_result as $result) {
|
||||
$this->assertEqual($result['langcode'], 'hu', 'The search found the correct Hungarian result');
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,8 @@ class SearchRankingTest extends SearchTestBase {
|
|||
// Assert the results.
|
||||
if ($tag == 'notag') {
|
||||
$this->assertEqual($set[$tag_rank]['node']->id(), $nodes[$tag]->id(), 'Search tag ranking for plain text order.');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$this->assertEqual($set[$tag_rank]['node']->id(), $nodes[$tag]->id(), 'Search tag ranking for "<' . $sorted_tags[$tag_rank] . '>" order.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
$shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
|
||||
$this->assertEqual((string) $shortcuts[0], 'Add content');
|
||||
$this->assertEqual((string) $shortcuts[1], 'All content');
|
||||
foreach($this->set->getShortcuts() as $shortcut) {
|
||||
foreach ($this->set->getShortcuts() as $shortcut) {
|
||||
$shortcut->setWeight($shortcut->getWeight() * -1)->save();
|
||||
}
|
||||
$this->drupalGet(Url::fromRoute('<front>'));
|
||||
|
|
|
@ -2539,7 +2539,7 @@ abstract class WebTestBase extends TestBase {
|
|||
* TRUE on pass, FALSE on fail.
|
||||
*/
|
||||
protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
|
||||
if ($path instanceof Url) {
|
||||
if ($path instanceof Url) {
|
||||
$url_obj = $path;
|
||||
}
|
||||
elseif (UrlHelper::isExternal($path)) {
|
||||
|
|
|
@ -58,10 +58,10 @@ class MachineNameController implements ContainerInjectionInterface {
|
|||
$lowercase = $request->query->get('lowercase');
|
||||
|
||||
$transliterated = $this->transliteration->transliterate($text, $langcode, '_');
|
||||
if($lowercase) {
|
||||
if ($lowercase) {
|
||||
$transliterated = Unicode::strtolower($transliterated);
|
||||
}
|
||||
if(isset($replace_pattern) && isset($replace)) {
|
||||
if (isset($replace_pattern) && isset($replace)) {
|
||||
// Quote the pattern delimiter and remove null characters to avoid the e
|
||||
// or other modifiers being injected.
|
||||
$transliterated = preg_replace('@' . strtr($replace_pattern, ['@' => '\@', chr(0) => '']) . '@', $replace, $transliterated);
|
||||
|
|
|
@ -187,7 +187,7 @@ class RenderElementTypesTest extends KernelTestBase {
|
|||
),
|
||||
);
|
||||
|
||||
foreach($elements as $element) {
|
||||
foreach ($elements as $element) {
|
||||
$xml = new \SimpleXMLElement(\Drupal::service('renderer')->renderRoot($element['value']));
|
||||
$result = $xml->xpath($element['expected']);
|
||||
$this->assertTrue($result, '"' . $element['name'] . '" input rendered correctly by drupal_render().');
|
||||
|
|
|
@ -192,8 +192,7 @@ abstract class EntityUnitTestBase extends KernelTestBase {
|
|||
// Drupal supported databases and is known to work for other databases
|
||||
// like SQL Server 2014 and Oracle 10 too.
|
||||
$id = $string ? $this->randomMachineName() : mt_rand(1, 0x7FFFFFFF);
|
||||
}
|
||||
while (isset($this->generatedIds[$id]));
|
||||
} while (isset($this->generatedIds[$id]));
|
||||
$this->generatedIds[$id] = $id;
|
||||
return $id;
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ class ToolkitGdTest extends KernelTestBase {
|
|||
if ($image_reloaded->getToolkit()->getType() == IMAGETYPE_GIF) {
|
||||
$this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', array('%file' => $file)));
|
||||
}
|
||||
else {
|
||||
else {
|
||||
$this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', array('%file' => $file)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ ENDPO;
|
|||
$test_samples = ['Save and continue', 'Anonymous', 'Language'];
|
||||
$langcodes = ['de', 'es'];
|
||||
|
||||
foreach($test_samples as $sample) {
|
||||
foreach($langcodes as $langcode) {
|
||||
foreach ($test_samples as $sample) {
|
||||
foreach ($langcodes as $langcode) {
|
||||
$edit = array();
|
||||
$edit['langcode'] = $langcode;
|
||||
$edit['translation'] = 'translated';
|
||||
|
|
|
@ -95,7 +95,7 @@ class InstallerTranslationTest extends InstallerTestBase {
|
|||
|
||||
// Verify the strings from the translation files were imported.
|
||||
$test_samples = ['Save and continue', 'Anonymous'];
|
||||
foreach($test_samples as $sample) {
|
||||
foreach ($test_samples as $sample) {
|
||||
$edit = array();
|
||||
$edit['langcode'] = 'de';
|
||||
$edit['translation'] = 'translated';
|
||||
|
|
|
@ -132,7 +132,8 @@ class KeyValueContentEntityStorageTest extends KernelTestBase {
|
|||
try {
|
||||
$same_id->save();
|
||||
$this->fail('Not possible to overwrite an entity entity.');
|
||||
} catch (EntityStorageException $e) {
|
||||
}
|
||||
catch (EntityStorageException $e) {
|
||||
$this->pass('Not possible to overwrite an entity entity.');
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,8 @@ class UninstallTest extends WebTestBase {
|
|||
try {
|
||||
$this->container->get('module_installer')->install(array('module_installer_config_test'));
|
||||
$this->fail($message);
|
||||
} catch (EntityMalformedException $e) {
|
||||
}
|
||||
catch (EntityMalformedException $e) {
|
||||
$this->pass($message);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class ContextPluginTest extends KernelTestBase {
|
|||
try {
|
||||
$plugin->getContextValue('user');
|
||||
}
|
||||
catch(ContextException $e) {
|
||||
catch (ContextException $e) {
|
||||
$this->assertIdentical("The 'entity:user' context is required and not present.", $e->getMessage(), 'Requesting a non-set value of a required context should throw a context exception.');
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class ErrorHandlerTest extends WebTestBase {
|
|||
'%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
|
||||
'@message' => 'Argument 1 passed to Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}() must be of the type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 62 and defined',
|
||||
);
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) {
|
||||
// In PHP 7, instead of a recoverable fatal error we get a TypeError.
|
||||
$fatal_error['%type'] = 'TypeError';
|
||||
// The error message also changes in PHP 7.
|
||||
|
|
|
@ -248,7 +248,7 @@ class TypedDataTest extends KernelTestBase {
|
|||
|
||||
// Generate some files that will be used to test the binary data type.
|
||||
$files = array();
|
||||
for ($i = 0; $i < 3; $i++){
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$path = "public://example_$i.png";
|
||||
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path);
|
||||
$image = File::create(['uri' => $path]);
|
||||
|
|
|
@ -16,7 +16,7 @@ class EntityTestLocalTasks extends DeriverBase {
|
|||
$this->derivatives = array();
|
||||
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
|
||||
|
||||
foreach($types as $entity_type) {
|
||||
foreach ($types as $entity_type) {
|
||||
$this->derivatives[$entity_type . '.canonical'] = array();
|
||||
$this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
|
||||
$this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
|
||||
|
|
|
@ -322,7 +322,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
|
||||
// We only validate if they've chosen the text field style.
|
||||
if ($this->options['type'] != 'textfield') {
|
||||
if ($form_state->getValue($identifier) != 'All') {
|
||||
if ($form_state->getValue($identifier) != 'All') {
|
||||
$this->validated_exposed_input = (array) $form_state->getValue($identifier);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -326,7 +326,7 @@ function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
|
|||
$values = array('name' => trim($name));
|
||||
if (isset($vocabulary)) {
|
||||
$vocabularies = taxonomy_vocabulary_get_names();
|
||||
if (isset($vocabularies[$vocabulary])){
|
||||
if (isset($vocabularies[$vocabulary])) {
|
||||
$values['vid'] = $vocabulary;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -171,7 +171,7 @@ class Tour extends ConfigEntityBase implements TourInterface {
|
|||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
|
||||
foreach($this->tipsCollection as $instance) {
|
||||
foreach ($this->tipsCollection as $instance) {
|
||||
$definition = $instance->getPluginDefinition();
|
||||
$this->addDependency('module', $definition['provider']);
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
|
|||
$top = array_shift($parts);
|
||||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
|
||||
$token_array = array(array_pop($parts) => $replacement);
|
||||
foreach(array_reverse($parts) as $key) {
|
||||
foreach (array_reverse($parts) as $key) {
|
||||
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1', 'Tokens need to be valid Twig variables.');
|
||||
$token_array = array($key => $token_array);
|
||||
}
|
||||
|
|
|
@ -720,7 +720,7 @@ abstract class StylePluginBase extends PluginBase {
|
|||
$fields = $this->view->field;
|
||||
$rendered_fields = &$this->rendered_fields[$index];
|
||||
$post_render_tokens = [];
|
||||
foreach ($field_ids as $id) {
|
||||
foreach ($field_ids as $id) {
|
||||
$rendered_fields[$id] = $data[$id]['#markup'];
|
||||
$tokens = $fields[$id]->postRender($row, $rendered_fields[$id]);
|
||||
if ($tokens) {
|
||||
|
|
|
@ -38,7 +38,7 @@ class NewViewConfigSchemaTest extends WebTestBase {
|
|||
'standard:aggregator_feed',
|
||||
'standard:aggregator_item',
|
||||
);
|
||||
foreach($wizards as $wizard_key) {
|
||||
foreach ($wizards as $wizard_key) {
|
||||
$edit = array();
|
||||
$edit['label'] = $this->randomString();
|
||||
$edit['id'] = strtolower($this->randomMachineName());
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<exclude name="Drupal.Commenting.FunctionComment.WrongStyle"/>
|
||||
</rule>
|
||||
<rule ref="Drupal.ControlStructures.ElseIf"/>
|
||||
<rule ref="Drupal.ControlStructures.ControlSignature"/>
|
||||
<rule ref="Drupal.Files.EndFileNewline"/>
|
||||
<rule ref="Drupal.Files.TxtFileLineLength"/>
|
||||
<rule ref="Drupal.Formatting.SpaceInlineIf"/>
|
||||
|
|
|
@ -75,7 +75,7 @@ trait AssertConfigTrait {
|
|||
}
|
||||
foreach ($op->closing as $closing) {
|
||||
// The UUIDs don't exist in the default config.
|
||||
if (strpos($closing, 'uuid: ') === 0) {
|
||||
if (strpos($closing, 'uuid: ') === 0) {
|
||||
continue;
|
||||
}
|
||||
throw new \Exception($config_name . ': ' . var_export($op, TRUE));
|
||||
|
|
|
@ -263,7 +263,7 @@ class ConfigCRUDTest extends KernelTestBase {
|
|||
$this->assertIdentical($config->get(), $data);
|
||||
|
||||
// Re-set each key using Config::set().
|
||||
foreach($data as $key => $value) {
|
||||
foreach ($data as $key => $value) {
|
||||
$config->set($key, $value);
|
||||
}
|
||||
$config->save();
|
||||
|
|
|
@ -473,7 +473,7 @@ class ConfigDependencyTest extends EntityKernelTestBase {
|
|||
*/
|
||||
protected function getDependentIds(array $dependents) {
|
||||
$dependent_ids = array();
|
||||
foreach($dependents as $dependent) {
|
||||
foreach ($dependents as $dependent) {
|
||||
$dependent_ids[] = $dependent->getEntityTypeId() . ':' . $dependent->id();
|
||||
}
|
||||
return $dependent_ids;
|
||||
|
|
|
@ -34,7 +34,8 @@ class InsertDefaultsTest extends DatabaseTestBase {
|
|||
db_insert('test')->execute();
|
||||
// This is only executed if no exception has been thrown.
|
||||
$this->fail('Expected exception NoFieldsException has not been thrown.');
|
||||
} catch (NoFieldsException $e) {
|
||||
}
|
||||
catch (NoFieldsException $e) {
|
||||
$this->pass('Expected exception NoFieldsException has been thrown.');
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ class LargeQueryTest extends DatabaseTestBase {
|
|||
try {
|
||||
db_query('SELECT name FROM {test} WHERE name = :name', array(':name' => $long_name));
|
||||
$this->fail("An exception should be thrown for queries larger than 'max_allowed_packet'");
|
||||
} catch (DatabaseException $e) {
|
||||
}
|
||||
catch (DatabaseException $e) {
|
||||
// Close and re-open the connection. Otherwise we will run into error
|
||||
// 2006 "MySQL server had gone away" afterwards.
|
||||
Database::closeConnection();
|
||||
|
|
|
@ -230,7 +230,8 @@ class SchemaTest extends KernelTestBase {
|
|||
try {
|
||||
db_create_table('test_timestamp', $table_specification);
|
||||
}
|
||||
catch (\Exception $e) {}
|
||||
catch (\Exception $e) {
|
||||
}
|
||||
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
|
||||
}
|
||||
|
||||
|
|
|
@ -368,7 +368,8 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
|
|||
->fields($values)
|
||||
->execute();
|
||||
$this->pass($message);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Keep throwing it.
|
||||
throw $e;
|
||||
}
|
||||
|
|
|
@ -189,8 +189,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
|
|||
// Drupal supported databases and is known to work for other databases
|
||||
// like SQL Server 2014 and Oracle 10 too.
|
||||
$id = $string ? $this->randomMachineName() : mt_rand(1, 0x7FFFFFFF);
|
||||
}
|
||||
while (isset($this->generatedIds[$id]));
|
||||
} while (isset($this->generatedIds[$id]));
|
||||
$this->generatedIds[$id] = $id;
|
||||
return $id;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class EntityUUIDTest extends EntityKernelTestBase {
|
|||
// Creating a duplicate needs to result in a new UUID.
|
||||
$entity_duplicate = $entity->createDuplicate();
|
||||
foreach ($entity->getFields() as $property => $value) {
|
||||
switch($property) {
|
||||
switch ($property) {
|
||||
case 'uuid':
|
||||
$this->assertNotNull($entity_duplicate->uuid());
|
||||
$this->assertNotNull($entity->uuid());
|
||||
|
|
|
@ -178,7 +178,7 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
*/
|
||||
public function aliasManagerCallback() {
|
||||
$args = func_get_args();
|
||||
switch($args[0]) {
|
||||
switch ($args[0]) {
|
||||
case '/test/one':
|
||||
return '/hello/world';
|
||||
case '/test/two/5':
|
||||
|
|
Loading…
Reference in New Issue