diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
index b93f8d7b6760ccaf337798034de6d63ca96297b4..6310a62eb06fc52cad087d9fcad346fc73fb9141 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
@@ -296,7 +296,7 @@ class MetaDataStorageHandler implements ClearableState
      * This function looks up the metadata for the given entity id in the given set. It will throw an
      * exception if it is unable to locate the metadata.
      *
-     * @param string|null $index The entity id we are looking up. This parameter may be NULL, in which case we look up
+     * @param string|null $entityId The entity id we are looking up. This parameter may be NULL, in which case we look up
      * the current entity id based on the current hostname/path.
      * @param string $set The set of metadata we are looking up the entity id in.
      *
@@ -304,33 +304,33 @@ class MetaDataStorageHandler implements ClearableState
      * @throws \Exception If metadata for the specified entity is expired.
      * @throws \SimpleSAML\Error\MetadataNotFound If no metadata for the entity specified can be found.
      */
-    public function getMetaData(?string $index, string $set): array
+    public function getMetaData(?string $entityId, string $set): array
     {
-        if ($index === null) {
-            $index = $this->getMetaDataCurrentEntityID($set, 'metaindex');
+        if ($entityId === null) {
+            $entityId = $this->getMetaDataCurrentEntityID($set, 'metaindex');
         }
 
         foreach ($this->sources as $source) {
-            $metadata = $source->getMetaData($index, $set);
+            $metadata = $source->getMetaData($entityId, $set);
 
             if ($metadata !== null) {
                 if (array_key_exists('expire', $metadata)) {
                     if ($metadata['expire'] < time()) {
                         throw new \Exception(
-                            'Metadata for the entity [' . $index . '] expired ' .
+                            'Metadata for the entity [' . $entityId . '] expired ' .
                             (time() - $metadata['expire']) . ' seconds ago.'
                         );
                     }
                 }
 
-                $metadata['metadata-index'] = $index;
+                $metadata['metadata-index'] = $entityId;
                 $metadata['metadata-set'] = $set;
                 Assert::keyExists($metadata, 'entityid');
                 return $metadata;
             }
         }
 
-        throw new Error\MetadataNotFound($index);
+        throw new Error\MetadataNotFound($entityId);
     }
 
 
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
index a48191f7e68b6c50c9a36d7e72004a52cc85bd53..7edbdcbd1906d01aadc9c2451a6a8bed823fedbb 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
@@ -176,7 +176,7 @@ abstract class MetaDataStorageSource
 
         foreach ($metadataSet as $index => $entry) {
             $cidrHints = [];
-            
+
             // support hint.cidr for idp discovery
             if (array_key_exists('hint.cidr', $entry) && is_array($entry['hint.cidr'])) {
                 $cidrHints = $entry['hint.cidr'];
@@ -220,17 +220,17 @@ abstract class MetaDataStorageSource
      * override this function if it doesn't implement the getMetadataSet function, or if the
      * implementation of getMetadataSet is slow.
      *
-     * @param string $index The entityId or metaindex we are looking up.
+     * @param string $entityId The entityId or metaindex we are looking up.
      * @param string $set The set we are looking for metadata in.
      *
      * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to
      *         locate the entity.
      */
-    public function getMetaData(string $index, string $set): ?array
+    public function getMetaData(string $entityId, string $set): ?array
     {
         $metadataSet = $this->getMetadataSet($set);
 
-        $indexLookup = $this->lookupIndexFromEntityId($index, $metadataSet);
+        $indexLookup = $this->lookupIndexFromEntityId($entityId, $metadataSet);
         if (isset($indexLookup) && array_key_exists($indexLookup, $metadataSet)) {
             return $metadataSet[$indexLookup];
         }
diff --git a/lib/SimpleSAML/Metadata/Sources/MDQ.php b/lib/SimpleSAML/Metadata/Sources/MDQ.php
index 8714d70c51bd47486f3f3456224ae103282e3e6b..98430d5e0a93aacb03d8c0250d113f0393111d83 100644
--- a/lib/SimpleSAML/Metadata/Sources/MDQ.php
+++ b/lib/SimpleSAML/Metadata/Sources/MDQ.php
@@ -235,7 +235,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
      * override this function if it doesn't implement the getMetadataSet function, or if the
      * implementation of getMetadataSet is slow.
      *
-     * @param string $index The entityId or metaindex we are looking up.
+     * @param string $entityId The entityId or metaindex we are looking up.
      * @param string $set The set we are looking for metadata in.
      *
      * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to
@@ -243,13 +243,13 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
      * @throws \Exception If an error occurs while validating the signature or the metadata is in an
      *         incorrect set.
      */
-    public function getMetaData(string $index, string $set): ?array
+    public function getMetaData(string $entityId, string $set): ?array
     {
-        Logger::info(__CLASS__ . ': loading metadata entity [' . $index . '] from [' . $set . ']');
+        Logger::info(__CLASS__ . ': loading metadata entity [' . $entityId . '] from [' . $set . ']');
 
         // read from cache if possible
         try {
-            $data = $this->getFromCache($set, $index);
+            $data = $this->getFromCache($set, $entityId);
         } catch (\Exception $e) {
             Logger::error($e->getMessage());
             // proceed with fetching metadata even if the cache is broken
@@ -263,14 +263,14 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
 
         if (isset($data)) {
             // metadata found in cache and not expired
-            Logger::debug(__CLASS__ . ': using cached metadata for: ' . $index . '.');
+            Logger::debug(__CLASS__ . ': using cached metadata for: ' . $entityId . '.');
             return $data;
         }
 
         // look at Metadata Query Protocol: https://github.com/iay/md-query/blob/master/draft-young-md-query.txt
-        $mdq_url = $this->server . '/entities/' . urlencode($index);
+        $mdq_url = $this->server . '/entities/' . urlencode($entityId);
 
-        Logger::debug(__CLASS__ . ': downloading metadata for "' . $index . '" from [' . $mdq_url . ']');
+        Logger::debug(__CLASS__ . ': downloading metadata for "' . $entityId . '" from [' . $mdq_url . ']');
         try {
             $xmldata = Utils\HTTP::fetch($mdq_url);
         } catch (\Exception $e) {
@@ -280,7 +280,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
 
         if (empty($xmldata)) {
             $error = error_get_last();
-            Logger::info('Unable to fetch metadata for "' . $index . '" from ' . $mdq_url . ': ' .
+            Logger::info('Unable to fetch metadata for "' . $entityId . '" from ' . $mdq_url . ': ' .
                 (is_array($error) ? $error['message'] : 'no error available'));
             return null;
         }
@@ -291,11 +291,11 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource
 
         $data = self::getParsedSet($entity, $set);
         if ($data === null) {
-            throw new \Exception(__CLASS__ . ': no metadata for set "' . $set . '" available from "' . $index . '".');
+            throw new \Exception(__CLASS__ . ': no metadata for set "' . $set . '" available from "' . $entityId . '".');
         }
 
         try {
-            $this->writeToCache($set, $index, $data);
+            $this->writeToCache($set, $entityId, $data);
         } catch (\Exception $e) {
             // Proceed without writing to cache
             Logger::error('Error writing MDQ result to cache: ' . $e->getMessage());