Unverified Commit ddd8c7d8 authored by alexpott's avatar alexpott
Browse files

Issue #3106216 by Spokje, longwave, alexpott, apaderno, Hardik_Patel_12,...

Issue #3106216 by Spokje, longwave, alexpott, apaderno, Hardik_Patel_12, daffie: Remove unused variables from core

(cherry picked from commit 2f1c7166)
parent a5f202d3
......@@ -543,7 +543,7 @@ function drupal_flush_all_caches($kernel = NULL) {
$module_handler = \Drupal::moduleHandler();
// Flush all persistent caches.
$module_handler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
foreach (Cache::getBins() as $cache_backend) {
$cache_backend->deleteAll();
}
......
......@@ -1173,7 +1173,7 @@ function install_verify_database_ready() {
$table = key($system_schema);
$existing_install = FALSE;
if ($database = Database::getConnectionInfo()) {
if (Database::getConnectionInfo()) {
try {
$existing_install = Database::getConnection()->schema()->tableExists($table);
}
......@@ -2424,7 +2424,6 @@ function install_config_revert_install_changes() {
$config_importer->import();
}
catch (ConfigImporterException $e) {
global $install_state;
$messenger = \Drupal::messenger();
// There are validation errors.
$messenger->addError(t('The configuration synchronization failed validation.'));
......
......@@ -250,8 +250,8 @@ protected function getServiceDefinition(Definition $definition) {
$service['shared'] = $definition->isShared();
}
if (($decorated = $definition->getDecoratedService()) !== NULL) {
throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal 8 run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
if ($definition->getDecoratedService() !== NULL) {
throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
}
if ($callable = $definition->getFactory()) {
......
......@@ -130,8 +130,8 @@ public function dispatch($event/*, string $event_name = NULL*/) {
}
// Invoke listeners and resolve callables if necessary.
foreach ($this->listeners[$event_name] as $priority => &$definitions) {
foreach ($definitions as $key => &$definition) {
foreach ($this->listeners[$event_name] as &$definitions) {
foreach ($definitions as &$definition) {
if (!isset($definition['callable'])) {
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
}
......@@ -173,8 +173,8 @@ public function getListeners($event_name = NULL): array {
}
// Collect listeners and resolve callables if necessary.
foreach ($this->listeners[$event_name] as $priority => &$definitions) {
foreach ($definitions as $key => &$definition) {
foreach ($this->listeners[$event_name] as &$definitions) {
foreach ($definitions as &$definition) {
if (!isset($definition['callable'])) {
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
}
......@@ -202,7 +202,7 @@ public function getListenerPriority($event_name, $listener): ?int {
}
// Resolve service definitions if the listener has not been found so far.
foreach ($this->listeners[$event_name] as $priority => &$definitions) {
foreach ($definitions as $key => &$definition) {
foreach ($definitions as &$definition) {
if (!isset($definition['callable'])) {
// Once the callable is retrieved we keep it for subsequent method
// invocations on this class.
......
......@@ -79,7 +79,7 @@ public function build($class_name) {
// In order to avoid that, check for each interface, whether one of its
// parents is also in the list and exclude it.
if ($interfaces = $reflection->getInterfaces()) {
foreach ($interfaces as $interface_name => $interface) {
foreach ($interfaces as $interface) {
// Exclude all parents from the list of implemented interfaces of the
// class.
if ($parent_interfaces = $interface->getInterfaceNames()) {
......
......@@ -143,7 +143,7 @@ public static function allowedIfHasPermissions(AccountInterface $account, array
if ($conjunction == 'AND' && !empty($permissions)) {
$access = TRUE;
foreach ($permissions as $permission) {
if (!$permission_access = $account->hasPermission($permission)) {
if (!$account->hasPermission($permission)) {
$access = FALSE;
break;
}
......@@ -151,7 +151,7 @@ public static function allowedIfHasPermissions(AccountInterface $account, array
}
else {
foreach ($permissions as $permission) {
if ($permission_access = $account->hasPermission($permission)) {
if ($account->hasPermission($permission)) {
$access = TRUE;
break;
}
......
......@@ -544,7 +544,7 @@ public static function validateCssLibrary($library) {
return 2;
}
$categories[] = $category;
foreach ($files as $source => $options) {
foreach ($files as $options) {
if (!is_array($options)) {
return 1;
}
......
......@@ -398,7 +398,7 @@ final protected static function openConnection($key, $target) {
throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
}
if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
if (!self::$databaseInfo[$key][$target]['driver']) {
throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
}
......
......@@ -769,7 +769,7 @@ protected function setDefaultLangcode() {
* Updates language for already instantiated fields.
*/
protected function updateFieldLangcodes($langcode) {
foreach ($this->fields as $name => $items) {
foreach ($this->fields as $items) {
if (!empty($items[LanguageInterface::LANGCODE_DEFAULT])) {
$items[LanguageInterface::LANGCODE_DEFAULT]->setLangcode($langcode);
}
......
......@@ -106,7 +106,7 @@ public function getByField($field_name) {
public function getByFields(array $field_names) {
$this->groupViolationOffsets();
$violations = [];
foreach (array_intersect_key($this->violationOffsetsByField, array_flip($field_names)) as $field_name => $offsets) {
foreach (array_intersect_key($this->violationOffsetsByField, array_flip($field_names)) as $offsets) {
foreach ($offsets as $offset) {
$violations[] = $this->get($offset);
}
......
......@@ -276,7 +276,7 @@ public function calculateDependencies() {
if (\Drupal::moduleHandler()->moduleExists('field')) {
$components = $this->content + $this->hidden;
$field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->targetEntityType, $this->bundle);
foreach (array_intersect_key($field_definitions, $components) as $field_name => $field_definition) {
foreach (array_intersect_key($field_definitions, $components) as $field_definition) {
if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
$this->addDependency('config', $field_definition->getConfigDependencyName());
}
......
......@@ -229,7 +229,7 @@ protected function getFromStaticCache(array $ids) {
*/
protected function setStaticCache(array $entities) {
if ($this->entityType->isStaticallyCacheable()) {
foreach ($entities as $id => $entity) {
foreach ($entities as $entity) {
$this->memoryCache->set($this->buildCacheId($entity->id()), $entity, MemoryCacheInterface::CACHE_PERMANENT, [$this->memoryCacheTag]);
}
}
......
......@@ -279,7 +279,7 @@ protected function filterByProfileDirectories(array $all_files) {
return TRUE;
}
foreach ($this->profileDirectories as $weight => $profile_path) {
foreach ($this->profileDirectories as $profile_path) {
if (strpos($file->getPath(), $profile_path) === 0) {
// Parent profile found.
return TRUE;
......
......@@ -312,7 +312,7 @@ protected function doList() {
$extensions = $this->doScanExtensions();
// Read info files for each extension.
foreach ($extensions as $extension_name => $extension) {
foreach ($extensions as $extension) {
$extension->info = $this->createExtensionInfo($extension);
// Invoke hook_system_info_alter() to give installed modules a chance to
......
......@@ -88,7 +88,7 @@ public function __construct($root, $type, CacheBackendInterface $cache, InfoPars
protected function getExtensionDiscovery() {
$discovery = parent::getExtensionDiscovery();
if ($active_profile = $this->getActiveProfile()) {
if ($this->getActiveProfile()) {
$discovery->setProfileDirectories($this->getProfileDirectories($discovery));
}
......
......@@ -561,7 +561,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
// Any cache entry might implicitly depend on the uninstalled modules,
// so clear all of them explicitly.
$this->moduleHandler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
foreach (Cache::getBins() as $cache_backend) {
$cache_backend->deleteAll();
}
......
......@@ -142,7 +142,7 @@ protected function doList() {
// sub-themes.
$this->fillInSubThemeData($themes, $sub_themes);
foreach ($themes as $key => $theme) {
foreach ($themes as $theme) {
// After $theme is processed by buildModuleDependencies(), there can be a
// `$theme->requires` array containing both module and base theme
// dependencies. The module dependencies are copied to their own property
......
......@@ -345,7 +345,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin
* Either the bundle string, or NULL if there is no bundle.
*/
protected static function getRandomBundle(EntityTypeInterface $entity_type, array $selection_settings) {
if ($bundle_key = $entity_type->getKey('bundle')) {
if ($entity_type->getKey('bundle')) {
if (!empty($selection_settings['target_bundles'])) {
$bundle_ids = $selection_settings['target_bundles'];
}
......
......@@ -135,7 +135,7 @@ public function isAllowed($name, $threshold, $window = 3600, $identifier = NULL)
*/
public function garbageCollection() {
try {
$return = $this->connection->delete(static::TABLE_NAME)
$this->connection->delete(static::TABLE_NAME)
->condition('expiration', REQUEST_TIME, '<')
->execute();
}
......
......@@ -18,7 +18,7 @@ class FormErrorHandler implements FormErrorHandlerInterface {
*/
public function handleFormErrors(array &$form, FormStateInterface $form_state) {
// After validation check if there are errors.
if ($errors = $form_state->getErrors()) {
if ($form_state->getErrors()) {
// Display error messages for each element.
$this->displayErrorMessages($form, $form_state);
......@@ -110,6 +110,7 @@ protected function setElementErrorsFromFormState(array &$form, FormStateInterfac
// modify the original form. When processing grouped elements a reference to
// the complete form is needed.
if (empty($elements)) {
// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.VariableRedeclaration
$elements = &$form;
}
......
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