Skip to content

Commit 2b950c2

Browse files
rcnsheppardptvdijen
authored andcommitted
Fix various errors and warnings detected in VS Code (simplesamlphp#2468)
- Undeclared variable (incorrect name) - Move some deprecated static functions to instances - Namespacing on various PHPdoc tags - Various PHPdoc tags NULL to lowercase - Fix a PHP 8.2 deprecation re string interpolation
1 parent 3e92bcf commit 2b950c2

12 files changed

Lines changed: 28 additions & 34 deletions

File tree

bin/memcacheSync.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
require_once($baseDir . '/src/_autoload.php');
2727

2828
// Initialize the configuration
29-
$configdir = SimpleSAML\Utils\Config::getConfigDir();
29+
$configUtils = new SimpleSAML\Utils\Config();
30+
$configdir = $configUtils->getConfigDir();
3031
\SimpleSAML\Configuration::setConfigDir($configdir);
3132

3233
// Things we should warn the user about

modules/saml/src/Controller/ServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function login(Request $request, string $sourceId): RedirectResponse
119119
* @param Utils\HTTP $httpUtils
120120
*
121121
* @return string
122-
* @throws BadRequest
122+
* @throws \SimpleSAML\Error\BadRequest
123123
* @throws Error\Exception
124124
*/
125125
protected function loginHandler(

modules/saml/src/IdP/SAML2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ public static function receiveLogoutMessage(Request $request, IdP $idp): Respons
746746
*
747747
* @param \SimpleSAML\IdP $idp The IdP we are sending a logout request from.
748748
* @param array $association The association that should be terminated.
749-
* @param string|NULL $relayState An id that should be carried across the logout.
749+
* @param string|null $relayState An id that should be carried across the logout.
750750
*
751751
* @return string The logout URL.
752752
*/

src/SimpleSAML/Command/SspCacheClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function configure(): void
5959
}
6060

6161
/**
62-
* @throws ExceptionInterface
62+
* @throws \Symfony\Component\Console\Exception\ExceptionInterface
6363
*/
6464
protected function execute(InputInterface $input, OutputInterface $output): int
6565
{

src/SimpleSAML/Metadata/MetaDataStorageHandlerDirectory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,10 @@ private function load(string $set): ?array
131131
}
132132
}
133133

134-
135-
136-
137134
if (!is_array($metadata)) {
138-
throw new Exception('Could not load metadata set [' . $set . '] from file: ' . $metadatasetfile);
135+
throw new Exception('Could not load metadata set [' . $set . '] from file: ' . $metadatasetdir);
139136
}
137+
140138
return $metadata;
141139
}
142140

