From 30a88a2240d54cda29621d38d2d9485b416ea5b5 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 28 Apr 2026 19:24:07 +0200 Subject: [PATCH] chore: adjust NCU to have proper `final` keyword and `Override` attribute where needed Signed-off-by: Ferdinand Thiessen --- lib/unstable/Config/Exceptions/IncorrectTypeException.php | 2 +- lib/unstable/Config/Exceptions/TypeConflictException.php | 2 +- lib/unstable/Config/Exceptions/UnknownKeyException.php | 2 +- lib/unstable/Config/Lexicon/ConfigLexiconEntry.php | 4 ++-- .../Signature/Exceptions/IdentityNotFoundException.php | 2 +- .../Signature/Exceptions/IncomingRequestException.php | 2 +- .../Signature/Exceptions/InvalidKeyOriginException.php | 2 +- .../Signature/Exceptions/InvalidSignatureException.php | 2 +- .../Signature/Exceptions/SignatoryConflictException.php | 2 +- .../Signature/Exceptions/SignatoryNotFoundException.php | 2 +- .../Exceptions/SignatureElementNotFoundException.php | 2 +- .../Signature/Exceptions/SignatureNotFoundException.php | 2 +- lib/unstable/Security/Signature/Model/Signatory.php | 5 +++-- 13 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/unstable/Config/Exceptions/IncorrectTypeException.php b/lib/unstable/Config/Exceptions/IncorrectTypeException.php index 6b91959071a..32f05c55a3f 100644 --- a/lib/unstable/Config/Exceptions/IncorrectTypeException.php +++ b/lib/unstable/Config/Exceptions/IncorrectTypeException.php @@ -15,5 +15,5 @@ use Exception; * @deprecated 32.0.0 use \OCP\Config\Exceptions\IncorrectTypeException * @see \OCP\Config\Exceptions\IncorrectTypeException */ -class IncorrectTypeException extends Exception { +final class IncorrectTypeException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/TypeConflictException.php b/lib/unstable/Config/Exceptions/TypeConflictException.php index 808679ed873..6f6c1fd7e70 100644 --- a/lib/unstable/Config/Exceptions/TypeConflictException.php +++ b/lib/unstable/Config/Exceptions/TypeConflictException.php @@ -15,5 +15,5 @@ use Exception; * @deprecated 32.0.0 use \OCP\Config\Exceptions\TypeConflictException * @see \OCP\Config\Exceptions\TypeConflictException */ -class TypeConflictException extends Exception { +final class TypeConflictException extends Exception { } diff --git a/lib/unstable/Config/Exceptions/UnknownKeyException.php b/lib/unstable/Config/Exceptions/UnknownKeyException.php index 744ce25e48d..b49d0368ae4 100644 --- a/lib/unstable/Config/Exceptions/UnknownKeyException.php +++ b/lib/unstable/Config/Exceptions/UnknownKeyException.php @@ -15,5 +15,5 @@ use Exception; * @deprecated 32.0.0 use \OCP\Config\Exceptions\UnknownKeyException * @see \OCP\Config\Exceptions\UnknownKeyException */ -class UnknownKeyException extends Exception { +final class UnknownKeyException extends Exception { } diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php index 2587cd52c01..b37fda0cc56 100644 --- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php +++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php @@ -20,7 +20,7 @@ use NCU\Config\ValueType; * @see \OCP\Config\Lexicon\Entry * @psalm-suppress DeprecatedClass */ -class ConfigLexiconEntry { +final class ConfigLexiconEntry { /** * @experimental 32.0.0 * @deprecated 32.0.0 use \OCP\Config\Lexicon\Entry @@ -145,7 +145,7 @@ class ConfigLexiconEntry { * @see \OCP\Config\Lexicon\Entry */ private function convertFromArray(array $default): string { - return json_encode($default); + return json_encode($default, JSON_THROW_ON_ERROR); } /** diff --git a/lib/unstable/Security/Signature/Exceptions/IdentityNotFoundException.php b/lib/unstable/Security/Signature/Exceptions/IdentityNotFoundException.php index 4b37acd292b..af9247d4225 100644 --- a/lib/unstable/Security/Signature/Exceptions/IdentityNotFoundException.php +++ b/lib/unstable/Security/Signature/Exceptions/IdentityNotFoundException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\IdentityNotFoundException} * @psalm-suppress DeprecatedClass */ -class IdentityNotFoundException extends SignatureException { +final class IdentityNotFoundException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Exceptions/IncomingRequestException.php b/lib/unstable/Security/Signature/Exceptions/IncomingRequestException.php index 16e9209f743..5549c41c1e5 100644 --- a/lib/unstable/Security/Signature/Exceptions/IncomingRequestException.php +++ b/lib/unstable/Security/Signature/Exceptions/IncomingRequestException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\IncomingRequestException} * @psalm-suppress DeprecatedClass */ -class IncomingRequestException extends SignatureException { +final class IncomingRequestException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Exceptions/InvalidKeyOriginException.php b/lib/unstable/Security/Signature/Exceptions/InvalidKeyOriginException.php index d7235ee1683..9967fb3f11e 100644 --- a/lib/unstable/Security/Signature/Exceptions/InvalidKeyOriginException.php +++ b/lib/unstable/Security/Signature/Exceptions/InvalidKeyOriginException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\InvalidKeyOriginException} * @psalm-suppress DeprecatedClass */ -class InvalidKeyOriginException extends SignatureException { +final class InvalidKeyOriginException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Exceptions/InvalidSignatureException.php b/lib/unstable/Security/Signature/Exceptions/InvalidSignatureException.php index 37430c74f2e..3301973224b 100644 --- a/lib/unstable/Security/Signature/Exceptions/InvalidSignatureException.php +++ b/lib/unstable/Security/Signature/Exceptions/InvalidSignatureException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\InvalidSignatureException} * @psalm-suppress DeprecatedClass */ -class InvalidSignatureException extends SignatureException { +final class InvalidSignatureException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Exceptions/SignatoryConflictException.php b/lib/unstable/Security/Signature/Exceptions/SignatoryConflictException.php index dc53fe94726..0accb584923 100644 --- a/lib/unstable/Security/Signature/Exceptions/SignatoryConflictException.php +++ b/lib/unstable/Security/Signature/Exceptions/SignatoryConflictException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\SignatoryConflictException} * @psalm-suppress DeprecatedClass */ -class SignatoryConflictException extends SignatoryException { +final class SignatoryConflictException extends SignatoryException { } diff --git a/lib/unstable/Security/Signature/Exceptions/SignatoryNotFoundException.php b/lib/unstable/Security/Signature/Exceptions/SignatoryNotFoundException.php index 0b141d862c2..a9b72d3cc2f 100644 --- a/lib/unstable/Security/Signature/Exceptions/SignatoryNotFoundException.php +++ b/lib/unstable/Security/Signature/Exceptions/SignatoryNotFoundException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\SignatoryNotFoundException} * @psalm-suppress DeprecatedClass */ -class SignatoryNotFoundException extends SignatoryException { +final class SignatoryNotFoundException extends SignatoryException { } diff --git a/lib/unstable/Security/Signature/Exceptions/SignatureElementNotFoundException.php b/lib/unstable/Security/Signature/Exceptions/SignatureElementNotFoundException.php index 8930bc0b776..dbf23feb4e9 100644 --- a/lib/unstable/Security/Signature/Exceptions/SignatureElementNotFoundException.php +++ b/lib/unstable/Security/Signature/Exceptions/SignatureElementNotFoundException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\SignatureElementNotFoundException} * @psalm-suppress DeprecatedClass */ -class SignatureElementNotFoundException extends SignatureException { +final class SignatureElementNotFoundException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Exceptions/SignatureNotFoundException.php b/lib/unstable/Security/Signature/Exceptions/SignatureNotFoundException.php index 13c820ddf53..761b04ae228 100644 --- a/lib/unstable/Security/Signature/Exceptions/SignatureNotFoundException.php +++ b/lib/unstable/Security/Signature/Exceptions/SignatureNotFoundException.php @@ -13,5 +13,5 @@ namespace NCU\Security\Signature\Exceptions; * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Exceptions\SignatureNotFoundException} * @psalm-suppress DeprecatedClass */ -class SignatureNotFoundException extends SignatureException { +final class SignatureNotFoundException extends SignatureException { } diff --git a/lib/unstable/Security/Signature/Model/Signatory.php b/lib/unstable/Security/Signature/Model/Signatory.php index f3ae93840ad..de0aeebc9db 100644 --- a/lib/unstable/Security/Signature/Model/Signatory.php +++ b/lib/unstable/Security/Signature/Model/Signatory.php @@ -49,7 +49,7 @@ use OCP\AppFramework\Db\Entity; * @method int getLastUpdated() * @psalm-suppress PropertyNotSetInConstructor */ -class Signatory extends Entity implements JsonSerializable { +final class Signatory extends Entity implements JsonSerializable { protected string $keyId = ''; protected string $keyIdSum = ''; protected string $providerId = ''; @@ -103,7 +103,7 @@ class Signatory extends Entity implements JsonSerializable { // removing /index.php from generated url $path = parse_url($keyId, PHP_URL_PATH); - if (str_starts_with($path, '/index.php/')) { + if ($path !== null && $path !== false && str_starts_with($path, '/index.php/')) { $pos = strpos($keyId, '/index.php'); if ($pos !== false) { $keyId = substr_replace($keyId, '', $pos, 10); @@ -182,6 +182,7 @@ class Signatory extends Entity implements JsonSerializable { * @experimental 31.0.0 * @deprecated 33.0.0 use {@see \OCP\Security\Signature\Model\Signatory} */ + #[\Override] public function jsonSerialize(): array { return [ 'keyId' => $this->getKeyId(),