Issue #3106216 by Spokje, longwave, alexpott, apaderno, Hardik_Patel_12, daffie: Remove unused variables from core
parent
a0b2090aac
commit
2f1c716625
|
@ -516,7 +516,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 @@ class OptimizedPhpArrayDumper extends Dumper {
|
|||
$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 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
|||
}
|
||||
|
||||
// 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 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
|||
}
|
||||
|
||||
// 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 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
|||
}
|
||||
// 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 @@ EOS;
|
|||
// 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 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
|
|||
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 @@ abstract class AccessResult implements AccessResultInterface, RefinableCacheable
|
|||
}
|
||||
else {
|
||||
foreach ($permissions as $permission) {
|
||||
if ($permission_access = $account->hasPermission($permission)) {
|
||||
if ($account->hasPermission($permission)) {
|
||||
$access = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -544,7 +544,7 @@ class LibraryDiscoveryParser {
|
|||
return 2;
|
||||
}
|
||||
$categories[] = $category;
|
||||
foreach ($files as $source => $options) {
|
||||
foreach ($files as $options) {
|
||||
if (!is_array($options)) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -398,7 +398,7 @@ abstract class Database {
|
|||
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 @@ abstract class ContentEntityBase extends EntityBase implements \IteratorAggregat
|
|||
* 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 @@ class EntityConstraintViolationList extends ConstraintViolationList implements E
|
|||
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 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
|
|||
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 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
|
|||
*/
|
||||
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 @@ class ExtensionDiscovery {
|
|||
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 @@ abstract class ExtensionList {
|
|||
$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 @@ class ModuleExtensionList extends ExtensionList {
|
|||
protected function getExtensionDiscovery() {
|
||||
$discovery = parent::getExtensionDiscovery();
|
||||
|
||||
if ($active_profile = $this->getActiveProfile()) {
|
||||
if ($this->getActiveProfile()) {
|
||||
$discovery->setProfileDirectories($this->getProfileDirectories($discovery));
|
||||
}
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ class ModuleInstaller implements ModuleInstallerInterface {
|
|||
// 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 @@ class ThemeExtensionList extends ExtensionList {
|
|||
// 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 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
* 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 @@ class DatabaseBackend implements FloodInterface {
|
|||
*/
|
||||
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 @@ class FormErrorHandler implements FormErrorHandlerInterface {
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class MenuParentFormSelector implements MenuParentFormSelectorInterface {
|
|||
if (!isset($options[$menu_parent])) {
|
||||
// The requested menu parent cannot be found in the menu anymore. Try
|
||||
// setting it to the top level in the current menu.
|
||||
[$menu_name, $parent] = explode(':', $menu_parent, 2);
|
||||
[$menu_name] = explode(':', $menu_parent, 2);
|
||||
$menu_parent = $menu_name . ':';
|
||||
}
|
||||
if (isset($options[$menu_parent])) {
|
||||
|
|
|
@ -320,7 +320,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
|
|||
public function __toString() {
|
||||
$return = '';
|
||||
/** @var \Drupal\Core\Template\AttributeValueBase $value */
|
||||
foreach ($this->storage as $name => $value) {
|
||||
foreach ($this->storage as $value) {
|
||||
$rendered = $value->render();
|
||||
if ($rendered) {
|
||||
$return .= ' ' . $rendered;
|
||||
|
|
|
@ -29,7 +29,7 @@ class TestHttpClientMiddleware {
|
|||
$request = $request->withHeader('User-Agent', drupal_generate_test_ua($test_prefix));
|
||||
}
|
||||
return $handler($request, $options)
|
||||
->then(function (ResponseInterface $response) use ($request) {
|
||||
->then(function (ResponseInterface $response) {
|
||||
if (!drupal_valid_test_ua()) {
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface {
|
|||
// entity, since we should determine whether the entity matches the
|
||||
// constraints and not whether the entity validates.
|
||||
if (($data instanceof ListInterface || $data instanceof ComplexDataInterface) && !$data->isEmpty() && !($data instanceof EntityAdapter && $constraints_given)) {
|
||||
foreach ($data as $name => $property) {
|
||||
foreach ($data as $property) {
|
||||
$this->validateNode($property);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1118,6 +1118,7 @@ realword
|
|||
rebuilder
|
||||
reclosed
|
||||
recolorable
|
||||
redeclaration
|
||||
redirections
|
||||
redstrawberryhiddenfield
|
||||
refactorings
|
||||
|
|
|
@ -76,7 +76,7 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI
|
|||
[$module, $delta] = $value;
|
||||
switch ($module) {
|
||||
case 'aggregator':
|
||||
[$type, $id] = explode('-', $delta);
|
||||
[$type] = explode('-', $delta);
|
||||
if ($type == 'feed') {
|
||||
return 'aggregator_feed_block';
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class SourceEditingRedundantTagsConstraintValidator extends ConstraintValidator
|
|||
private function pluginsSupplyingTagsMessage(array $tags, array $plugin_definitions): string {
|
||||
$message_array = [];
|
||||
$message_string = '';
|
||||
foreach ($plugin_definitions as $plugin_id => $definition) {
|
||||
foreach ($plugin_definitions as $definition) {
|
||||
if ($definition->hasElements()) {
|
||||
$elements_array = HTMLRestrictionsUtilities::allowedElementsStringToHtmlFilterArray(implode('', $definition->getElements()));
|
||||
foreach ($elements_array as $tag_name => $tag_config) {
|
||||
|
|
|
@ -712,7 +712,7 @@ function comment_entity_view_display_presave(EntityViewDisplayInterface $display
|
|||
}
|
||||
|
||||
// Disable the comment field formatter when the used view display is disabled.
|
||||
foreach ($storage->loadMultiple() as $id => $view_display) {
|
||||
foreach ($storage->loadMultiple() as $view_display) {
|
||||
$changed = FALSE;
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
|
||||
foreach ($view_display->getComponents() as $field => $component) {
|
||||
|
|
|
@ -193,7 +193,7 @@ class Comment extends ContentEntityBase implements CommentInterface {
|
|||
$comments = $comment_storage->loadMultiple($child_cids);
|
||||
$comment_storage->delete($comments);
|
||||
|
||||
foreach ($entities as $id => $entity) {
|
||||
foreach ($entities as $entity) {
|
||||
\Drupal::service('comment.statistics')->update($entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Permissions {
|
|||
public function transitionPermissions() {
|
||||
$permissions = [];
|
||||
/** @var \Drupal\workflows\WorkflowInterface $workflow */
|
||||
foreach (Workflow::loadMultipleByType('content_moderation') as $id => $workflow) {
|
||||
foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
|
||||
foreach ($workflow->getTypePlugin()->getTransitions() as $transition) {
|
||||
$permissions['use ' . $workflow->id() . ' transition ' . $transition->id()] = [
|
||||
'title' => $this->t('%workflow workflow: Use %transition transition.', [
|
||||
|
|
|
@ -55,7 +55,7 @@ class ViewsData {
|
|||
return $this->moderationInformation->isModeratedEntityType($type);
|
||||
});
|
||||
|
||||
foreach ($entity_types_with_moderation as $entity_type_id => $entity_type) {
|
||||
foreach ($entity_types_with_moderation as $entity_type) {
|
||||
$table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
|
||||
|
||||
$data[$table]['moderation_state'] = [
|
||||
|
|
|
@ -369,7 +369,7 @@ function editor_entity_insert(EntityInterface $entity) {
|
|||
return;
|
||||
}
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
foreach ($referenced_files_by_field as $uuids) {
|
||||
_editor_record_file_usage($uuids, $entity);
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ function editor_entity_update(EntityInterface $entity) {
|
|||
// deletion of previous file usages are necessary.
|
||||
if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) {
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
foreach ($referenced_files_by_field as $uuids) {
|
||||
_editor_record_file_usage($uuids, $entity);
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ function editor_entity_delete(EntityInterface $entity) {
|
|||
return;
|
||||
}
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
foreach ($referenced_files_by_field as $uuids) {
|
||||
_editor_delete_file_usage($uuids, $entity, 0);
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ function editor_entity_revision_delete(EntityInterface $entity) {
|
|||
return;
|
||||
}
|
||||
$referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
|
||||
foreach ($referenced_files_by_field as $field => $uuids) {
|
||||
foreach ($referenced_files_by_field as $uuids) {
|
||||
_editor_delete_file_usage($uuids, $entity, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) {
|
|||
|
||||
$fields = $deleted_fields_repository->getFieldDefinitions($field_storage_unique_id);
|
||||
|
||||
$info = \Drupal::entityTypeManager()->getDefinitions();
|
||||
foreach ($fields as $field) {
|
||||
$entity_type = $field->getTargetEntityTypeId();
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class FieldUiTable extends Table {
|
|||
$region_name = call_user_func_array($row['#region_callback'], [&$row]);
|
||||
|
||||
// Add the element in the tree.
|
||||
// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
|
||||
$target = &$trees[$region_name][''];
|
||||
foreach ($parents[$name] as $key) {
|
||||
$target = &$target['children'][$key];
|
||||
|
|
|
@ -31,7 +31,7 @@ class FileAccessControlHandler extends EntityAccessControlHandler {
|
|||
}
|
||||
elseif ($references = $this->getFileReferences($entity)) {
|
||||
foreach ($references as $field_name => $entity_map) {
|
||||
foreach ($entity_map as $referencing_entity_type => $referencing_entities) {
|
||||
foreach ($entity_map as $referencing_entities) {
|
||||
/** @var \Drupal\Core\Entity\EntityInterface $referencing_entity */
|
||||
foreach ($referencing_entities as $referencing_entity) {
|
||||
$entity_and_field_access = $referencing_entity->access('view', $account, TRUE)->andIf($referencing_entity->$field_name->access('view', $account, TRUE));
|
||||
|
|
|
@ -24,7 +24,7 @@ class RSSEnclosureFormatter extends FileFormatterBase {
|
|||
$entity = $items->getEntity();
|
||||
// Add the first file as an enclosure to the RSS item. RSS allows only one
|
||||
// enclosure per item. See: http://wikipedia.org/wiki/RSS_enclosure
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $file) {
|
||||
/** @var \Drupal\file\FileInterface $file */
|
||||
$entity->rss_elements[] = [
|
||||
'key' => 'enclosure',
|
||||
|
|
|
@ -26,7 +26,7 @@ class TableFormatter extends DescriptionAwareFileFormatterBase {
|
|||
if ($files = $this->getEntitiesToView($items, $langcode)) {
|
||||
$header = [t('Attachment'), t('Size')];
|
||||
$rows = [];
|
||||
foreach ($files as $delta => $file) {
|
||||
foreach ($files as $file) {
|
||||
$item = $file->_referringItem;
|
||||
$rows[] = [
|
||||
[
|
||||
|
|
|
@ -285,7 +285,7 @@ class FilterHtml extends FilterBase {
|
|||
// allowed attribute values with a wildcard. A wildcard by itself
|
||||
// would mean allowing all possible attribute values. But in that
|
||||
// case, one would not specify an attribute value at all.
|
||||
$allowed_attribute_values = array_filter($allowed_attribute_values, function ($value) use ($star_protector) {
|
||||
$allowed_attribute_values = array_filter($allowed_attribute_values, function ($value) {
|
||||
return $value !== '*';
|
||||
});
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ class ResourceIdentifierNormalizer extends NormalizerBase implements Denormalize
|
|||
}
|
||||
/** @var \Drupal\field\Entity\FieldConfig $field_definition */
|
||||
$field_definition = $field_definitions[$context['related']];
|
||||
// This is typically 'target_id'.
|
||||
$item_definition = $field_definition->getItemDefinition();
|
||||
$property_key = $item_definition->getMainPropertyName();
|
||||
$target_resource_types = $resource_type->getRelatableResourceTypesByField($resource_type->getPublicName($context['related']));
|
||||
$target_resource_type_names = array_map(function (ResourceType $resource_type) {
|
||||
return $resource_type->getTypeName();
|
||||
|
@ -87,7 +84,7 @@ class ResourceIdentifierNormalizer extends NormalizerBase implements Denormalize
|
|||
|
||||
$is_multiple = $field_definition->getFieldStorageDefinition()->isMultiple();
|
||||
$data = $this->massageRelationshipInput($data, $is_multiple);
|
||||
$resource_identifiers = array_map(function ($value) use ($property_key, $target_resource_type_names) {
|
||||
$resource_identifiers = array_map(function ($value) use ($target_resource_type_names) {
|
||||
// Make sure that the provided type is compatible with the targeted
|
||||
// resource.
|
||||
if (!in_array($value['type'], $target_resource_type_names)) {
|
||||
|
|
|
@ -360,9 +360,9 @@ class LayoutBuilderEntityViewDisplay extends BaseEntityViewDisplay implements La
|
|||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
|
||||
foreach ($this->getSections() as $delta => $section) {
|
||||
foreach ($this->getSections() as $section) {
|
||||
$this->calculatePluginDependencies($section->getLayout());
|
||||
foreach ($section->getComponents() as $uuid => $component) {
|
||||
foreach ($section->getComponents() as $component) {
|
||||
$this->calculatePluginDependencies($component->getPlugin());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class LayoutBuilderEntityViewDisplayStorage extends ConfigEntityStorage {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function mapFromStorageRecords(array $records) {
|
||||
foreach ($records as $id => &$record) {
|
||||
foreach ($records as &$record) {
|
||||
if (!empty($record['third_party_settings']['layout_builder']['sections'])) {
|
||||
$sections = &$record['third_party_settings']['layout_builder']['sections'];
|
||||
$sections = array_map([Section::class, 'fromArray'], $sections);
|
||||
|
|
|
@ -73,7 +73,7 @@ class LayoutSectionItemList extends FieldItemList implements SectionListInterfac
|
|||
parent::preSave();
|
||||
// Loop through each section and reconstruct it to ensure that all default
|
||||
// values are present.
|
||||
foreach ($this->list as $delta => $item) {
|
||||
foreach ($this->list as $item) {
|
||||
$item->section = Section::fromArray($item->section->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ class TranslationStatusForm extends FormBase {
|
|||
$this->moduleHandler->loadInclude('locale', 'compare.inc');
|
||||
$project_data = locale_translation_build_projects();
|
||||
|
||||
foreach ($status as $project_id => $project) {
|
||||
foreach ($status as $project) {
|
||||
foreach ($project as $langcode => $project_info) {
|
||||
// No translation file found for this project-language combination.
|
||||
if (empty($project_info->type)) {
|
||||
|
|
|
@ -171,7 +171,7 @@ class OEmbedIframeController implements ContainerInjectionInterface {
|
|||
'#placeholder_token' => $placeholder_token,
|
||||
];
|
||||
$context = new RenderContext();
|
||||
$content = $this->renderer->executeInRenderContext($context, function () use ($resource, $element) {
|
||||
$content = $this->renderer->executeInRenderContext($context, function () use ($element) {
|
||||
return $this->renderer->render($element);
|
||||
});
|
||||
$response
|
||||
|
|
|
@ -130,7 +130,7 @@ class UrlResolver implements UrlResolverInterface {
|
|||
public function getProviderByUrl($url) {
|
||||
// Check the URL against every scheme of every endpoint of every provider
|
||||
// until we find a match.
|
||||
foreach ($this->providers->getAll() as $provider_name => $provider_info) {
|
||||
foreach ($this->providers->getAll() as $provider_info) {
|
||||
foreach ($provider_info->getEndpoints() as $endpoint) {
|
||||
if ($endpoint->matchUrl($url)) {
|
||||
return $provider_info;
|
||||
|
|
|
@ -82,7 +82,7 @@ class ArrayBuild extends ProcessPluginBase {
|
|||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$new_value = [];
|
||||
|
||||
foreach ((array) $value as $old_key => $old_value) {
|
||||
foreach ((array) $value as $old_value) {
|
||||
// Checks that $old_value is an array.
|
||||
if (!is_array($old_value)) {
|
||||
throw new MigrateException("The input should be an array of arrays");
|
||||
|
|
|
@ -266,9 +266,6 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
|
|||
if ($this->batch == 0) {
|
||||
$this->prepareQuery();
|
||||
|
||||
// Get the key values, for potential use in joining to the map table.
|
||||
$keys = [];
|
||||
|
||||
// The rules for determining what conditions to add to the query are as
|
||||
// follows (applying first applicable rule):
|
||||
// 1. If the map is joinable, join it. We will want to accept all rows
|
||||
|
|
|
@ -382,7 +382,7 @@ class MigrationState {
|
|||
$state_by_source = [];
|
||||
$dest_by_source = [];
|
||||
$states = [static::FINISHED, static::NOT_FINISHED];
|
||||
foreach ($migration_states as $module => $info) {
|
||||
foreach ($migration_states as $info) {
|
||||
foreach ($states as $state) {
|
||||
if (isset($info[$state][$version])) {
|
||||
foreach ($info[$state][$version] as $source => $destination) {
|
||||
|
|
|
@ -141,7 +141,7 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
|
|||
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
|
||||
}
|
||||
|
||||
[$revision_permission_operation, $entity_operation] = static::REVISION_OPERATION_MAP[$operation] ?? [
|
||||
[$revision_permission_operation] = static::REVISION_OPERATION_MAP[$operation] ?? [
|
||||
NULL,
|
||||
NULL,
|
||||
];
|
||||
|
|
|
@ -358,9 +358,7 @@ function rdf_preprocess_node(&$variables) {
|
|||
$fields = array_keys(\Drupal::service('comment.manager')->getFields('node'));
|
||||
$definitions = array_keys($variables['node']->getFieldDefinitions());
|
||||
$valid_fields = array_intersect($fields, $definitions);
|
||||
$count = 0;
|
||||
foreach ($valid_fields as $field_name) {
|
||||
$count += $variables['node']->get($field_name)->comment_count;
|
||||
// Adds RDFa markup for the comment count near the node title as
|
||||
// metadata.
|
||||
$comment_count_attributes = rdf_rdfa_attributes($comment_count_mapping, $variables['node']->get($field_name)->comment_count);
|
||||
|
|
|
@ -25,7 +25,7 @@ trait EntityResourceAccessTrait {
|
|||
// Only check 'edit' permissions for fields that were actually submitted by
|
||||
// the user. Field access makes no difference between 'create' and 'update',
|
||||
// so the 'edit' operation is used here.
|
||||
foreach ($entity->_restSubmittedFields as $key => $field_name) {
|
||||
foreach ($entity->_restSubmittedFields as $field_name) {
|
||||
if (!$entity->get($field_name)->access('edit')) {
|
||||
throw new AccessDeniedHttpException("Access denied on creating field '$field_name'.");
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ function system_post_update_entity_revision_metadata_bc_cleanup() {
|
|||
});
|
||||
|
||||
// Remove the '$requiredRevisionMetadataKeys' property for these entity types.
|
||||
foreach ($last_installed_definitions as $entity_type_id => $entity_type) {
|
||||
foreach ($last_installed_definitions as $entity_type) {
|
||||
$closure = function (ContentEntityTypeInterface $entity_type) {
|
||||
return get_object_vars($entity_type);
|
||||
};
|
||||
|
|
|
@ -161,6 +161,7 @@ class OverviewTerms extends FormBase {
|
|||
$term_deltas = [];
|
||||
$tree = $this->storageController->loadTree($taxonomy_vocabulary->id(), 0, NULL, TRUE);
|
||||
$tree_index = 0;
|
||||
$complete_tree = NULL;
|
||||
do {
|
||||
// In case this tree is completely empty.
|
||||
if (empty($tree[$tree_index])) {
|
||||
|
|
|
@ -89,7 +89,7 @@ class TermSelection extends DefaultSelection {
|
|||
|
||||
$total = 0;
|
||||
$referenceable_entities = $this->getReferenceableEntities($match, $match_operator, 0);
|
||||
foreach ($referenceable_entities as $bundle => $entities) {
|
||||
foreach ($referenceable_entities as $entities) {
|
||||
$total += count($entities);
|
||||
}
|
||||
return $total;
|
||||
|
|
|
@ -28,7 +28,7 @@ class EntityReferenceTaxonomyTermRssFormatter extends EntityReferenceFormatterBa
|
|||
$parent_entity = $items->getEntity();
|
||||
$elements = [];
|
||||
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $entity) {
|
||||
$parent_entity->rss_elements[] = [
|
||||
'key' => 'category',
|
||||
'value' => $entity->label(),
|
||||
|
|
|
@ -21,7 +21,7 @@ class ToolbarController extends ControllerBase implements TrustedCallbackInterfa
|
|||
* @return \Drupal\Core\Ajax\AjaxResponse
|
||||
*/
|
||||
public function subtreesAjax() {
|
||||
[$subtrees, $cacheability] = toolbar_get_rendered_subtrees();
|
||||
[$subtrees] = toolbar_get_rendered_subtrees();
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new SetSubtreesCommand($subtrees));
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class ProfileFieldOptionTranslation extends ProcessPluginBase {
|
|||
$list = array_map('trim', $list);
|
||||
$list = array_filter($list, 'strlen');
|
||||
if ($field_type === 'list_string') {
|
||||
foreach ($list as $key => $value) {
|
||||
foreach ($list as $value) {
|
||||
$allowed_values[] = ['label' => $value];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ class RegisterForm extends AccountForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$user = $this->currentUser();
|
||||
/** @var \Drupal\user\UserInterface $account */
|
||||
$account = $this->entity;
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ class ViewsEntitySchemaSubscriber implements EntityTypeListenerInterface, EventS
|
|||
|
||||
$all_views = $this->entityTypeManager->getStorage('view')->loadMultiple(NULL);
|
||||
/** @var \Drupal\views\Entity\View $view */
|
||||
foreach ($all_views as $id => $view) {
|
||||
foreach ($all_views as $view) {
|
||||
|
||||
// First check just the base table.
|
||||
if (in_array($view->get('base_table'), $tables)) {
|
||||
|
|
|
@ -243,7 +243,7 @@ abstract class CachePluginBase extends PluginBase {
|
|||
|
||||
if (!empty($entity_information)) {
|
||||
// Add the list cache tags for each entity type used by this view.
|
||||
foreach ($entity_information as $table => $metadata) {
|
||||
foreach ($entity_information as $metadata) {
|
||||
$tags = Cache::mergeTags($tags, \Drupal::entityTypeManager()->getDefinition($metadata['entity_type'])->getListCacheTags());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2520,7 +2520,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
|
|||
// Check for missing relationships.
|
||||
$relationships = array_keys($this->getHandlers('relationship'));
|
||||
foreach (ViewExecutable::getHandlerTypes() as $type => $handler_type_info) {
|
||||
foreach ($this->getHandlers($type) as $handler_id => $handler) {
|
||||
foreach ($this->getHandlers($type) as $handler) {
|
||||
if (!empty($handler->options['relationship']) && $handler->options['relationship'] != 'none' && !in_array($handler->options['relationship'], $relationships)) {
|
||||
$errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()]);
|
||||
}
|
||||
|
|
|
@ -338,13 +338,10 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
|
|||
|
||||
// Replace % with %views_arg for menu autoloading and add to the
|
||||
// page arguments so the argument actually comes through.
|
||||
foreach ($bits as $pos => $bit) {
|
||||
if ($bit == '%') {
|
||||
// If a view requires any arguments we cannot create a static menu link.
|
||||
return [];
|
||||
}
|
||||
if (in_array('%', $bits, TRUE)) {
|
||||
// If a view requires any arguments we cannot create a static menu link.
|
||||
return [];
|
||||
}
|
||||
|
||||
$path = implode('/', $bits);
|
||||
$view_id = $this->view->storage->id();
|
||||
$display_id = $this->display['id'];
|
||||
|
|
|
@ -158,7 +158,7 @@ abstract class ExposedFormPluginBase extends PluginBase implements CacheableDepe
|
|||
// Make sure the original order of sorts is preserved
|
||||
// (e.g. a sticky sort is often first)
|
||||
$view->query->orderby = [];
|
||||
foreach ($view->sort as $key => $sort) {
|
||||
foreach ($view->sort as $sort) {
|
||||
if (!$sort->isExposed()) {
|
||||
$sort->query();
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
|
|||
public function calculateDependencies() {
|
||||
$dependencies = [];
|
||||
|
||||
foreach ($this->getEntityTableInfo() as $entity_type => $info) {
|
||||
foreach ($this->getEntityTableInfo() as $info) {
|
||||
if (!empty($info['provider'])) {
|
||||
$dependencies['module'][] = $info['provider'];
|
||||
}
|
||||
|
|
|
@ -1357,7 +1357,7 @@ class Sql extends QueryPluginBase {
|
|||
];
|
||||
}
|
||||
|
||||
foreach ($entity_information as $entity_type_id => $info) {
|
||||
foreach ($entity_information as $info) {
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($info['entity_type']);
|
||||
$base_field = !$info['revision'] ? $entity_type->getKey('id') : $entity_type->getKey('revision');
|
||||
$this->addField($info['alias'], $base_field, '', $params);
|
||||
|
|
|
@ -433,7 +433,7 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
|
|||
public function getCacheContexts() {
|
||||
$contexts = [];
|
||||
|
||||
foreach ($this->options['info'] as $field_id => $info) {
|
||||
foreach ($this->options['info'] as $info) {
|
||||
if (!empty($info['sortable'])) {
|
||||
// The rendered link needs to play well with any other query parameter
|
||||
// used on the page, like pager and exposed filter.
|
||||
|
|
|
@ -121,7 +121,7 @@ class ViewsUIController extends ControllerBase {
|
|||
foreach ($rows as &$row) {
|
||||
$views = [];
|
||||
// Link each view name to the view itself.
|
||||
foreach ($row['views'] as $row_name => $view) {
|
||||
foreach ($row['views'] as $view) {
|
||||
$views[] = Link::fromTextAndUrl($view, new Url('entity.view.edit_form', ['view' => $view]))->toString();
|
||||
}
|
||||
unset($row['views']);
|
||||
|
|
|
@ -83,7 +83,7 @@ class EntityTypeInfo implements ContainerInjectionInterface {
|
|||
* @see hook_entity_type_alter()
|
||||
*/
|
||||
public function entityTypeAlter(array &$entity_types) {
|
||||
foreach ($entity_types as $entity_type_id => $entity_type) {
|
||||
foreach ($entity_types as $entity_type) {
|
||||
// Non-default workspaces display the active revision on the canonical
|
||||
// route of an entity, so the latest version route is no longer needed.
|
||||
$link_templates = $entity_type->get('links');
|
||||
|
|
|
@ -34,7 +34,7 @@ class WorkspacesServiceProvider extends ServiceProviderBase {
|
|||
// Ensure that there's no active workspace while running database updates by
|
||||
// removing the relevant tag from all workspace negotiator services.
|
||||
if ($container->get('kernel') instanceof UpdateKernel) {
|
||||
foreach ($container->getDefinitions() as $id => $definition) {
|
||||
foreach ($container->getDefinitions() as $definition) {
|
||||
if ($definition->hasTag('workspace_negotiator')) {
|
||||
$definition->clearTag('workspace_negotiator');
|
||||
}
|
||||
|
|
|
@ -145,6 +145,24 @@
|
|||
<rule ref="DrupalPractice.Commenting.ExpectedException"/>
|
||||
<rule ref="DrupalPractice.General.ExceptionT"/>
|
||||
<rule ref="DrupalPractice.InfoFiles.NamespacedDependency"/>
|
||||
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis">
|
||||
<!-- @todo exclude tests -->
|
||||
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||
<!-- Do not run this sniff on API files or transliteration data. -->
|
||||
<exclude-pattern>*.api.php</exclude-pattern>
|
||||
<exclude-pattern>core/lib/Drupal/Component/Transliteration/data/*.php</exclude-pattern>
|
||||
<properties>
|
||||
<property name="allowUnusedFunctionParameters" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable">
|
||||
<!-- Setting severity to 0 to completely disable an error message in this sniff, without excluding the whole sniff -->
|
||||
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#changing-the-default-severity-levels -->
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<!-- Generic sniffs -->
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
||||
|
|
|
@ -19,7 +19,7 @@ if (PHP_SAPI !== 'cli') {
|
|||
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||
$request = Request::createFromGlobals();
|
||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
|
||||
// Run the database dump command.
|
||||
$application = new DbToolsApplication();
|
||||
|
|
|
@ -19,7 +19,7 @@ if (PHP_SAPI !== 'cli') {
|
|||
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||
$request = Request::createFromGlobals();
|
||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
|
||||
// Run the database dump command.
|
||||
$application = new DbDumpApplication();
|
||||
|
|
|
@ -20,7 +20,7 @@ if (PHP_SAPI !== 'cli') {
|
|||
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||
$request = Request::createFromGlobals();
|
||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||
|
||||
// Run the database dump command.
|
||||
$application = new GenerateProxyClassApplication(new ProxyBuilder());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* Lists available colors and color schemes for the Bartik theme.
|
||||
*/
|
||||
|
||||
// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
|
||||
$info = [
|
||||
// Available colors and color labels used in theme.
|
||||
'fields' => [
|
||||
|
|
Loading…
Reference in New Issue