Skip to content

Commit f48838c

Browse files
happydudetvdijen
andauthored
PHP 8.4 deprecation fixes (simplesamlphp#2414)
* PHP 8.4 implicit nullable deprecation fix * PHP 8.4 - avoid "Constant E_STRICT is deprecated" message * Fix deprecations --------- Co-authored-by: Tim van Dijen <tvdijen@gmail.com>
1 parent 0c8bf02 commit f48838c

35 files changed

Lines changed: 72 additions & 72 deletions

modules/admin/src/Controller/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function setAuthState(Auth\State $authState): void
9999
* @param string|null $as
100100
* @return \Symfony\Component\HttpFoundation\Response
101101
*/
102-
public function main(Request $request, string $as = null): Response
102+
public function main(Request $request, ?string $as = null): Response
103103
{
104104
$response = $this->authUtils->requireAdmin();
105105
if ($response instanceof Response) {

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

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

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

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

modules/core/src/Storage/SQLPermanentStorage.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SQLPermanentStorage
4141
* @param \SimpleSAML\Configuration|null $config
4242
* @throws \Exception
4343
*/
44-
public function __construct(string $name, Configuration $config = null)
44+
public function __construct(string $name, ?Configuration $config = null)
4545
{
4646
if (is_null($config)) {
4747
$config = Configuration::getInstance();
@@ -93,7 +93,7 @@ public function __construct(string $name, Configuration $config = null)
9393
* @param string $value
9494
* @param int|null $duration
9595
*/
96-
public function set(string $type, string $key1, string $key2, string $value, int $duration = null): void
96+
public function set(string $type, string $key1, string $key2, string $value, ?int $duration = null): void
9797
{
9898
if ($this->exists($type, $key1, $key2)) {
9999
$this->update($type, $key1, $key2, $value, $duration);
@@ -111,7 +111,7 @@ public function set(string $type, string $key1, string $key2, string $value, int
111111
* @param int|null $duration
112112
* @return array
113113
*/
114-
private function insert(string $type, string $key1, string $key2, string $value, int $duration = null): array
114+
private function insert(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
115115
{
116116
$expire = is_null($duration) ? null : (time() + $duration);
117117

@@ -137,7 +137,7 @@ private function insert(string $type, string $key1, string $key2, string $value,
137137
* @param int|null $duration
138138
* @return array
139139
*/
140-
private function update(string $type, string $key1, string $key2, string $value, int $duration = null): array
140+
private function update(string $type, string $key1, string $key2, string $value, ?int $duration = null): array
141141
{
142142
$expire = is_null($duration) ? null : (time() + $duration);
143143

@@ -160,7 +160,7 @@ private function update(string $type, string $key1, string $key2, string $value,
160160
* @param string|null $key2
161161
* @return array|null
162162
*/
163-
public function get(string $type = null, string $key1 = null, string $key2 = null): ?array
163+
public function get(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?array
164164
{
165165
$conditions = $this->getCondition($type, $key1, $key2);
166166
$query = 'SELECT * FROM data WHERE ' . $conditions;
@@ -185,7 +185,7 @@ public function get(string $type = null, string $key1 = null, string $key2 = nul
185185
* @param string|null $key2
186186
* @return string|null
187187
*/
188-
public function getValue(string $type = null, string $key1 = null, string $key2 = null): ?string
188+
public function getValue(?string $type = null, ?string $key1 = null, ?string $key2 = null): ?string
189189
{
190190
$res = $this->get($type, $key1, $key2);
191191
if ($res === null) {
@@ -218,7 +218,7 @@ public function exists(string $type, string $key1, string $key2): bool
218218
* @param string|null $key2
219219
* @return array|false
220220
*/
221-
public function getList(string $type = null, string $key1 = null, string $key2 = null)
221+
public function getList(?string $type = null, ?string $key1 = null, ?string $key2 = null)
222222
{
223223
$conditions = $this->getCondition($type, $key1, $key2);
224224
$query = 'SELECT * FROM data WHERE ' . $conditions;
@@ -246,9 +246,9 @@ public function getList(string $type = null, string $key1 = null, string $key2 =
246246
* @return array|null
247247
*/
248248
public function getKeys(
249-
string $type = null,
250-
string $key1 = null,
251-
string $key2 = null,
249+
?string $type = null,
250+
?string $key1 = null,
251+
?string $key2 = null,
252252
string $whichKey = 'type',
253253
): ?array {
254254
if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) {
@@ -311,7 +311,7 @@ public function removeExpired(): int
311311
* @param string|null $key2
312312
* @return string
313313
*/
314-
private function getCondition(string $type = null, string $key1 = null, string $key2 = null): string
314+
private function getCondition(?string $type = null, ?string $key1 = null, ?string $key2 = null): string
315315
{
316316
$conditions = [];
317317
if (!is_null($type)) {

modules/cron/src/Cron.php

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

modules/debugsp/src/Controller/Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function setAuthState(Auth\State $authState): void
7878
* @param string|null $as
7979
* @return \SimpleSAML\XHTML\Template|\SimpleSAML\HTTP\RunnableResponse
8080
*/
81-
private function makeSPList(Request $request, string $as = null): Response
81+
private function makeSPList(Request $request, ?string $as = null): Response
8282
{
8383
$t = new Template($this->config, 'debugsp:authsource_list.twig');
8484
$samlSpSources = Auth\Source::getSourcesOfType('saml:SP');
@@ -101,7 +101,7 @@ private function makeSPList(Request $request, string $as = null): Response
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
if (is_null($as)) {
107107
$t = $this->makeSPList($request, $as);

modules/saml/src/Error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
private string $status,
3333
private ?string $subStatus = null,
3434
private ?string $statusMessage = null,
35-
Throwable $cause = null,
35+
?Throwable $cause = null,
3636
) {
3737
$st = self::shortStatus($status);
3838
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, C::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, C::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, C::STATUS_NO_PASSIVE, $message, $cause);
2929
}

0 commit comments

Comments
 (0)