Skip to content

Commit 99cfdb5

Browse files
happydudetvdijen
authored andcommitted
PHP 8.4 Deprecation fixes (#2413)
* PHP 8.4 implicit nullable deprecation fix * PHP 8.4 - avoid "Constant E_STRICT is deprecated" message * Remove stray space * Fix deprecations --------- Co-authored-by: Tim van Dijen <tvdijen@gmail.com>
1 parent 926852c commit 99cfdb5

34 files changed

+78
-73
lines changed

modules/admin/src/Controller/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function setAuthState(Auth\State $authState): void
101101
* @param string|null $as
102102
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
103103
*/
104-
public function main(Request $request, string $as = null): Response
104+
public function main(Request $request, ?string $as = null): Response
105105
{
106106
$this->authUtils->requireAdmin();
107107
if (is_null($as)) {

modules/core/src/Auth/Process/Cardinality.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class Cardinality extends Auth\ProcessingFilter
3333
*
3434
* @param array &$config Configuration information about this filter.
3535
* @param mixed $reserved For future use.
36-
* @param \SimpleSAML\Utils\HTTP $httpUtils HTTP utility service (handles redirects).
36+
* @param \SimpleSAML\Utils\HTTP|null $httpUtils HTTP utility service (handles redirects).
3737
* @throws \SimpleSAML\Error\Exception
3838
*/
39-
public function __construct(array &$config, $reserved, Utils\HTTP $httpUtils = null)
39+
public function __construct(array &$config, $reserved, ?Utils\HTTP $httpUtils = null)
4040
{
4141
parent::__construct($config, $reserved);
4242

modules/core/src/Auth/Process/CardinalitySingle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class CardinalitySingle extends Auth\ProcessingFilter
4444
*
4545
* @param array &$config Configuration information about this filter.
4646
* @param mixed $reserved For future use.
47-
* @param \SimpleSAML\Utils\HTTP $httpUtils HTTP utility service (handles redirects).
47+
* @param \SimpleSAML\Utils\HTTP|null $httpUtils HTTP utility service (handles redirects).
4848
*/
49-
public function __construct(array &$config, $reserved, Utils\HTTP $httpUtils = null)
49+
public function __construct(array &$config, $reserved, ?Utils\HTTP $httpUtils = null)
5050
{
5151
parent::__construct($config, $reserved);
5252

modules/core/src/Storage/SQLPermanentStorage.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SQLPermanentStorage
2929
* @param \SimpleSAML\Configuration|null $config
3030
* @throws \Exception
3131
*/
32-
public function __construct(string $name, Configuration $config = null)
32+
public function __construct(string $name, ?Configuration $config = null)
3333
{
3434
if (is_null($config)) {
3535
$config = Configuration::getInstance();
@@ -81,7 +81,7 @@ public function __construct(string $name, Configuration $config = null)
8181
* @param string $value
8282
* @param int|null $duration
8383
*/
84-
public function set(string $type, string $key1, string $key2, string $value, int $duration = null): void
84+
public function set(string $type, string $key1, string $key2, string $value, ?int $duration = null): void
8585
{
8686
if ($this->exists($type, $key1, $key2)) {
8787
$this->update($type, $key1, $key2, $value, $duration);
@@ -99,7 +99,7 @@ public function set(string $type, string $key1, string $key2, string $value, int
9999
* @param int|null $duration
100100
* @return array
101101
*/
102-
private function insert(string $type, string $key1, string $key2, string $value, int $duration = null): array
102+
private function insert(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
103103
{
104104
$expire = is_null($duration) ? null : (time() + $duration);
105105

@@ -125,7 +125,7 @@ private function insert(string $type, string $key1, string $key2, string $value,
125125
* @param int|null $duration
126126
* @return array
127127
*/
128-
private function update(string $type, string $key1, string $key2, string $value, int $duration = null): array
128+
private function update(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
129129
{
130130
$expire = is_null($duration) ? null : (time() + $duration);
131131

@@ -148,7 +148,7 @@ private function update(string $type, string $key1, string $key2, string $value,
148148
* @param string|null $key2
149149
* @return array|null
150150
*/
151-
public function get(string $type = null, string $key1 = null, string $key2 = null): ?array
151+
public function get(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?array
152152
{
153153
$conditions = $this->getCondition($type, $key1, $key2);
154154
$query = 'SELECT * FROM data WHERE ' . $conditions;
@@ -173,7 +173,7 @@ public function get(string $type = null, string $key1 = null, string $key2 = nul
173173
* @param string|null $key2
174174
* @return string|null
175175
*/
176-
public function getValue(string $type = null, string $key1 = null, string $key2 = null): ?string
176+
public function getValue(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?string
177177
{
178178
$res = $this->get($type, $key1, $key2);
179179
if ($res === null) {
@@ -206,7 +206,7 @@ public function exists(string $type, string $key1, string $key2): bool
206206
* @param string|null $key2
207207
* @return array|false
208208
*/
209-
public function getList(string $type = null, string $key1 = null, string $key2 = null)
209+
public function getList(?string $type = null, ?string $key1 = null, ?string $key2 = null)
210210
{
211211
$conditions = $this->getCondition($type, $key1, $key2);
212212
$query = 'SELECT * FROM data WHERE ' . $conditions;
@@ -234,9 +234,9 @@ public function getList(string $type = null, string $key1 = null, string $key2 =
234234
* @return array|null
235235
*/
236236
public function getKeys(
237-
string $type = null,
238-
string $key1 = null,
239-
string $key2 = null,
237+
?string $type = null,
238+
?string $key1 = null,
239+
?string $key2 = null,
240240
string $whichKey = 'type',
241241
): ?array {
242242
if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) {
@@ -299,7 +299,7 @@ public function removeExpired(): int
299299
* @param string|null $key2
300300
* @return string
301301
*/
302-
private function getCondition(string $type = null, string $key1 = null, string $key2 = null): string
302+
private function getCondition(?string $type = null, ?string $key1 = null, ?string $key2 = null): string
303303
{
304304
$conditions = [];
305305
if (!is_null($type)) {

modules/cron/src/Cron.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Cron
2626
* @param \SimpleSAML\Configuration $cronconfig The cron configuration to use. If not specified defaults
2727
* to `config/module_cron.php`
2828
*/
29-
public function __construct(Configuration $cronconfig = null)
29+
public function __construct(?Configuration $cronconfig = null)
3030
{
3131
if ($cronconfig == null) {
3232
$cronconfig = Configuration::getConfig('module_cron.php');

modules/saml/src/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(
2929
private string $status,
3030
private ?string $subStatus = null,
3131
private ?string $statusMessage = null,
32-
Throwable $cause = null,
32+
?Throwable $cause = null,
3333
) {
3434
$st = self::shortStatus($status);
3535
if ($subStatus !== null) {

modules/saml/src/Error/NoAuthnContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NoAuthnContext extends \SimpleSAML\Module\saml\Error
2323
* @param string|null $message A short message explaining why this error happened.
2424
* @param \Throwable|null $cause An exception that caused this error.
2525
*/
26-
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
26+
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
2727
{
2828
parent::__construct($responsible, Constants::STATUS_NO_AUTHN_CONTEXT, $message, $cause);
2929
}

modules/saml/src/Error/NoAvailableIDP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NoAvailableIDP extends \SimpleSAML\Module\saml\Error
2323
* @param string|null $message A short message explaining why this error happened.
2424
* @param \Throwable|null $cause An exception that caused this error.
2525
*/
26-
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
26+
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
2727
{
2828
parent::__construct($responsible, Constants::STATUS_NO_AVAILABLE_IDP, $message, $cause);
2929
}

modules/saml/src/Error/NoPassive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NoPassive extends \SimpleSAML\Module\saml\Error
2323
* @param string|null $message A short message explaining why this error happened.
2424
* @param \Throwable|null $cause An exception that caused this error.
2525
*/
26-
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
26+
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
2727
{
2828
parent::__construct($responsible, Constants::STATUS_NO_PASSIVE, $message, $cause);
2929
}

modules/saml/src/Error/NoSupportedIDP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NoSupportedIDP extends \SimpleSAML\Module\saml\Error
2323
* @param string|null $message A short message explaining why this error happened.
2424
* @param \Throwable|null $cause An exception that caused this error.
2525
*/
26-
public function __construct(string $responsible, string $message = null, Throwable $cause = null)
26+
public function __construct(string $responsible, ?string $message = null, ?Throwable $cause = null)
2727
{
2828
parent::__construct($responsible, Constants::STATUS_NO_SUPPORTED_IDP, $message, $cause);
2929
}

0 commit comments

Comments
 (0)