src/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function load(string $set): ?array
104104
while ($d = $stmt->fetch()) {
105105
$data = json_decode($d['entity_data'], true);
106106
if ($data === null) {
107-
throw new Error\Exception("Cannot decode metadata for entity '${d['entity_id']}'");
107+
throw new Error\Exception("Cannot decode metadata for entity '{$d['entity_id']}'");
108108
}
109109
if (!array_key_exists('entityid', $data)) {
110110
$data['entityid'] = $d['entity_id'];
@@ -188,7 +188,7 @@ public function getMetaData(string $entityId, string $set): ?array
188188
$data = json_decode($d['entity_data'], true);
189189
if (json_last_error() != JSON_ERROR_NONE) {
190190
throw new Error\Exception(
191-
"Cannot decode metadata for entity '${d['entity_id']}'",
191+
"Cannot decode metadata for entity '{$d['entity_id']}'",
192192
);
193193
}
194194

src/SimpleSAML/Metadata/SAMLParser.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public static function parseDescriptorsString(string $string): array
340340
* This function parses a DOMElement which represents either an EntityDescriptor element or an
341341
* EntitiesDescriptor element. It will return an associative array of SAMLParser instances in both cases.
342342
*
343-
* @param \DOMElement|NULL $element The DOMElement which contains the EntityDescriptor element or the
343+
* @param \DOMElement|null $element The DOMElement which contains the EntityDescriptor element or the
344344
* EntitiesDescriptor element.
345345
*
346346
* @return SAMLParser[] An associative array of SAMLParser instances. The key of the array will
@@ -366,9 +366,8 @@ public static function parseDescriptorsElement(?DOMElement $element = null): arr
366366

367367
/**
368368
*
369-
* @param \SAML2\XML\md\EntityDescriptor|\SAML2\XML\md\EntitiesDescriptor $element
370-
* The element we should process.
371-
* @param int|NULL $maxExpireTime The maximum expiration time of the entities.
369+
* @param \SAML2\XML\md\EntityDescriptor|\SAML2\XML\md\EntitiesDescriptor $element The element we should process.
370+
* @param int|null $maxExpireTime The maximum expiration time of the entities.
372371
* @param array $validators The parent-elements that may be signed.
373372
* @param array $parentExtensions An optional array of extensions from the parent element.
374373
*
@@ -749,9 +748,8 @@ private static function parseRoleDescriptorType(RoleDescriptor $element, ?int $e
749748
* - 'nameIDFormats': The NameIDFormats supported by this SSODescriptor. This may be an empty array.
750749
* - 'keys': Array of associative arrays with the elements from parseKeyDescriptor:
751750
*
752-
* @param \SimpleSAML\SAML2\XML\md\SSODescriptorType $element The element we should extract metadata from.
753-
* @param int|null $expireTime The unix timestamp for when this element should expire, or
754-
* NULL if unknown.
751+
* @param \SAML2\XML\md\SSODescriptorType $element The element we should extract metadata from.
752+
* @param int|null $expireTime The unix timestamp for when this element should expire, or NULL if unknown.
755753
*
756754
* @return array An associative array with metadata we have extracted from this element.
757755
*/
@@ -778,9 +776,8 @@ private static function parseSSODescriptor(SSODescriptorType $element, ?int $exp
778776
/**
779777
* This function extracts metadata from a SPSSODescriptor element.
780778
*
781-
* @param \SimpleSAML\SAML2\XML\md\SPSSODescriptor $element The element which should be parsed.
782-
* @param int|null $expireTime The unix timestamp for when this element should expire, or
783-
* NULL if unknown.
779+
* @param \SAML2\XML\md\SPSSODescriptor $element The element which should be parsed.
780+
* @param int|null $expireTime The unix timestamp for when this element should expire, or NULL if unknown.
784781
*/
785782
private function processSPSSODescriptor(SPSSODescriptor $element, ?int $expireTime): void
786783
{
@@ -812,9 +809,8 @@ private function processSPSSODescriptor(SPSSODescriptor $element, ?int $expireTi
812809
/**
813810
* This function extracts metadata from a IDPSSODescriptor element.
814811
*
815-
* @param \SimpleSAML\SAML2\XML\md\IDPSSODescriptor $element The element which should be parsed.
816-
* @param int|null $expireTime The unix timestamp for when this element should expire, or
817-
* NULL if unknown.
812+
* @param \SAML2\XML\md\IDPSSODescriptor $element The element which should be parsed.
813+
* @param int|null $expireTime The unix timestamp for when this element should expire, or NULL if unknown.
818814
*/
819815
private function processIDPSSODescriptor(IDPSSODescriptor $element, ?int $expireTime): void
820816
{
@@ -836,9 +832,8 @@ private function processIDPSSODescriptor(IDPSSODescriptor $element, ?int $expire
836832
/**
837833
* This function extracts metadata from a AttributeAuthorityDescriptor element.
838834
*
839-
* @param \SimpleSAML\SAML2\XML\md\AttributeAuthorityDescriptor $element The element which should be parsed.
840-
* @param int|null $expireTime The unix timestamp for when this element should
841-
* expire, or NULL if unknown.
835+
* @param \SAML2\XML\md\AttributeAuthorityDescriptor $element The element which should be parsed.
836+
* @param int|null $expireTime The unix timestamp for when this element should expire, or NULL if unknown.
842837
*/
843838
private function processAttributeAuthorityDescriptor(
844839
AttributeAuthorityDescriptor $element,

src/SimpleSAML/Module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public static function resolveClass(string $id, string $type, ?string $subclass
477477
* @param string The classname.
478478
* @param string|null $subclass The class should be a subclass of this class. Optional.
479479
*
480-
* @return object the new object
480+
* @return object The new object
481481
*/
482482
public static function createObject(string $className, ?string $subclass = null): object
483483
{

src/SimpleSAML/Utils/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Auth
1717
/**
1818
* Retrieve an admin logout URL.
1919
*
20-
* @param string|NULL $returnTo The URL the user should arrive on after admin authentication. Defaults to null.
20+
* @param string|null $returnTo The URL the user should arrive on after admin authentication. Defaults to null.
2121
*
2222
* @return string A URL which can be used for logging out.
2323
* @throws \InvalidArgumentException If $returnTo is neither a string nor null.

src/SimpleSAML/Utils/Config/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Metadata
6060
* @param array $endpoints An array with endpoints.
6161
* @param array|null $bindings An array with acceptable bindings. Can be null if any binding is allowed.
6262
*
63-
* @return array|NULL The default endpoint, or null if no acceptable endpoints are used.
63+
* @return array|null The default endpoint, or null if no acceptable endpoints are used.
6464
*
6565
*/
6666
public static function getDefaultEndpoint(array $endpoints, ?array $bindings = null): ?array

0 commit comments

Comments
 (0)