From b6d7b0a95099e10881c753ef6c562346b35600e5 Mon Sep 17 00:00:00 2001 From: Bartosz Bankowski Date: Tue, 28 Apr 2026 13:35:25 +0200 Subject: [PATCH 1/2] Add PHP 8.3 typed class constants across the codebase Co-Authored-By: Claude Sonnet 4.6 --- src/Ouzo/Core/Config/ConfigValueSelector.php | 6 +- src/Ouzo/Core/Db/ModelQueryBuilder.php | 2 +- src/Ouzo/Core/Db/OnConflict.php | 4 +- src/Ouzo/Core/Db/Options.php | 2 +- src/Ouzo/Core/DownloadHandler.php | 2 +- .../Core/Exception/ForbiddenException.php | 2 +- src/Ouzo/Core/Exception/InternalException.php | 2 +- src/Ouzo/Core/Exception/NotFoundException.php | 2 +- .../Core/Exception/UnauthorizedException.php | 2 +- .../Core/Exception/ValidationException.php | 2 +- .../ExceptionHandling/ExceptionLogger.php | 6 +- src/Ouzo/Core/Http/HttpMethod.php | 12 +- src/Ouzo/Core/Http/HttpStatus.php | 136 +++++++++--------- src/Ouzo/Core/Http/MediaType.php | 12 +- src/Ouzo/Core/I18n.php | 2 +- src/Ouzo/Core/Logger/Backtrace.php | 2 +- src/Ouzo/Core/Logger/SyslogLogger.php | 2 +- .../Core/Response/ResponseTypeResolve.php | 4 +- src/Ouzo/Core/Restriction/Between.php | 8 +- src/Ouzo/Core/Stats/SessionStats.php | 2 +- .../Core/Tools/Model/Template/ClassStub.php | 2 +- src/Ouzo/Core/Uri/JsUriHelperGenerator.php | 2 +- src/Ouzo/Core/View/PhtmlRenderer.php | 2 +- src/Ouzo/Core/View/TwigRenderer.php | 2 +- src/Ouzo/Goodies/Utilities/Arrays.php | 4 +- src/Ouzo/Goodies/Utilities/Date.php | 4 +- .../Utilities/Iterator/BatchingIterator.php | 2 +- src/Ouzo/Goodies/Utilities/StrSubstitutor.php | 4 +- src/Ouzo/Goodies/Utilities/Strings.php | 6 +- src/Ouzo/Goodies/Utilities/Time/TimeUnit.php | 14 +- src/Ouzo/Inject/Injection/Scope.php | 4 +- .../Migrations/Migration/MigrationCommand.php | 2 +- .../Migrations/Migration/MigrationDumper.php | 4 +- .../Migrations/Migration/MigrationLoader.php | 2 +- 34 files changed, 133 insertions(+), 133 deletions(-) diff --git a/src/Ouzo/Core/Config/ConfigValueSelector.php b/src/Ouzo/Core/Config/ConfigValueSelector.php index 4e7fb02c..a3f532ce 100644 --- a/src/Ouzo/Core/Config/ConfigValueSelector.php +++ b/src/Ouzo/Core/Config/ConfigValueSelector.php @@ -11,9 +11,9 @@ class ConfigValueSelector { - private const CONFIG_START = '${'; - private const CONFIG_END = '}'; - private const VALUE_SEPARATOR = ':'; + private const string CONFIG_START = '${'; + private const string CONFIG_END = '}'; + private const string VALUE_SEPARATOR = ':'; public static function selectConfigValue(string $selector): mixed { diff --git a/src/Ouzo/Core/Db/ModelQueryBuilder.php b/src/Ouzo/Core/Db/ModelQueryBuilder.php index 44531be0..b711c094 100644 --- a/src/Ouzo/Core/Db/ModelQueryBuilder.php +++ b/src/Ouzo/Core/Db/ModelQueryBuilder.php @@ -19,7 +19,7 @@ class ModelQueryBuilder { - const MODEL_QUERY_MARKER_COMMENT = 'orm:model'; + const string MODEL_QUERY_MARKER_COMMENT = 'orm:model'; private Db $db; /** @var ModelJoin[] */ diff --git a/src/Ouzo/Core/Db/OnConflict.php b/src/Ouzo/Core/Db/OnConflict.php index 4b15e519..5e5af002 100644 --- a/src/Ouzo/Core/Db/OnConflict.php +++ b/src/Ouzo/Core/Db/OnConflict.php @@ -7,8 +7,8 @@ class OnConflict { - const DO_NOTHING = 'DO_NOTHING'; - const UPDATE = 'UPDATE'; + const string DO_NOTHING = 'DO_NOTHING'; + const string UPDATE = 'UPDATE'; private ?string $onConflictAction; private array $onConflictColumns; private array $onConflictUpdateValues; diff --git a/src/Ouzo/Core/Db/Options.php b/src/Ouzo/Core/Db/Options.php index 71c64cd0..23872f4f 100644 --- a/src/Ouzo/Core/Db/Options.php +++ b/src/Ouzo/Core/Db/Options.php @@ -7,5 +7,5 @@ class Options { - const EMULATE_PREPARES = 'EMULATE_PREPARES'; + const string EMULATE_PREPARES = 'EMULATE_PREPARES'; } diff --git a/src/Ouzo/Core/DownloadHandler.php b/src/Ouzo/Core/DownloadHandler.php index a2ff4f77..9f92236b 100644 --- a/src/Ouzo/Core/DownloadHandler.php +++ b/src/Ouzo/Core/DownloadHandler.php @@ -10,7 +10,7 @@ class DownloadHandler { - const READ_BUFFER_SIZE = 1024 * 1024 * 20; + const int READ_BUFFER_SIZE = 1024 * 1024 * 20; public function downloadFile(array $fileData): void { diff --git a/src/Ouzo/Core/Exception/ForbiddenException.php b/src/Ouzo/Core/Exception/ForbiddenException.php index 657c39a7..6179daaa 100644 --- a/src/Ouzo/Core/Exception/ForbiddenException.php +++ b/src/Ouzo/Core/Exception/ForbiddenException.php @@ -11,7 +11,7 @@ class ForbiddenException extends OuzoException { - const HTTP_CODE = 403; + const int HTTP_CODE = 403; /** @param Error[]|Error $errors */ public function __construct(array|Error $errors) diff --git a/src/Ouzo/Core/Exception/InternalException.php b/src/Ouzo/Core/Exception/InternalException.php index 10f71634..db0bfe58 100644 --- a/src/Ouzo/Core/Exception/InternalException.php +++ b/src/Ouzo/Core/Exception/InternalException.php @@ -11,7 +11,7 @@ class InternalException extends OuzoException { - const HTTP_CODE = 500; + const int HTTP_CODE = 500; /** * @param Error[]|Error $errors diff --git a/src/Ouzo/Core/Exception/NotFoundException.php b/src/Ouzo/Core/Exception/NotFoundException.php index bda7b999..3ffa7e4f 100644 --- a/src/Ouzo/Core/Exception/NotFoundException.php +++ b/src/Ouzo/Core/Exception/NotFoundException.php @@ -11,7 +11,7 @@ class NotFoundException extends OuzoException { - const HTTP_CODE = 404; + const int HTTP_CODE = 404; /** * @param Error[]|Error $errors diff --git a/src/Ouzo/Core/Exception/UnauthorizedException.php b/src/Ouzo/Core/Exception/UnauthorizedException.php index 3b04840a..87f7ad9a 100644 --- a/src/Ouzo/Core/Exception/UnauthorizedException.php +++ b/src/Ouzo/Core/Exception/UnauthorizedException.php @@ -11,7 +11,7 @@ class UnauthorizedException extends OuzoException { - const HTTP_CODE = 401; + const int HTTP_CODE = 401; /** * @param Error[]|Error $errors diff --git a/src/Ouzo/Core/Exception/ValidationException.php b/src/Ouzo/Core/Exception/ValidationException.php index be2d53c2..612ae132 100644 --- a/src/Ouzo/Core/Exception/ValidationException.php +++ b/src/Ouzo/Core/Exception/ValidationException.php @@ -11,7 +11,7 @@ class ValidationException extends OuzoException { - const HTTP_CODE = 400; + const int HTTP_CODE = 400; /** * @param Error[]|Error $errors diff --git a/src/Ouzo/Core/ExceptionHandling/ExceptionLogger.php b/src/Ouzo/Core/ExceptionHandling/ExceptionLogger.php index dc94a910..62d3a3ec 100644 --- a/src/Ouzo/Core/ExceptionHandling/ExceptionLogger.php +++ b/src/Ouzo/Core/ExceptionHandling/ExceptionLogger.php @@ -17,9 +17,9 @@ class ExceptionLogger { - const PASSWORD_PLACEHOLDER = '***'; - const UNAUTHORIZED = '401'; - const NOT_FOUND = '404'; + const string PASSWORD_PLACEHOLDER = '***'; + const string UNAUTHORIZED = '401'; + const string NOT_FOUND = '404'; private OuzoExceptionData $exceptionData; diff --git a/src/Ouzo/Core/Http/HttpMethod.php b/src/Ouzo/Core/Http/HttpMethod.php index 41519df8..b8bcdf72 100644 --- a/src/Ouzo/Core/Http/HttpMethod.php +++ b/src/Ouzo/Core/Http/HttpMethod.php @@ -8,10 +8,10 @@ final class HttpMethod { - public const DELETE = 'DELETE'; - public const GET = 'GET'; - public const OPTIONS = 'OPTIONS'; - public const PATCH = 'PATCH'; - public const POST = 'POST'; - public const PUT = 'PUT'; + public const string DELETE = 'DELETE'; + public const string GET = 'GET'; + public const string OPTIONS = 'OPTIONS'; + public const string PATCH = 'PATCH'; + public const string POST = 'POST'; + public const string PUT = 'PUT'; } diff --git a/src/Ouzo/Core/Http/HttpStatus.php b/src/Ouzo/Core/Http/HttpStatus.php index 6571f08f..4155f272 100644 --- a/src/Ouzo/Core/Http/HttpStatus.php +++ b/src/Ouzo/Core/Http/HttpStatus.php @@ -12,80 +12,80 @@ final class HttpStatus { // 1xx Informational - const CONTINUE = 100; - const SWITCHING_PROTOCOLS = 101; - const PROCESSING = 102; - const CHECKPOINT = 103; + const int CONTINUE = 100; + const int SWITCHING_PROTOCOLS = 101; + const int PROCESSING = 102; + const int CHECKPOINT = 103; // 2xx Success - const OK = 200; - const CREATED = 201; - const ACCEPTED = 202; - const NON_AUTHORITATIVE_INFORMATION = 203; - const NO_CONTENT = 204; - const RESET_CONTENT = 205; - const PARTIAL_CONTENT = 206; - const MULTI_STATUS = 207; - const ALREADY_REPORTED = 208; - const IM_USED = 226; + const int OK = 200; + const int CREATED = 201; + const int ACCEPTED = 202; + const int NON_AUTHORITATIVE_INFORMATION = 203; + const int NO_CONTENT = 204; + const int RESET_CONTENT = 205; + const int PARTIAL_CONTENT = 206; + const int MULTI_STATUS = 207; + const int ALREADY_REPORTED = 208; + const int IM_USED = 226; // 3xx Redirection - const MULTIPLE_CHOICES = 300; - const MOVED_PERMANENTLY = 301; - const FOUND = 302; - const MOVED_TEMPORARILY = 302; - const SEE_OTHER = 303; - const NOT_MODIFIED = 304; - const USE_PROXY = 305; - const TEMPORARY_REDIRECT = 307; - const PERMANENT_REDIRECT = 308; + const int MULTIPLE_CHOICES = 300; + const int MOVED_PERMANENTLY = 301; + const int FOUND = 302; + const int MOVED_TEMPORARILY = 302; + const int SEE_OTHER = 303; + const int NOT_MODIFIED = 304; + const int USE_PROXY = 305; + const int TEMPORARY_REDIRECT = 307; + const int PERMANENT_REDIRECT = 308; // 4xx Client Error - const BAD_REQUEST = 400; - const UNAUTHORIZED = 401; - const PAYMENT_REQUIRED = 402; - const FORBIDDEN = 403; - const NOT_FOUND = 404; - const METHOD_NOT_ALLOWED = 405; - const NOT_ACCEPTABLE = 406; - const PROXY_AUTHENTICATION_REQUIRED = 407; - const REQUEST_TIMEOUT = 408; - const CONFLICT = 409; - const GONE = 410; - const LENGTH_REQUIRED = 411; - const PRECONDITION_FAILED = 412; - const PAYLOAD_TOO_LARGE = 413; - const REQUEST_ENTITY_TOO_LARGE = 413; - const URI_TOO_LONG = 414; - const REQUEST_URI_TOO_LONG = 414; - const UNSUPPORTED_MEDIA_TYPE = 415; - const REQUESTED_RANGE_NOT_SATISFIABLE = 416; - const EXPECTATION_FAILED = 417; - const I_AM_A_TEAPOT = 418; - const INSUFFICIENT_SPACE_ON_RESOURCE = 419; - const METHOD_FAILURE = 420; - const DESTINATION_LOCKED = 421; - const UNPROCESSABLE_ENTITY = 422; - const LOCKED = 423; - const FAILED_DEPENDENCY = 424; - const TOO_EARLY = 425; - const UPGRADE_REQUIRED = 426; - const PRECONDITION_REQUIRED = 428; - const TOO_MANY_REQUESTS = 429; - const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; - const UNAVAILABLE_FOR_LEGAL_REASONS = 451; + const int BAD_REQUEST = 400; + const int UNAUTHORIZED = 401; + const int PAYMENT_REQUIRED = 402; + const int FORBIDDEN = 403; + const int NOT_FOUND = 404; + const int METHOD_NOT_ALLOWED = 405; + const int NOT_ACCEPTABLE = 406; + const int PROXY_AUTHENTICATION_REQUIRED = 407; + const int REQUEST_TIMEOUT = 408; + const int CONFLICT = 409; + const int GONE = 410; + const int LENGTH_REQUIRED = 411; + const int PRECONDITION_FAILED = 412; + const int PAYLOAD_TOO_LARGE = 413; + const int REQUEST_ENTITY_TOO_LARGE = 413; + const int URI_TOO_LONG = 414; + const int REQUEST_URI_TOO_LONG = 414; + const int UNSUPPORTED_MEDIA_TYPE = 415; + const int REQUESTED_RANGE_NOT_SATISFIABLE = 416; + const int EXPECTATION_FAILED = 417; + const int I_AM_A_TEAPOT = 418; + const int INSUFFICIENT_SPACE_ON_RESOURCE = 419; + const int METHOD_FAILURE = 420; + const int DESTINATION_LOCKED = 421; + const int UNPROCESSABLE_ENTITY = 422; + const int LOCKED = 423; + const int FAILED_DEPENDENCY = 424; + const int TOO_EARLY = 425; + const int UPGRADE_REQUIRED = 426; + const int PRECONDITION_REQUIRED = 428; + const int TOO_MANY_REQUESTS = 429; + const int REQUEST_HEADER_FIELDS_TOO_LARGE = 431; + const int UNAVAILABLE_FOR_LEGAL_REASONS = 451; // 5xx Server Error - const INTERNAL_SERVER_ERROR = 500; - const NOT_IMPLEMENTED = 501; - const BAD_GATEWAY = 502; - const SERVICE_UNAVAILABLE = 503; - const GATEWAY_TIMEOUT = 504; - const HTTP_VERSION_NOT_SUPPORTED = 505; - const VARIANT_ALSO_NEGOTIATES = 506; - const INSUFFICIENT_STORAGE = 507; - const LOOP_DETECTED = 508; - const BANDWIDTH_LIMIT_EXCEEDED = 509; - const NOT_EXTENDED = 510; - const NETWORK_AUTHENTICATION_REQUIRED = 511; + const int INTERNAL_SERVER_ERROR = 500; + const int NOT_IMPLEMENTED = 501; + const int BAD_GATEWAY = 502; + const int SERVICE_UNAVAILABLE = 503; + const int GATEWAY_TIMEOUT = 504; + const int HTTP_VERSION_NOT_SUPPORTED = 505; + const int VARIANT_ALSO_NEGOTIATES = 506; + const int INSUFFICIENT_STORAGE = 507; + const int LOOP_DETECTED = 508; + const int BANDWIDTH_LIMIT_EXCEEDED = 509; + const int NOT_EXTENDED = 510; + const int NETWORK_AUTHENTICATION_REQUIRED = 511; } diff --git a/src/Ouzo/Core/Http/MediaType.php b/src/Ouzo/Core/Http/MediaType.php index a8c8dec2..a111af0f 100644 --- a/src/Ouzo/Core/Http/MediaType.php +++ b/src/Ouzo/Core/Http/MediaType.php @@ -8,15 +8,15 @@ final class MediaType { - public const ALL = '*/*'; + public const string ALL = '*/*'; - public const APPLICATION_JSON = 'application/json'; + public const string APPLICATION_JSON = 'application/json'; - public const APPLICATION_XML = 'application/xml'; + public const string APPLICATION_XML = 'application/xml'; - public const TEXT_HTML = 'text/html'; + public const string TEXT_HTML = 'text/html'; - public const TEXT_JSON = 'text/json'; + public const string TEXT_JSON = 'text/json'; - public const TEXT_XML = 'text/xml'; + public const string TEXT_XML = 'text/xml'; } diff --git a/src/Ouzo/Core/I18n.php b/src/Ouzo/Core/I18n.php index 677f0909..4cd4f5fc 100644 --- a/src/Ouzo/Core/I18n.php +++ b/src/Ouzo/Core/I18n.php @@ -13,7 +13,7 @@ class I18n { - const DEFAULT_LANGUAGE = 'en'; + const string DEFAULT_LANGUAGE = 'en'; private static ?Translator $translator = null; private static ?array $labels = []; diff --git a/src/Ouzo/Core/Logger/Backtrace.php b/src/Ouzo/Core/Logger/Backtrace.php index dbd1bc0f..d3662425 100644 --- a/src/Ouzo/Core/Logger/Backtrace.php +++ b/src/Ouzo/Core/Logger/Backtrace.php @@ -11,7 +11,7 @@ class Backtrace { - private const OUZO_PACKAGE_NAME = 'letsdrink/ouzo'; + private const string OUZO_PACKAGE_NAME = 'letsdrink/ouzo'; public static function getCallingClass(array $namesToIgnore = [self::OUZO_PACKAGE_NAME]): string { diff --git a/src/Ouzo/Core/Logger/SyslogLogger.php b/src/Ouzo/Core/Logger/SyslogLogger.php index 6650b80b..0aa40df2 100644 --- a/src/Ouzo/Core/Logger/SyslogLogger.php +++ b/src/Ouzo/Core/Logger/SyslogLogger.php @@ -13,7 +13,7 @@ class SyslogLogger implements LoggerInterface { - const MAX_MESSAGE_SIZE = 1024; + const int MAX_MESSAGE_SIZE = 1024; private SyslogAdapter $syslogAdapter; private ?array $loggerConfiguration; diff --git a/src/Ouzo/Core/Response/ResponseTypeResolve.php b/src/Ouzo/Core/Response/ResponseTypeResolve.php index 66328b71..cb76c9a9 100644 --- a/src/Ouzo/Core/Response/ResponseTypeResolve.php +++ b/src/Ouzo/Core/Response/ResponseTypeResolve.php @@ -13,8 +13,8 @@ class ResponseTypeResolve { - const APPLICATION_ALL = 'application/*'; - const TEXT_ALL = 'text/*'; + const string APPLICATION_ALL = 'application/*'; + const string TEXT_ALL = 'text/*'; public static function resolve(): string { diff --git a/src/Ouzo/Core/Restriction/Between.php b/src/Ouzo/Core/Restriction/Between.php index 12ee2114..72044015 100644 --- a/src/Ouzo/Core/Restriction/Between.php +++ b/src/Ouzo/Core/Restriction/Between.php @@ -7,8 +7,8 @@ class Between { - const INCLUSIVE = 1; - const EXCLUSIVE = 2; - const LEFT_EXCLUSIVE = 3; - const RIGHT_EXCLUSIVE = 4; + const int INCLUSIVE = 1; + const int EXCLUSIVE = 2; + const int LEFT_EXCLUSIVE = 3; + const int RIGHT_EXCLUSIVE = 4; } diff --git a/src/Ouzo/Core/Stats/SessionStats.php b/src/Ouzo/Core/Stats/SessionStats.php index 1a0a3357..73ef6475 100644 --- a/src/Ouzo/Core/Stats/SessionStats.php +++ b/src/Ouzo/Core/Stats/SessionStats.php @@ -16,7 +16,7 @@ class SessionStats { - public const NUMBER_OF_REQUESTS_TO_KEEP = 10; + public const int NUMBER_OF_REQUESTS_TO_KEEP = 10; private Uri $uri; #[Inject] diff --git a/src/Ouzo/Core/Tools/Model/Template/ClassStub.php b/src/Ouzo/Core/Tools/Model/Template/ClassStub.php index 5e2908af..3c1826f5 100644 --- a/src/Ouzo/Core/Tools/Model/Template/ClassStub.php +++ b/src/Ouzo/Core/Tools/Model/Template/ClassStub.php @@ -13,7 +13,7 @@ class ClassStub { - const FIELDS_COUNT_IN_LINE = 7; + const int FIELDS_COUNT_IN_LINE = 7; private string $stubContent; private array $attributes = []; diff --git a/src/Ouzo/Core/Uri/JsUriHelperGenerator.php b/src/Ouzo/Core/Uri/JsUriHelperGenerator.php index e6a5b209..83f52f84 100644 --- a/src/Ouzo/Core/Uri/JsUriHelperGenerator.php +++ b/src/Ouzo/Core/Uri/JsUriHelperGenerator.php @@ -13,7 +13,7 @@ class JsUriHelperGenerator { - const INDENT = ' '; + const string INDENT = ' '; private string $generatedFunctions = ''; /** @var RouteRule[] */ diff --git a/src/Ouzo/Core/View/PhtmlRenderer.php b/src/Ouzo/Core/View/PhtmlRenderer.php index 73fa0d8c..27eb658d 100644 --- a/src/Ouzo/Core/View/PhtmlRenderer.php +++ b/src/Ouzo/Core/View/PhtmlRenderer.php @@ -13,7 +13,7 @@ class PhtmlRenderer implements ViewRenderer { - const EXTENSION = '.phtml'; + const string EXTENSION = '.phtml'; private string $viewPath; diff --git a/src/Ouzo/Core/View/TwigRenderer.php b/src/Ouzo/Core/View/TwigRenderer.php index 337359f4..2e301504 100644 --- a/src/Ouzo/Core/View/TwigRenderer.php +++ b/src/Ouzo/Core/View/TwigRenderer.php @@ -14,7 +14,7 @@ class TwigRenderer implements ViewRenderer { - const EXTENSION = '.html.twig'; + const string EXTENSION = '.html.twig'; private string $loaderPath; private string $viewPath; diff --git a/src/Ouzo/Goodies/Utilities/Arrays.php b/src/Ouzo/Goodies/Utilities/Arrays.php index 145060b7..de7010dd 100644 --- a/src/Ouzo/Goodies/Utilities/Arrays.php +++ b/src/Ouzo/Goodies/Utilities/Arrays.php @@ -12,8 +12,8 @@ class Arrays { - const TREAT_NULL_AS_VALUE = 1; - const REMOVE_EMPTY_PARENTS = true; + const int TREAT_NULL_AS_VALUE = 1; + const bool REMOVE_EMPTY_PARENTS = true; /** * Returns true if every element in array satisfies the predicate. diff --git a/src/Ouzo/Goodies/Utilities/Date.php b/src/Ouzo/Goodies/Utilities/Date.php index eb04f703..66a3b88d 100644 --- a/src/Ouzo/Goodies/Utilities/Date.php +++ b/src/Ouzo/Goodies/Utilities/Date.php @@ -12,8 +12,8 @@ class Date { - const DEFAULT_TIME_FORMAT = 'Y-m-d H:i'; - const DEFAULT_TIMEZONE = 'UTC'; + const string DEFAULT_TIME_FORMAT = 'Y-m-d H:i'; + const string DEFAULT_TIMEZONE = 'UTC'; public static function formatDate(?string $date, string $format = 'Y-m-d'): ?string { diff --git a/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php index 78f5113d..627d09db 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php @@ -10,7 +10,7 @@ class BatchingIterator implements Iterator { - const OPTION_PRESERVER_KEYS = 0x2; + const int OPTION_PRESERVER_KEYS = 0x2; private Iterator $iterator; private int $chunkSize; diff --git a/src/Ouzo/Goodies/Utilities/StrSubstitutor.php b/src/Ouzo/Goodies/Utilities/StrSubstitutor.php index 9ad4efab..93f310b7 100644 --- a/src/Ouzo/Goodies/Utilities/StrSubstitutor.php +++ b/src/Ouzo/Goodies/Utilities/StrSubstitutor.php @@ -8,8 +8,8 @@ readonly class StrSubstitutor { - private const START = '{{'; - private const END = '}}'; + private const string START = '{{'; + private const string END = '}}'; public function __construct( private array $values = [], diff --git a/src/Ouzo/Goodies/Utilities/Strings.php b/src/Ouzo/Goodies/Utilities/Strings.php index c23503fc..cf853537 100644 --- a/src/Ouzo/Goodies/Utilities/Strings.php +++ b/src/Ouzo/Goodies/Utilities/Strings.php @@ -10,11 +10,11 @@ class Strings { - const EMPTY = ''; - const SPACE = ' '; + const string EMPTY = ''; + const string SPACE = ' '; #[Deprecated(message: 'use Strings::EMPTY instead', since: '3.0')] - const EMPTY_STRING = self::EMPTY; + const string EMPTY_STRING = self::EMPTY; /** * Example: diff --git a/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php b/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php index 0fc943a0..8d587037 100644 --- a/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php +++ b/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php @@ -8,13 +8,13 @@ class TimeUnit { - public const DAYS = 'DAYS'; - public const HOURS = 'HOURS'; - public const MICROSECONDS = 'MICROSECONDS'; - public const MILLISECONDS = 'MILLISECONDS'; - public const MINUTES = 'MINUTES'; - public const NANOSECONDS = 'NANOSECONDS'; - public const SECONDS = 'SECONDS'; + public const string DAYS = 'DAYS'; + public const string HOURS = 'HOURS'; + public const string MICROSECONDS = 'MICROSECONDS'; + public const string MILLISECONDS = 'MILLISECONDS'; + public const string MINUTES = 'MINUTES'; + public const string NANOSECONDS = 'NANOSECONDS'; + public const string SECONDS = 'SECONDS'; private function __construct(private string $timeUnit) { diff --git a/src/Ouzo/Inject/Injection/Scope.php b/src/Ouzo/Inject/Injection/Scope.php index e6ce5fac..858f9191 100644 --- a/src/Ouzo/Inject/Injection/Scope.php +++ b/src/Ouzo/Inject/Injection/Scope.php @@ -8,6 +8,6 @@ class Scope { - const SINGLETON = 'singleton'; - const PROTOTYPE = 'prototype'; + const string SINGLETON = 'singleton'; + const string PROTOTYPE = 'prototype'; } diff --git a/src/Ouzo/Migrations/Migration/MigrationCommand.php b/src/Ouzo/Migrations/Migration/MigrationCommand.php index 75eb83f0..fe833f9e 100644 --- a/src/Ouzo/Migrations/Migration/MigrationCommand.php +++ b/src/Ouzo/Migrations/Migration/MigrationCommand.php @@ -19,7 +19,7 @@ abstract class MigrationCommand extends Command { - const LOG_STDOUT_ARGUMENT = 'log-stdout'; + public const string LOG_STDOUT_ARGUMENT = 'log-stdout'; protected function configure() { diff --git a/src/Ouzo/Migrations/Migration/MigrationDumper.php b/src/Ouzo/Migrations/Migration/MigrationDumper.php index 0a9ec9d4..5475b916 100644 --- a/src/Ouzo/Migrations/Migration/MigrationDumper.php +++ b/src/Ouzo/Migrations/Migration/MigrationDumper.php @@ -10,8 +10,8 @@ class MigrationDumper { - private const SCHEMA = 'SCHEMA'; - private const DATA = 'DATA'; + private const string SCHEMA = 'SCHEMA'; + private const string DATA = 'DATA'; /* @var OutputInterface */ private $output; diff --git a/src/Ouzo/Migrations/Migration/MigrationLoader.php b/src/Ouzo/Migrations/Migration/MigrationLoader.php index ec14e24a..a3374f73 100644 --- a/src/Ouzo/Migrations/Migration/MigrationLoader.php +++ b/src/Ouzo/Migrations/Migration/MigrationLoader.php @@ -13,7 +13,7 @@ class MigrationLoader { - private const MIGRATION_FILE_MASK = '/[0-9]{9,}_.+\.php/'; + private const string MIGRATION_FILE_MASK = '/[0-9]{9,}_.+\.php/'; public function loadMigrations(array $dirs): array { From 07d841ac803a71ab4ee2f18c70d04e5466663e76 Mon Sep 17 00:00:00 2001 From: Bartosz Bankowski Date: Tue, 28 Apr 2026 13:37:42 +0200 Subject: [PATCH 2/2] Add PHP 8.3 #[Override] attributes across the codebase Co-Authored-By: Claude Sonnet 4.6 --- .../Core/Config/Inject/ValueAttributeInjector.php | 2 ++ src/Ouzo/Core/Db/Dialect/MySqlDialect.php | 12 ++++++++++++ src/Ouzo/Core/Db/Dialect/PostgresDialect.php | 10 ++++++++++ src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php | 15 +++++++++++++++ .../Db/EmulatedPDOPreparedStatementExecutor.php | 1 + src/Ouzo/Core/Db/PDOPreparedStatementExecutor.php | 1 + src/Ouzo/Core/Db/Relation.php | 1 + src/Ouzo/Core/Db/RelationWithAlias.php | 1 + src/Ouzo/Core/Db/StatementIterator.php | 5 +++++ src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php | 4 ++++ src/Ouzo/Core/Db/WhereClause/EmptyWhereClause.php | 3 +++ src/Ouzo/Core/Db/WhereClause/ExistsClause.php | 3 +++ src/Ouzo/Core/Db/WhereClause/OrClause.php | 4 ++++ src/Ouzo/Core/Db/WhereClause/SqlWhereClause.php | 3 +++ src/Ouzo/Core/Exception/ForbiddenException.php | 1 + src/Ouzo/Core/Exception/InternalException.php | 1 + src/Ouzo/Core/Exception/NotFoundException.php | 1 + src/Ouzo/Core/Exception/UnauthorizedException.php | 1 + src/Ouzo/Core/Exception/ValidationException.php | 1 + .../Core/ExceptionHandling/CliErrorRenderer.php | 1 + .../Core/ExceptionHandling/DebugErrorHandler.php | 2 ++ .../ExceptionHandling/DebugErrorLogHandler.php | 1 + .../ExceptionHandling/DebugExceptionHandler.php | 1 + src/Ouzo/Core/ExceptionHandling/ErrorRenderer.php | 1 + src/Ouzo/Core/ExceptionHandling/OuzoException.php | 1 + .../Core/ExceptionHandling/OuzoExceptionData.php | 1 + .../Core/ExceptionHandling/ValidationError.php | 2 ++ src/Ouzo/Core/Logger/DefaultMessageFormatter.php | 1 + src/Ouzo/Core/Logger/StdOutputLogger.php | 9 +++++++++ src/Ouzo/Core/Logger/SyslogLogger.php | 9 +++++++++ .../Middleware/Interceptor/DefaultRequestId.php | 1 + .../Core/Middleware/Interceptor/LogRequest.php | 1 + .../Middleware/Interceptor/SessionStarter.php | 1 + src/Ouzo/Core/Model.php | 2 ++ src/Ouzo/Core/Notice.php | 1 + src/Ouzo/Core/Request/RequestContextFactory.php | 1 + src/Ouzo/Core/Restriction/BetweenRestriction.php | 2 ++ src/Ouzo/Core/Restriction/EqualToRestriction.php | 1 + .../Restriction/GreaterOrEqualToRestriction.php | 1 + .../Core/Restriction/GreaterThanRestriction.php | 1 + src/Ouzo/Core/Restriction/IsInRestriction.php | 2 ++ src/Ouzo/Core/Restriction/IsNotInRestriction.php | 2 ++ .../Core/Restriction/IsNotNullRestriction.php | 1 + src/Ouzo/Core/Restriction/IsNullRestriction.php | 1 + .../Core/Restriction/LessOrEqualToRestriction.php | 1 + src/Ouzo/Core/Restriction/LessThanRestriction.php | 1 + src/Ouzo/Core/Restriction/LikeRestriction.php | 1 + src/Ouzo/Core/Restriction/NoValueRestriction.php | 1 + .../Core/Restriction/NotEqualToRestriction.php | 1 + src/Ouzo/Core/Restriction/RegexpRestriction.php | 1 + .../Core/Restriction/SingleValueRestriction.php | 1 + src/Ouzo/Core/Routing/Annotation/Route/Delete.php | 1 + src/Ouzo/Core/Routing/Annotation/Route/Get.php | 1 + .../Core/Routing/Annotation/Route/Options.php | 1 + src/Ouzo/Core/Routing/Annotation/Route/Post.php | 1 + src/Ouzo/Core/Routing/Annotation/Route/Put.php | 1 + src/Ouzo/Core/Routing/GroupedRoute.php | 6 ++++++ .../Core/Routing/Loader/AnnotationClassLoader.php | 1 + .../Routing/Loader/AnnotationDirectoryLoader.php | 1 + src/Ouzo/Core/Routing/Route.php | 6 ++++++ src/Ouzo/Core/Tests/ControllerTestCase.php | 2 ++ src/Ouzo/Core/Tests/DbTransactionalTestCase.php | 2 ++ src/Ouzo/Core/Tests/MockCookiesSetter.php | 1 + src/Ouzo/Core/Tests/MockDownloadHandler.php | 2 ++ src/Ouzo/Core/Tests/MockHeaderSender.php | 1 + src/Ouzo/Core/Tests/MockOutputRenderer.php | 1 + src/Ouzo/Core/Tests/MockRedirectHandler.php | 1 + src/Ouzo/Core/Tests/MockSessionInitializer.php | 1 + .../Core/Tests/MockSessionStarterInterceptor.php | 1 + src/Ouzo/Core/Tests/ModelAttributesMatcher.php | 2 ++ .../Tools/Model/Template/Dialect/MySqlDialect.php | 2 ++ .../Model/Template/Dialect/PostgresDialect.php | 3 +++ src/Ouzo/Core/Uri/PathProvider.php | 1 + src/Ouzo/Core/View/DefaultViewNameProvider.php | 1 + src/Ouzo/Core/View/DefaultViewPathProvider.php | 1 + src/Ouzo/Core/View/PhtmlRenderer.php | 2 ++ src/Ouzo/Core/View/TwigRenderer.php | 2 ++ .../Goodies/Tests/Mock/AndArgumentMatcher.php | 2 ++ src/Ouzo/Goodies/Tests/Mock/AnyArgument.php | 2 ++ src/Ouzo/Goodies/Tests/Mock/AnyArgumentList.php | 1 + .../Goodies/Tests/Mock/FluentArgumentMatcher.php | 3 +++ src/Ouzo/Goodies/Tests/Mock/MethodCall.php | 1 + src/Ouzo/Goodies/Tests/Mock/NotCalledVerifier.php | 1 + .../Tests/Mock/ReceivedTimesCallVerifier.php | 2 ++ src/Ouzo/Goodies/Utilities/Chain/ChainHandler.php | 1 + src/Ouzo/Goodies/Utilities/Chain/EndChain.php | 1 + .../Goodies/Utilities/Chain/InvocationChain.php | 1 + src/Ouzo/Goodies/Utilities/Extractor.php | 4 ++++ .../Utilities/Iterator/BatchingIterator.php | 5 +++++ .../Utilities/Iterator/FilteringIterator.php | 2 ++ .../Utilities/Iterator/ForwardingIterator.php | 5 +++++ .../Utilities/Iterator/GeneratingIterator.php | 5 +++++ .../Utilities/Iterator/ReindexingIterator.php | 3 +++ .../Utilities/Iterator/SkippingIterator.php | 3 +++ .../Utilities/Iterator/TransformingIterator.php | 2 ++ .../Utilities/Iterator/UnbatchingIterator.php | 5 +++++ .../Goodies/Utilities/JsonDecodeException.php | 1 + .../Goodies/Utilities/JsonEncodeException.php | 1 + .../Goodies/Utilities/NonCallableExtractor.php | 4 ++++ .../Supplier/ExpiringMemoizingSupplier.php | 1 + .../Utilities/Supplier/MemoizingSupplier.php | 1 + src/Ouzo/Goodies/Utilities/Time/TimeUnit.php | 1 + .../Annotation/InjectAttributeInjector.php | 2 ++ .../Annotation/InjectListAttributeInjector.php | 2 ++ .../Injection/Creator/EagerInstanceCreator.php | 2 ++ .../Creator/ProxyManagerInstanceCreator.php | 2 ++ .../Migrations/Migration/MigrationCommand.php | 2 ++ .../Migrations/Migration/MigrationDbConfig.php | 1 + .../Migration/MigrationFailedException.php | 1 + src/Ouzo/Migrations/Migration/SchemaMigration.php | 1 + 110 files changed, 240 insertions(+) diff --git a/src/Ouzo/Core/Config/Inject/ValueAttributeInjector.php b/src/Ouzo/Core/Config/Inject/ValueAttributeInjector.php index 0d6c4a64..ce061e91 100644 --- a/src/Ouzo/Core/Config/Inject/ValueAttributeInjector.php +++ b/src/Ouzo/Core/Config/Inject/ValueAttributeInjector.php @@ -17,6 +17,7 @@ class ValueAttributeInjector implements AttributeInjector { + #[Override] public function injectForProperties(object $instance, array $reflectionProperties, InstanceFactory $instanceFactory): void { foreach ($reflectionProperties as $reflectionProperty) { @@ -30,6 +31,7 @@ public function injectForProperties(object $instance, array $reflectionPropertie } } + #[Override] public function injectForConstructorParameter(ReflectionMethod $constructor, InstanceFactory $instanceFactory): array { $constructorParameters = []; diff --git a/src/Ouzo/Core/Db/Dialect/MySqlDialect.php b/src/Ouzo/Core/Db/Dialect/MySqlDialect.php index df50eb23..7be47705 100644 --- a/src/Ouzo/Core/Db/Dialect/MySqlDialect.php +++ b/src/Ouzo/Core/Db/Dialect/MySqlDialect.php @@ -13,6 +13,7 @@ class MySqlDialect extends Dialect { + #[Override] public function table(): string { $alias = $this->query->aliasTable; @@ -24,57 +25,68 @@ public function table(): string return $table; } + #[Override] public function getConnectionErrorCodes(): array { return [2003, 2006]; } + #[Override] public function getErrorCode(array $errorInfo): mixed { return Arrays::getValue($errorInfo, 1); } + #[Override] public function using(): string { return $this->usingClause($this->query->usingClauses, ' INNER JOIN ', $this->query->table, $this->query->aliasTable); } + #[Override] public function batchInsert(string $table, string $primaryKey, array $columns, int $batchSize, ?OnConflict $onConflict): string { throw new InvalidArgumentException("Batch insert not supported in mysql"); } + #[Override] protected function insertEmptyRow(): string { return "INSERT INTO {$this->query->table} VALUES ()"; } + #[Override] public function regexpMatcher(): string { return 'REGEXP'; } + #[Override] protected function quote(string $word): string { return "`{$word}`"; } + #[Override] public function onConflictUpdate(): string { $attributes = DialectUtil::buildAttributesPartForUpdate($this->query->updateAttributes); return " ON DUPLICATE KEY UPDATE {$attributes}"; } + #[Override] public function onConflictDoNothing(): string { throw new InvalidArgumentException("On conflict do nothing is not supported in mysql"); } + #[Override] protected function getDistinctOnQuery(): string { throw new InvalidArgumentException("DISTINCT ON is not supported in mysql"); } + #[Override] protected function wrapQueryWithDistinctCount(string $sql): string { throw new InvalidArgumentException("DISTINCT for COUNT is not supported in mysql"); diff --git a/src/Ouzo/Core/Db/Dialect/PostgresDialect.php b/src/Ouzo/Core/Db/Dialect/PostgresDialect.php index 39531411..7cff412a 100644 --- a/src/Ouzo/Core/Db/Dialect/PostgresDialect.php +++ b/src/Ouzo/Core/Db/Dialect/PostgresDialect.php @@ -13,16 +13,19 @@ class PostgresDialect extends Dialect { + #[Override] public function getConnectionErrorCodes(): array { return ['57000', '57014', '57P01', '57P02', '57P03']; } + #[Override] public function getErrorCode(array $errorInfo): mixed { return Arrays::getValue($errorInfo, 0); } + #[Override] public function batchInsert(string $table, string $primaryKey, $columns, $batchSize, ?OnConflict $onConflict): string { $valueClause = '(' . implode(', ', array_fill(0, count($columns), '?')) . ')'; @@ -49,21 +52,25 @@ public function batchInsert(string $table, string $primaryKey, $columns, $batchS return $sql; } + #[Override] protected function insertEmptyRow(): string { return "INSERT INTO {$this->query->table} DEFAULT VALUES"; } + #[Override] public function regexpMatcher(): string { return '~'; } + #[Override] protected function quote(string $word): string { return "\"{$word}\""; } + #[Override] public function onConflictUpdate(): string { $attributes = DialectUtil::buildAttributesPartForUpdate($this->query->updateAttributes); @@ -72,16 +79,19 @@ public function onConflictUpdate(): string return " ON CONFLICT ({$joinedColumns}) DO UPDATE SET {$attributes}"; } + #[Override] public function onConflictDoNothing(): string { return " ON CONFLICT DO NOTHING"; } + #[Override] protected function getDistinctOnQuery(): string { return 'DISTINCT ON (' . Joiner::on(', ')->join($this->query->distinctOnColumns) . ') '; } + #[Override] protected function wrapQueryWithDistinctCount(string $sql): string { return "SELECT count(*) FROM ({$sql}) AS count_data"; diff --git a/src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php b/src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php index 5f76b403..7d009948 100644 --- a/src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php +++ b/src/Ouzo/Core/Db/Dialect/Sqlite3Dialect.php @@ -15,16 +15,19 @@ class Sqlite3Dialect extends Dialect { + #[Override] public function getConnectionErrorCodes(): array { return [10, 11, 14]; } + #[Override] public function getErrorCode(array $errorInfo): mixed { return Arrays::getValue($errorInfo, 1); } + #[Override] public function update(): string { if ($this->query->aliasTable) { @@ -33,6 +36,7 @@ public function update(): string return parent::update(); } + #[Override] public function join(): string { $any = Arrays::any($this->query->joinClauses, function (JoinClause $joinClause) { @@ -44,6 +48,7 @@ public function join(): string return parent::join(); } + #[Override] public function lockForUpdate(): string { if ($this->query->lockForUpdate) { @@ -52,6 +57,7 @@ public function lockForUpdate(): string return ''; } + #[Override] public function using(): string { if ($this->query->usingClauses) { @@ -60,47 +66,56 @@ public function using(): string return ''; } + #[Override] public function batchInsert(string $table, string $primaryKey, $columns, $batchSize, ?OnConflict $onConflict): string { throw new InvalidArgumentException("Batch insert not supported in sqlite3"); } + #[Override] protected function insertEmptyRow(): string { return "INSERT INTO {$this->query->table} DEFAULT VALUES"; } + #[Override] public function regexpMatcher(): string { //needs package sqlite3-pcre to work correctly return 'REGEXP'; } + #[Override] protected function quote(string $word): string { return "\"{$word}\""; } + #[Override] public function getIteratorOptions(): array { return []; } + #[Override] public function onConflictUpdate(): string { throw new BadMethodCallException('UPSERT is not supported in sqlite3'); } + #[Override] public function onConflictDoNothing(): string { throw new BadMethodCallException('On conflict do nothing is not supported in sqlite3'); } + #[Override] protected function getDistinctOnQuery(): string { throw new InvalidArgumentException("DISTINCT ON is not supported in sqlite3"); } + #[Override] protected function wrapQueryWithDistinctCount(string $sql): string { throw new InvalidArgumentException("DISTINCT for COUNT is not supported in sqlite3"); diff --git a/src/Ouzo/Core/Db/EmulatedPDOPreparedStatementExecutor.php b/src/Ouzo/Core/Db/EmulatedPDOPreparedStatementExecutor.php index cdf41a9e..a9d5e0aa 100644 --- a/src/Ouzo/Core/Db/EmulatedPDOPreparedStatementExecutor.php +++ b/src/Ouzo/Core/Db/EmulatedPDOPreparedStatementExecutor.php @@ -11,6 +11,7 @@ class EmulatedPDOPreparedStatementExecutor extends PDOExecutor { + #[Override] public function createPDOStatement(PDO $dbHandle, string $sql, array $boundValues, string $queryString, array $options = []): PDOStatement { $sql = PreparedStatementEmulator::substitute($sql, $boundValues); diff --git a/src/Ouzo/Core/Db/PDOPreparedStatementExecutor.php b/src/Ouzo/Core/Db/PDOPreparedStatementExecutor.php index d892a90f..3b7ad217 100644 --- a/src/Ouzo/Core/Db/PDOPreparedStatementExecutor.php +++ b/src/Ouzo/Core/Db/PDOPreparedStatementExecutor.php @@ -12,6 +12,7 @@ class PDOPreparedStatementExecutor extends PDOExecutor { + #[Override] public function createPDOStatement(PDO $dbHandle, string $sql, array $boundValues, string $queryString, array $options = []): PDOStatement { try { diff --git a/src/Ouzo/Core/Db/Relation.php b/src/Ouzo/Core/Db/Relation.php index 691384a4..9efab892 100644 --- a/src/Ouzo/Core/Db/Relation.php +++ b/src/Ouzo/Core/Db/Relation.php @@ -100,6 +100,7 @@ public function withName(string $name): Relation return new Relation($name, $this->class, $this->localKey, $this->foreignKey, $this->collection, $this->condition); } + #[Override] public function __toString(): string { return "Relation {$this->name} {$this->class} {$this->localKey} {$this->foreignKey}"; diff --git a/src/Ouzo/Core/Db/RelationWithAlias.php b/src/Ouzo/Core/Db/RelationWithAlias.php index 66731c8c..720d70a6 100644 --- a/src/Ouzo/Core/Db/RelationWithAlias.php +++ b/src/Ouzo/Core/Db/RelationWithAlias.php @@ -12,6 +12,7 @@ public function __construct(public Relation $relation, public ?string $alias) { } + #[Override] public function __toString(): string { return "{$this->relation} {$this->alias}"; diff --git a/src/Ouzo/Core/Db/StatementIterator.php b/src/Ouzo/Core/Db/StatementIterator.php index 24329370..1ab6dfde 100644 --- a/src/Ouzo/Core/Db/StatementIterator.php +++ b/src/Ouzo/Core/Db/StatementIterator.php @@ -20,21 +20,25 @@ public function __construct(private PDOStatement $statement) $this->iterator = new IteratorIterator($statement); } + #[Override] public function current(): mixed { return $this->iterator->current(); } + #[Override] public function next(): void { $this->iterator->next(); } + #[Override] public function key(): float|bool|int|string|null { return $this->iterator->key(); } + #[Override] public function valid(): bool { $valid = $this->iterator->valid(); @@ -44,6 +48,7 @@ public function valid(): bool return $valid; } + #[Override] public function rewind(): void { $this->iterator->rewind(); diff --git a/src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php b/src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php index 35959c36..a6340f16 100644 --- a/src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php +++ b/src/Ouzo/Core/Db/WhereClause/ArrayWhereClause.php @@ -30,22 +30,26 @@ public function __construct(array $where, string $operator = 'AND') $this->operator = $operator; } + #[Override] public function isNeverSatisfied(): bool { return Arrays::any($this->where, fn($value) => is_array($value) && sizeof($value) == 0); } + #[Override] public function isEmpty(): bool { return empty($this->where); } + #[Override] public function toSql(): string { $whereKeys = self::buildWhereKeys($this->where); return DialectUtil::joinClauses($whereKeys, $this->operator); } + #[Override] public function getParameters(): array { return $this->values; diff --git a/src/Ouzo/Core/Db/WhereClause/EmptyWhereClause.php b/src/Ouzo/Core/Db/WhereClause/EmptyWhereClause.php index f45e6215..00019f76 100644 --- a/src/Ouzo/Core/Db/WhereClause/EmptyWhereClause.php +++ b/src/Ouzo/Core/Db/WhereClause/EmptyWhereClause.php @@ -8,16 +8,19 @@ class EmptyWhereClause extends WhereClause { + #[Override] public function isEmpty(): bool { return true; } + #[Override] public function toSql(): string { return ''; } + #[Override] public function getParameters(): array { return []; diff --git a/src/Ouzo/Core/Db/WhereClause/ExistsClause.php b/src/Ouzo/Core/Db/WhereClause/ExistsClause.php index 15391b40..5508da49 100644 --- a/src/Ouzo/Core/Db/WhereClause/ExistsClause.php +++ b/src/Ouzo/Core/Db/WhereClause/ExistsClause.php @@ -21,17 +21,20 @@ public function __construct(Query $query, $negate = false) $this->negate = $negate; } + #[Override] public function isEmpty(): bool { return false; } + #[Override] public function toSql(): string { $sql = DialectFactory::create()->buildQuery($this->query); return $this->negate ? "NOT EXISTS ({$sql})" : "EXISTS ({$sql})"; } + #[Override] public function getParameters(): array { $queryBindValuesExtractor = new QueryBoundValuesExtractor($this->query); diff --git a/src/Ouzo/Core/Db/WhereClause/OrClause.php b/src/Ouzo/Core/Db/WhereClause/OrClause.php index 9d4d083f..fa139bcc 100644 --- a/src/Ouzo/Core/Db/WhereClause/OrClause.php +++ b/src/Ouzo/Core/Db/WhereClause/OrClause.php @@ -19,21 +19,25 @@ public function __construct(array $conditions) $this->conditions = $conditions; } + #[Override] public function isEmpty(): bool { return Arrays::all($this->conditions, fn(WhereClause $where) => $where->isEmpty()); } + #[Override] public function isNeverSatisfied(): bool { return Arrays::all($this->conditions, fn(WhereClause $where) => $where->isNeverSatisfied()); } + #[Override] public function toSql(): string { return DialectUtil::joinClauses($this->conditions, 'OR', fn(WhereClause $where) => $where->toSql()); } + #[Override] public function getParameters(): array { return Arrays::concat(Arrays::map($this->conditions, fn(WhereClause $where) => $where->getParameters())); diff --git a/src/Ouzo/Core/Db/WhereClause/SqlWhereClause.php b/src/Ouzo/Core/Db/WhereClause/SqlWhereClause.php index 2fed98a0..a31db0f9 100644 --- a/src/Ouzo/Core/Db/WhereClause/SqlWhereClause.php +++ b/src/Ouzo/Core/Db/WhereClause/SqlWhereClause.php @@ -20,16 +20,19 @@ public function __construct(string $sql, mixed $parameters = []) $this->values = $parameters === null ? [null] : Arrays::toArray($parameters); } + #[Override] public function toSql(): string { return stripos($this->sql, 'OR') ? "({$this->sql})" : $this->sql; } + #[Override] public function getParameters(): array { return $this->values; } + #[Override] public function isEmpty(): bool { return Strings::isBlank($this->sql); diff --git a/src/Ouzo/Core/Exception/ForbiddenException.php b/src/Ouzo/Core/Exception/ForbiddenException.php index 6179daaa..91a130ec 100644 --- a/src/Ouzo/Core/Exception/ForbiddenException.php +++ b/src/Ouzo/Core/Exception/ForbiddenException.php @@ -14,6 +14,7 @@ class ForbiddenException extends OuzoException const int HTTP_CODE = 403; /** @param Error[]|Error $errors */ + #[Override] public function __construct(array|Error $errors) { parent::__construct(self::HTTP_CODE, "Forbidden.", $errors); diff --git a/src/Ouzo/Core/Exception/InternalException.php b/src/Ouzo/Core/Exception/InternalException.php index db0bfe58..cb30f10b 100644 --- a/src/Ouzo/Core/Exception/InternalException.php +++ b/src/Ouzo/Core/Exception/InternalException.php @@ -17,6 +17,7 @@ class InternalException extends OuzoException * @param Error[]|Error $errors * @param string[] $headers */ + #[Override] public function __construct(array|Error $errors, array $headers = []) { parent::__construct(self::HTTP_CODE, "Internal error.", $errors, $headers); diff --git a/src/Ouzo/Core/Exception/NotFoundException.php b/src/Ouzo/Core/Exception/NotFoundException.php index 3ffa7e4f..f8e86116 100644 --- a/src/Ouzo/Core/Exception/NotFoundException.php +++ b/src/Ouzo/Core/Exception/NotFoundException.php @@ -17,6 +17,7 @@ class NotFoundException extends OuzoException * @param Error[]|Error $errors * @param string[] $headers */ + #[Override] public function __construct(array|Error $errors, array $headers = []) { parent::__construct(self::HTTP_CODE, "Not found.", $errors, $headers); diff --git a/src/Ouzo/Core/Exception/UnauthorizedException.php b/src/Ouzo/Core/Exception/UnauthorizedException.php index 87f7ad9a..d589c687 100644 --- a/src/Ouzo/Core/Exception/UnauthorizedException.php +++ b/src/Ouzo/Core/Exception/UnauthorizedException.php @@ -17,6 +17,7 @@ class UnauthorizedException extends OuzoException * @param Error[]|Error $errors * @param string[] $headers */ + #[Override] public function __construct(array|Error $errors, array $headers = []) { parent::__construct(self::HTTP_CODE, "Unauthorized.", $errors, $headers); diff --git a/src/Ouzo/Core/Exception/ValidationException.php b/src/Ouzo/Core/Exception/ValidationException.php index 612ae132..c1be0e94 100644 --- a/src/Ouzo/Core/Exception/ValidationException.php +++ b/src/Ouzo/Core/Exception/ValidationException.php @@ -17,6 +17,7 @@ class ValidationException extends OuzoException * @param Error[]|Error $errors * @param string[] $headers */ + #[Override] public function __construct(array|Error $errors, array $headers = []) { parent::__construct(self::HTTP_CODE, "Validation failed.", $errors, $headers); diff --git a/src/Ouzo/Core/ExceptionHandling/CliErrorRenderer.php b/src/Ouzo/Core/ExceptionHandling/CliErrorRenderer.php index a43dd38e..1fe605d6 100644 --- a/src/Ouzo/Core/ExceptionHandling/CliErrorRenderer.php +++ b/src/Ouzo/Core/ExceptionHandling/CliErrorRenderer.php @@ -11,6 +11,7 @@ class CliErrorRenderer implements Renderer { + #[Override] public function render(OuzoExceptionData $exceptionData, ?string $viewName): void { global $argv; diff --git a/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php b/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php index 99a046fb..4868d212 100644 --- a/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php +++ b/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php @@ -11,11 +11,13 @@ class DebugErrorHandler extends ErrorHandler { + #[Override] public function handleError(int $errorNumber, string $errorString, string $errorFile, int $errorLine): void { $this->createWhoops()->handleError($errorNumber, $errorString, $errorFile, $errorLine); } + #[Override] public function handleShutdown(): void { $this->createWhoops()->handleShutdown(); diff --git a/src/Ouzo/Core/ExceptionHandling/DebugErrorLogHandler.php b/src/Ouzo/Core/ExceptionHandling/DebugErrorLogHandler.php index 46b3837b..24d7b631 100644 --- a/src/Ouzo/Core/ExceptionHandling/DebugErrorLogHandler.php +++ b/src/Ouzo/Core/ExceptionHandling/DebugErrorLogHandler.php @@ -10,6 +10,7 @@ class DebugErrorLogHandler extends Handler { + #[Override] public function handle(): ?int { $exception = $this->getInspector()->getException(); diff --git a/src/Ouzo/Core/ExceptionHandling/DebugExceptionHandler.php b/src/Ouzo/Core/ExceptionHandling/DebugExceptionHandler.php index b8bbdf3a..a83dbbea 100644 --- a/src/Ouzo/Core/ExceptionHandling/DebugExceptionHandler.php +++ b/src/Ouzo/Core/ExceptionHandling/DebugExceptionHandler.php @@ -14,6 +14,7 @@ class DebugExceptionHandler extends ExceptionHandler { + #[Override] public function runDefaultHandler($exception): void { if ($this->isPrettyHandlerNeeded()) { diff --git a/src/Ouzo/Core/ExceptionHandling/ErrorRenderer.php b/src/Ouzo/Core/ExceptionHandling/ErrorRenderer.php index c9795d1f..241076f6 100644 --- a/src/Ouzo/Core/ExceptionHandling/ErrorRenderer.php +++ b/src/Ouzo/Core/ExceptionHandling/ErrorRenderer.php @@ -11,6 +11,7 @@ class ErrorRenderer implements Renderer { + #[Override] public function render(OuzoExceptionData $exceptionData, ?string $viewName): void { $errorMessage = $exceptionData->getMessage(); diff --git a/src/Ouzo/Core/ExceptionHandling/OuzoException.php b/src/Ouzo/Core/ExceptionHandling/OuzoException.php index 771c3c6c..2315c610 100644 --- a/src/Ouzo/Core/ExceptionHandling/OuzoException.php +++ b/src/Ouzo/Core/ExceptionHandling/OuzoException.php @@ -22,6 +22,7 @@ class OuzoException extends Exception * @param Error[]|Error $errors * @param string[] $headers */ + #[Override] public function __construct( int $httpCode, string $message, diff --git a/src/Ouzo/Core/ExceptionHandling/OuzoExceptionData.php b/src/Ouzo/Core/ExceptionHandling/OuzoExceptionData.php index be1f9797..9dff7071 100644 --- a/src/Ouzo/Core/ExceptionHandling/OuzoExceptionData.php +++ b/src/Ouzo/Core/ExceptionHandling/OuzoExceptionData.php @@ -102,6 +102,7 @@ public function getSeverityAsString(): string return "E_UNKNOWN"; } + #[Override] function __toString(): string { return __CLASS__ . Objects::toString(get_object_vars($this)); diff --git a/src/Ouzo/Core/ExceptionHandling/ValidationError.php b/src/Ouzo/Core/ExceptionHandling/ValidationError.php index 8a9cea6b..d7cc4290 100644 --- a/src/Ouzo/Core/ExceptionHandling/ValidationError.php +++ b/src/Ouzo/Core/ExceptionHandling/ValidationError.php @@ -12,6 +12,7 @@ class ValidationError extends Error { private ?string $value; + #[Override] public function __construct( string $message, ?string $field = null, @@ -24,6 +25,7 @@ public function __construct( } #[ArrayShape(['message' => "string", 'code' => "string", 'field' => "null|string"])] + #[Override] public function toArray(): array { $array = ['message' => $this->getMessage()]; diff --git a/src/Ouzo/Core/Logger/DefaultMessageFormatter.php b/src/Ouzo/Core/Logger/DefaultMessageFormatter.php index 88c43a9e..a3685ba1 100644 --- a/src/Ouzo/Core/Logger/DefaultMessageFormatter.php +++ b/src/Ouzo/Core/Logger/DefaultMessageFormatter.php @@ -10,6 +10,7 @@ class DefaultMessageFormatter implements MessageFormatter { + #[Override] public function format(string $logger, string $level, string $message): string { return sprintf("%s %s: [ID: %s] %s", $logger, $level, FrontController::$requestId, $message); diff --git a/src/Ouzo/Core/Logger/StdOutputLogger.php b/src/Ouzo/Core/Logger/StdOutputLogger.php index e08b8758..b61c454e 100644 --- a/src/Ouzo/Core/Logger/StdOutputLogger.php +++ b/src/Ouzo/Core/Logger/StdOutputLogger.php @@ -17,46 +17,55 @@ public function __construct(string $name, string $configuration, private string { } + #[Override] public function log($level, string|Stringable $message, array $context = []): void { $this->doLog($level, (string)$message); } + #[Override] public function emergency(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::EMERGENCY, (string)$message); } + #[Override] public function alert(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::ALERT, (string)$message); } + #[Override] public function critical(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::CRITICAL, (string)$message); } + #[Override] public function error(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::ERROR, (string)$message); } + #[Override] public function warning(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::WARNING, (string)$message); } + #[Override] public function notice(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::NOTICE, (string)$message); } + #[Override] public function info(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::INFO, (string)$message); } + #[Override] public function debug(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::DEBUG, (string)$message); diff --git a/src/Ouzo/Core/Logger/SyslogLogger.php b/src/Ouzo/Core/Logger/SyslogLogger.php index 0aa40df2..a0c1580f 100644 --- a/src/Ouzo/Core/Logger/SyslogLogger.php +++ b/src/Ouzo/Core/Logger/SyslogLogger.php @@ -29,46 +29,55 @@ public function __destruct() closelog(); } + #[Override] public function log($level, string|Stringable $message, array $context = []): void { $this->doLog($level, (string)$message); } + #[Override] public function emergency(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::EMERGENCY, (string)$message); } + #[Override] public function alert(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::ALERT, (string)$message); } + #[Override] public function critical(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::CRITICAL, (string)$message); } + #[Override] public function error(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::ERROR, (string)$message); } + #[Override] public function warning(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::WARNING, (string)$message); } + #[Override] public function notice(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::NOTICE, (string)$message); } + #[Override] public function info(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::INFO, (string)$message); } + #[Override] public function debug(string|Stringable $message, array $context = []): void { $this->doLog(LogLevel::DEBUG, (string)$message); diff --git a/src/Ouzo/Core/Middleware/Interceptor/DefaultRequestId.php b/src/Ouzo/Core/Middleware/Interceptor/DefaultRequestId.php index dc6d5da8..32471d30 100644 --- a/src/Ouzo/Core/Middleware/Interceptor/DefaultRequestId.php +++ b/src/Ouzo/Core/Middleware/Interceptor/DefaultRequestId.php @@ -13,6 +13,7 @@ class DefaultRequestId implements Interceptor { + #[Override] public function handle(mixed $param, Chain $next): mixed { return $this->handleRequestContext($param, $next); diff --git a/src/Ouzo/Core/Middleware/Interceptor/LogRequest.php b/src/Ouzo/Core/Middleware/Interceptor/LogRequest.php index f8be373b..bcefc05d 100644 --- a/src/Ouzo/Core/Middleware/Interceptor/LogRequest.php +++ b/src/Ouzo/Core/Middleware/Interceptor/LogRequest.php @@ -21,6 +21,7 @@ public function __construct(private PathProviderInterface $pathProvider) { } + #[Override] public function handle(mixed $param, Chain $next): mixed { return $this->handleRequestContext($param, $next); diff --git a/src/Ouzo/Core/Middleware/Interceptor/SessionStarter.php b/src/Ouzo/Core/Middleware/Interceptor/SessionStarter.php index 03eced33..55af5ada 100644 --- a/src/Ouzo/Core/Middleware/Interceptor/SessionStarter.php +++ b/src/Ouzo/Core/Middleware/Interceptor/SessionStarter.php @@ -12,6 +12,7 @@ class SessionStarter implements Interceptor { + #[Override] public function handle(mixed $param, Chain $next): mixed { $sessionInitializer = new SessionInitializer(); diff --git a/src/Ouzo/Core/Model.php b/src/Ouzo/Core/Model.php index 324815a2..dc14fc48 100644 --- a/src/Ouzo/Core/Model.php +++ b/src/Ouzo/Core/Model.php @@ -491,6 +491,7 @@ public function getRelation(string $name): Relation return $this->modelDefinition->relations->getRelation($name); } + #[Override] public function __toString(): string { return $this->inspect(); @@ -517,6 +518,7 @@ public function __unserialize(array $serialized): void $this->attributes = $serialized; } + #[Override] public function jsonSerialize(): mixed { return $this->attributes; diff --git a/src/Ouzo/Core/Notice.php b/src/Ouzo/Core/Notice.php index fdd6eb68..090d5da5 100644 --- a/src/Ouzo/Core/Notice.php +++ b/src/Ouzo/Core/Notice.php @@ -27,6 +27,7 @@ public function requestUrlMatches(Uri $uri): bool ) === 0; } + #[Override] public function __toString(): string { return $this->message; diff --git a/src/Ouzo/Core/Request/RequestContextFactory.php b/src/Ouzo/Core/Request/RequestContextFactory.php index d77d6150..0d07f9f0 100644 --- a/src/Ouzo/Core/Request/RequestContextFactory.php +++ b/src/Ouzo/Core/Request/RequestContextFactory.php @@ -23,6 +23,7 @@ public function __construct( { } + #[Override] public function create(): RequestContext { $controller = $this->routingService->getController(); diff --git a/src/Ouzo/Core/Restriction/BetweenRestriction.php b/src/Ouzo/Core/Restriction/BetweenRestriction.php index 844e5611..8e947411 100644 --- a/src/Ouzo/Core/Restriction/BetweenRestriction.php +++ b/src/Ouzo/Core/Restriction/BetweenRestriction.php @@ -15,6 +15,7 @@ public function __construct( { } + #[Override] public function toSql(string $fieldName): string { return match ($this->betweenMode) { @@ -25,6 +26,7 @@ public function toSql(string $fieldName): string }; } + #[Override] public function getValues(): array { return [$this->value1, $this->value2]; diff --git a/src/Ouzo/Core/Restriction/EqualToRestriction.php b/src/Ouzo/Core/Restriction/EqualToRestriction.php index 88e739e7..7e39d16d 100644 --- a/src/Ouzo/Core/Restriction/EqualToRestriction.php +++ b/src/Ouzo/Core/Restriction/EqualToRestriction.php @@ -8,6 +8,7 @@ class EqualToRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} = ?"; diff --git a/src/Ouzo/Core/Restriction/GreaterOrEqualToRestriction.php b/src/Ouzo/Core/Restriction/GreaterOrEqualToRestriction.php index af8a8b54..50eb283f 100644 --- a/src/Ouzo/Core/Restriction/GreaterOrEqualToRestriction.php +++ b/src/Ouzo/Core/Restriction/GreaterOrEqualToRestriction.php @@ -8,6 +8,7 @@ class GreaterOrEqualToRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} >= ?"; diff --git a/src/Ouzo/Core/Restriction/GreaterThanRestriction.php b/src/Ouzo/Core/Restriction/GreaterThanRestriction.php index 13f25620..c3e6bac3 100644 --- a/src/Ouzo/Core/Restriction/GreaterThanRestriction.php +++ b/src/Ouzo/Core/Restriction/GreaterThanRestriction.php @@ -8,6 +8,7 @@ class GreaterThanRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} > ?"; diff --git a/src/Ouzo/Core/Restriction/IsInRestriction.php b/src/Ouzo/Core/Restriction/IsInRestriction.php index df531eea..f7b0dec5 100644 --- a/src/Ouzo/Core/Restriction/IsInRestriction.php +++ b/src/Ouzo/Core/Restriction/IsInRestriction.php @@ -12,6 +12,7 @@ public function __construct(private mixed $values) { } + #[Override] public function toSql(string $fieldName): string { if (!count($this->values) > 0) { @@ -21,6 +22,7 @@ public function toSql(string $fieldName): string return "{$fieldName} IN({$placeholders})"; } + #[Override] public function getValues(): array { return $this->values; diff --git a/src/Ouzo/Core/Restriction/IsNotInRestriction.php b/src/Ouzo/Core/Restriction/IsNotInRestriction.php index f4e585c0..e3d9ec2e 100644 --- a/src/Ouzo/Core/Restriction/IsNotInRestriction.php +++ b/src/Ouzo/Core/Restriction/IsNotInRestriction.php @@ -12,6 +12,7 @@ public function __construct(private mixed $values) { } + #[Override] public function toSql(string $fieldName): string { if (!count($this->values) > 0) { @@ -21,6 +22,7 @@ public function toSql(string $fieldName): string return "{$fieldName} NOT IN({$placeholders})"; } + #[Override] public function getValues(): array { return $this->values; diff --git a/src/Ouzo/Core/Restriction/IsNotNullRestriction.php b/src/Ouzo/Core/Restriction/IsNotNullRestriction.php index 6cf040b8..dd086db5 100644 --- a/src/Ouzo/Core/Restriction/IsNotNullRestriction.php +++ b/src/Ouzo/Core/Restriction/IsNotNullRestriction.php @@ -8,6 +8,7 @@ class IsNotNullRestriction extends NoValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} IS NOT NULL"; diff --git a/src/Ouzo/Core/Restriction/IsNullRestriction.php b/src/Ouzo/Core/Restriction/IsNullRestriction.php index c2e37e18..d9ea187b 100644 --- a/src/Ouzo/Core/Restriction/IsNullRestriction.php +++ b/src/Ouzo/Core/Restriction/IsNullRestriction.php @@ -8,6 +8,7 @@ class IsNullRestriction extends NoValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} IS NULL"; diff --git a/src/Ouzo/Core/Restriction/LessOrEqualToRestriction.php b/src/Ouzo/Core/Restriction/LessOrEqualToRestriction.php index 3cdbdc14..c2ec87b0 100644 --- a/src/Ouzo/Core/Restriction/LessOrEqualToRestriction.php +++ b/src/Ouzo/Core/Restriction/LessOrEqualToRestriction.php @@ -8,6 +8,7 @@ class LessOrEqualToRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} <= ?"; diff --git a/src/Ouzo/Core/Restriction/LessThanRestriction.php b/src/Ouzo/Core/Restriction/LessThanRestriction.php index eff337d5..e1a467b8 100644 --- a/src/Ouzo/Core/Restriction/LessThanRestriction.php +++ b/src/Ouzo/Core/Restriction/LessThanRestriction.php @@ -8,6 +8,7 @@ class LessThanRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} < ?"; diff --git a/src/Ouzo/Core/Restriction/LikeRestriction.php b/src/Ouzo/Core/Restriction/LikeRestriction.php index 67262575..3808213f 100644 --- a/src/Ouzo/Core/Restriction/LikeRestriction.php +++ b/src/Ouzo/Core/Restriction/LikeRestriction.php @@ -8,6 +8,7 @@ class LikeRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} LIKE ?"; diff --git a/src/Ouzo/Core/Restriction/NoValueRestriction.php b/src/Ouzo/Core/Restriction/NoValueRestriction.php index 0ac23dc9..69c6eeb4 100644 --- a/src/Ouzo/Core/Restriction/NoValueRestriction.php +++ b/src/Ouzo/Core/Restriction/NoValueRestriction.php @@ -8,6 +8,7 @@ abstract class NoValueRestriction extends Restriction { + #[Override] public function getValues(): array { return []; diff --git a/src/Ouzo/Core/Restriction/NotEqualToRestriction.php b/src/Ouzo/Core/Restriction/NotEqualToRestriction.php index 34ab12a7..29e73e06 100644 --- a/src/Ouzo/Core/Restriction/NotEqualToRestriction.php +++ b/src/Ouzo/Core/Restriction/NotEqualToRestriction.php @@ -8,6 +8,7 @@ class NotEqualToRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { return "{$fieldName} <> ?"; diff --git a/src/Ouzo/Core/Restriction/RegexpRestriction.php b/src/Ouzo/Core/Restriction/RegexpRestriction.php index f01e0a6c..f27230b5 100644 --- a/src/Ouzo/Core/Restriction/RegexpRestriction.php +++ b/src/Ouzo/Core/Restriction/RegexpRestriction.php @@ -10,6 +10,7 @@ class RegexpRestriction extends SingleValueRestriction { + #[Override] public function toSql(string $fieldName): string { $dialect = DialectFactory::create(); diff --git a/src/Ouzo/Core/Restriction/SingleValueRestriction.php b/src/Ouzo/Core/Restriction/SingleValueRestriction.php index ece040ca..d9242d96 100644 --- a/src/Ouzo/Core/Restriction/SingleValueRestriction.php +++ b/src/Ouzo/Core/Restriction/SingleValueRestriction.php @@ -12,6 +12,7 @@ public function __construct(private mixed $value) { } + #[Override] public function getValues(): array { return [$this->value]; diff --git a/src/Ouzo/Core/Routing/Annotation/Route/Delete.php b/src/Ouzo/Core/Routing/Annotation/Route/Delete.php index 1615a221..dc4c2120 100644 --- a/src/Ouzo/Core/Routing/Annotation/Route/Delete.php +++ b/src/Ouzo/Core/Routing/Annotation/Route/Delete.php @@ -13,6 +13,7 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Delete extends Route { + #[Override] public function __construct(string $path, ?int $httpResponseCode = null) { parent::__construct($path, [HttpMethod::DELETE], $httpResponseCode); diff --git a/src/Ouzo/Core/Routing/Annotation/Route/Get.php b/src/Ouzo/Core/Routing/Annotation/Route/Get.php index 0b65ccd3..7bb31110 100644 --- a/src/Ouzo/Core/Routing/Annotation/Route/Get.php +++ b/src/Ouzo/Core/Routing/Annotation/Route/Get.php @@ -13,6 +13,7 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Get extends Route { + #[Override] public function __construct(string $path, ?int $httpResponseCode = null) { parent::__construct($path, [HttpMethod::GET], $httpResponseCode); diff --git a/src/Ouzo/Core/Routing/Annotation/Route/Options.php b/src/Ouzo/Core/Routing/Annotation/Route/Options.php index 99c616d4..01f02c92 100644 --- a/src/Ouzo/Core/Routing/Annotation/Route/Options.php +++ b/src/Ouzo/Core/Routing/Annotation/Route/Options.php @@ -13,6 +13,7 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Options extends Route { + #[Override] public function __construct(string $path, ?int $httpResponseCode = null) { parent::__construct($path, [HttpMethod::OPTIONS], $httpResponseCode); diff --git a/src/Ouzo/Core/Routing/Annotation/Route/Post.php b/src/Ouzo/Core/Routing/Annotation/Route/Post.php index f6c50120..1df2a35f 100644 --- a/src/Ouzo/Core/Routing/Annotation/Route/Post.php +++ b/src/Ouzo/Core/Routing/Annotation/Route/Post.php @@ -13,6 +13,7 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Post extends Route { + #[Override] public function __construct(string $path, ?int $httpResponseCode = null) { parent::__construct($path, [HttpMethod::POST], $httpResponseCode); diff --git a/src/Ouzo/Core/Routing/Annotation/Route/Put.php b/src/Ouzo/Core/Routing/Annotation/Route/Put.php index 926ced09..1c39329d 100644 --- a/src/Ouzo/Core/Routing/Annotation/Route/Put.php +++ b/src/Ouzo/Core/Routing/Annotation/Route/Put.php @@ -13,6 +13,7 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Put extends Route { + #[Override] public function __construct(string $path, ?int $httpResponseCode = null) { parent::__construct($path, [HttpMethod::PUT], $httpResponseCode); diff --git a/src/Ouzo/Core/Routing/GroupedRoute.php b/src/Ouzo/Core/Routing/GroupedRoute.php index 9fe7db60..5c38d844 100644 --- a/src/Ouzo/Core/Routing/GroupedRoute.php +++ b/src/Ouzo/Core/Routing/GroupedRoute.php @@ -15,31 +15,37 @@ public static function setGroupName(string $name): void self::$name = $name; } + #[Override] public static function get(string $uri, string $controller, string $action, array $options = []): void { Route::get(self::uri($uri), $controller, $action, $options); } + #[Override] public static function post(string $uri, string $controller, string $action, array $options = []): void { Route::post(self::uri($uri), $controller, $action, $options); } + #[Override] public static function put(string $uri, string $controller, string $action, array $options = []): void { Route::put(self::uri($uri), $controller, $action, $options); } + #[Override] public static function delete(string $uri, string $controller, string $action, array $options = []): void { Route::delete(self::uri($uri), $controller, $action, $options); } + #[Override] public static function any(string $uri, string $controller, string $action, array $options = []): void { Route::any(self::uri($uri), $controller, $action, $options); } + #[Override] public static function resource(string $controller, string $uriPrefix): void { Route::resource($controller, self::uri($uriPrefix)); diff --git a/src/Ouzo/Core/Routing/Loader/AnnotationClassLoader.php b/src/Ouzo/Core/Routing/Loader/AnnotationClassLoader.php index a95fbd39..0c2690c7 100644 --- a/src/Ouzo/Core/Routing/Loader/AnnotationClassLoader.php +++ b/src/Ouzo/Core/Routing/Loader/AnnotationClassLoader.php @@ -15,6 +15,7 @@ class AnnotationClassLoader implements Loader { + #[Override] public function load(array $classes): RouteMetadataCollection { $collection = new RouteMetadataCollection(); diff --git a/src/Ouzo/Core/Routing/Loader/AnnotationDirectoryLoader.php b/src/Ouzo/Core/Routing/Loader/AnnotationDirectoryLoader.php index f2b73876..511f3ee0 100644 --- a/src/Ouzo/Core/Routing/Loader/AnnotationDirectoryLoader.php +++ b/src/Ouzo/Core/Routing/Loader/AnnotationDirectoryLoader.php @@ -25,6 +25,7 @@ public function __construct(AnnotationClassLoader $annotationClassLoader) $this->annotationClassLoader = $annotationClassLoader; } + #[Override] public function load(array $paths): RouteMetadataCollection { $collection = new RouteMetadataCollection(); diff --git a/src/Ouzo/Core/Routing/Route.php b/src/Ouzo/Core/Routing/Route.php index 5c8d4c02..b6c40a5f 100644 --- a/src/Ouzo/Core/Routing/Route.php +++ b/src/Ouzo/Core/Routing/Route.php @@ -27,21 +27,25 @@ class Route implements RouteInterface private static array $routes = []; private static array $routeKeys = []; + #[Override] public static function get(string $uri, string $controller, string $action, array $options = []): void { self::addRoute(HttpMethod::GET, $uri, $controller, $action, true, $options); } + #[Override] public static function post(string $uri, string $controller, string $action, array $options = []): void { self::addRoute(HttpMethod::POST, $uri, $controller, $action, true, $options); } + #[Override] public static function put(string $uri, string $controller, string $action, array $options = []): void { self::addRoute(HttpMethod::PUT, $uri, $controller, $action, true, $options); } + #[Override] public static function delete(string $uri, string $controller, string $action, array $options = []): void { self::addRoute(HttpMethod::DELETE, $uri, $controller, $action, true, $options); @@ -52,11 +56,13 @@ public static function options(string $uri, string $controller, string $action, self::addRoute(HttpMethod::OPTIONS, $uri, $controller, $action, true, $options); } + #[Override] public static function any(string $uri, string $controller, string $action, array $options = []): void { self::addRoute(self::$methods, $uri, $controller, $action, true, $options); } + #[Override] public static function resource(string $controller, string $uriPrefix): void { self::addResourceRoute($controller, $uriPrefix, HttpMethod::GET, '', 'index'); diff --git a/src/Ouzo/Core/Tests/ControllerTestCase.php b/src/Ouzo/Core/Tests/ControllerTestCase.php index 59467c26..79e8883a 100644 --- a/src/Ouzo/Core/Tests/ControllerTestCase.php +++ b/src/Ouzo/Core/Tests/ControllerTestCase.php @@ -32,6 +32,7 @@ abstract class ControllerTestCase extends DbTransactionalTestCase protected FrontController $frontController; protected AttributeInjectorRegistry $attributeInjectorRegistry; + #[Override] public function setUp(): void { parent::setUp(); @@ -59,6 +60,7 @@ public function setUp(): void unset($_SERVER['REMOTE_ADDR']); } + #[Override] public function tearDown(): void { parent::tearDown(); diff --git a/src/Ouzo/Core/Tests/DbTransactionalTestCase.php b/src/Ouzo/Core/Tests/DbTransactionalTestCase.php index ecbeb810..e2f1452d 100644 --- a/src/Ouzo/Core/Tests/DbTransactionalTestCase.php +++ b/src/Ouzo/Core/Tests/DbTransactionalTestCase.php @@ -12,6 +12,7 @@ abstract class DbTransactionalTestCase extends TestCase { + #[Override] public function setUp(): void { Cache::clear(); @@ -21,6 +22,7 @@ public function setUp(): void } } + #[Override] public function tearDown(): void { Cache::clear(); diff --git a/src/Ouzo/Core/Tests/MockCookiesSetter.php b/src/Ouzo/Core/Tests/MockCookiesSetter.php index e5dcd607..6deb8ea5 100644 --- a/src/Ouzo/Core/Tests/MockCookiesSetter.php +++ b/src/Ouzo/Core/Tests/MockCookiesSetter.php @@ -12,6 +12,7 @@ class MockCookiesSetter extends CookiesSetter { private array $cookies = []; + #[Override] public function setCookies(array $cookies): void { $this->cookies = $cookies; diff --git a/src/Ouzo/Core/Tests/MockDownloadHandler.php b/src/Ouzo/Core/Tests/MockDownloadHandler.php index bd571ebf..208f7b95 100644 --- a/src/Ouzo/Core/Tests/MockDownloadHandler.php +++ b/src/Ouzo/Core/Tests/MockDownloadHandler.php @@ -13,11 +13,13 @@ class MockDownloadHandler extends DownloadHandler { private array $fileData = []; + #[Override] public function downloadFile(array $fileData): void { $this->fileData = $fileData; } + #[Override] public function streamMediaFile(array $fileData): void { $this->fileData = $fileData; diff --git a/src/Ouzo/Core/Tests/MockHeaderSender.php b/src/Ouzo/Core/Tests/MockHeaderSender.php index b7d0a3ae..bb293930 100644 --- a/src/Ouzo/Core/Tests/MockHeaderSender.php +++ b/src/Ouzo/Core/Tests/MockHeaderSender.php @@ -12,6 +12,7 @@ class MockHeaderSender extends HeaderSender { private array $headers; + #[Override] public function send(array $headers): void { $this->headers = $headers; diff --git a/src/Ouzo/Core/Tests/MockOutputRenderer.php b/src/Ouzo/Core/Tests/MockOutputRenderer.php index c11d4f93..9d6ec9c0 100644 --- a/src/Ouzo/Core/Tests/MockOutputRenderer.php +++ b/src/Ouzo/Core/Tests/MockOutputRenderer.php @@ -10,6 +10,7 @@ class MockOutputRenderer extends OutputRenderer { + #[Override] public function display(string $content): void { echo ''; diff --git a/src/Ouzo/Core/Tests/MockRedirectHandler.php b/src/Ouzo/Core/Tests/MockRedirectHandler.php index c0234d26..e2f9bffb 100644 --- a/src/Ouzo/Core/Tests/MockRedirectHandler.php +++ b/src/Ouzo/Core/Tests/MockRedirectHandler.php @@ -12,6 +12,7 @@ class MockRedirectHandler extends RedirectHandler { private string $location; + #[Override] public function redirect(string $url): void { $this->location = $url; diff --git a/src/Ouzo/Core/Tests/MockSessionInitializer.php b/src/Ouzo/Core/Tests/MockSessionInitializer.php index 5379967c..031e9887 100644 --- a/src/Ouzo/Core/Tests/MockSessionInitializer.php +++ b/src/Ouzo/Core/Tests/MockSessionInitializer.php @@ -10,6 +10,7 @@ class MockSessionInitializer extends SessionInitializer { + #[Override] public function startSession(): void { $_SESSION = isset($_SESSION) ? $_SESSION : []; diff --git a/src/Ouzo/Core/Tests/MockSessionStarterInterceptor.php b/src/Ouzo/Core/Tests/MockSessionStarterInterceptor.php index d947f8fb..3fad5747 100644 --- a/src/Ouzo/Core/Tests/MockSessionStarterInterceptor.php +++ b/src/Ouzo/Core/Tests/MockSessionStarterInterceptor.php @@ -11,6 +11,7 @@ class MockSessionStarterInterceptor implements Interceptor { + #[Override] public function handle(mixed $param, Chain $next): mixed { $mockSessionInitializer = new MockSessionInitializer(); diff --git a/src/Ouzo/Core/Tests/ModelAttributesMatcher.php b/src/Ouzo/Core/Tests/ModelAttributesMatcher.php index 27c79fd4..39f13372 100644 --- a/src/Ouzo/Core/Tests/ModelAttributesMatcher.php +++ b/src/Ouzo/Core/Tests/ModelAttributesMatcher.php @@ -21,6 +21,7 @@ public function __construct(Model $expected) $this->expectedAttributes = Arrays::filterByAllowedKeys($this->expected->attributes(), $this->expected->getFields()); } + #[Override] public function matches(mixed $argument): bool { if (get_class($this->expected) !== get_class($argument)) { @@ -30,6 +31,7 @@ public function matches(mixed $argument): bool return $this->expectedAttributes == $actualAttributes; } + #[Override] public function __toString(): string { $attributes = print_r($this->expectedAttributes, true); diff --git a/src/Ouzo/Core/Tools/Model/Template/Dialect/MySqlDialect.php b/src/Ouzo/Core/Tools/Model/Template/Dialect/MySqlDialect.php index e1e2c3f8..92606a3a 100644 --- a/src/Ouzo/Core/Tools/Model/Template/Dialect/MySqlDialect.php +++ b/src/Ouzo/Core/Tools/Model/Template/Dialect/MySqlDialect.php @@ -12,11 +12,13 @@ class MySqlDialect extends Dialect { + #[Override] public function primaryKey(): string { return $this->getPrimaryKey($this->tableName()); } + #[Override] public function columns(): array { return array_values($this->getTableColumns($this->tableName())); diff --git a/src/Ouzo/Core/Tools/Model/Template/Dialect/PostgresDialect.php b/src/Ouzo/Core/Tools/Model/Template/Dialect/PostgresDialect.php index dd00b7b9..d5552df9 100644 --- a/src/Ouzo/Core/Tools/Model/Template/Dialect/PostgresDialect.php +++ b/src/Ouzo/Core/Tools/Model/Template/Dialect/PostgresDialect.php @@ -12,17 +12,20 @@ class PostgresDialect extends Dialect { + #[Override] public function primaryKey(): string { return $this->getPrimaryKey($this->tableName()); } + #[Override] public function sequence(): string { $tableColumns = $this->getTableColumns($this->tableName()); return $this->getSequenceName($tableColumns, $this->primaryKey()); } + #[Override] public function columns(): array { return array_values($this->getTableColumns($this->tableName())); diff --git a/src/Ouzo/Core/Uri/PathProvider.php b/src/Ouzo/Core/Uri/PathProvider.php index 557fd9e0..040667a9 100644 --- a/src/Ouzo/Core/Uri/PathProvider.php +++ b/src/Ouzo/Core/Uri/PathProvider.php @@ -10,6 +10,7 @@ class PathProvider implements PathProviderInterface { + #[Override] public function getPath(): string { $uri = Arrays::getValue($_SERVER, 'REDIRECT_URL'); diff --git a/src/Ouzo/Core/View/DefaultViewNameProvider.php b/src/Ouzo/Core/View/DefaultViewNameProvider.php index 8016a077..c71744a0 100644 --- a/src/Ouzo/Core/View/DefaultViewNameProvider.php +++ b/src/Ouzo/Core/View/DefaultViewNameProvider.php @@ -11,6 +11,7 @@ class DefaultViewNameProvider implements ViewNameProvider { + #[Override] function getViewName(RouteRule $rule, ?string $action): string { $controllerName = $rule->getControllerName(); diff --git a/src/Ouzo/Core/View/DefaultViewPathProvider.php b/src/Ouzo/Core/View/DefaultViewPathProvider.php index 47d455b2..e8b839d5 100644 --- a/src/Ouzo/Core/View/DefaultViewPathProvider.php +++ b/src/Ouzo/Core/View/DefaultViewPathProvider.php @@ -11,6 +11,7 @@ class DefaultViewPathProvider implements ViewPathProvider { + #[Override] function getViewPath(string $viewName, string $extension): string { return Path::join(ROOT_PATH, ApplicationPaths::getViewPath(), $viewName . $extension); diff --git a/src/Ouzo/Core/View/PhtmlRenderer.php b/src/Ouzo/Core/View/PhtmlRenderer.php index 27eb658d..d0d754a8 100644 --- a/src/Ouzo/Core/View/PhtmlRenderer.php +++ b/src/Ouzo/Core/View/PhtmlRenderer.php @@ -26,6 +26,7 @@ public function __construct( $this->viewPath = $this->viewPathProvider->getViewPath($this->viewName, self::EXTENSION); } + #[Override] public function render(): string { ob_start(); @@ -68,6 +69,7 @@ public function __isset(string $name): bool return isset($this->attributes[$name]); } + #[Override] public function getViewPath(): string { return $this->viewPath; diff --git a/src/Ouzo/Core/View/TwigRenderer.php b/src/Ouzo/Core/View/TwigRenderer.php index 2e301504..95ccb14c 100644 --- a/src/Ouzo/Core/View/TwigRenderer.php +++ b/src/Ouzo/Core/View/TwigRenderer.php @@ -27,6 +27,7 @@ public function __construct(private string $viewName, private array $attributes) $this->viewPath = Path::join($this->loaderPath, $this->viewFilename); } + #[Override] public function render(): string { $options = Config::getValue('twig', 'options') ?: []; @@ -38,6 +39,7 @@ public function render(): string return $template->render($this->attributes); } + #[Override] public function getViewPath(): string { return $this->viewPath; diff --git a/src/Ouzo/Goodies/Tests/Mock/AndArgumentMatcher.php b/src/Ouzo/Goodies/Tests/Mock/AndArgumentMatcher.php index 45863a3c..d0f273c4 100644 --- a/src/Ouzo/Goodies/Tests/Mock/AndArgumentMatcher.php +++ b/src/Ouzo/Goodies/Tests/Mock/AndArgumentMatcher.php @@ -19,11 +19,13 @@ public function __construct(array $matchers) $this->matchers = $matchers; } + #[Override] public function matches(mixed $argument): bool { return Arrays::all($this->matchers, Functions::extract()->matches($argument)); } + #[Override] public function __toString(): string { return implode(' and ', $this->matchers); diff --git a/src/Ouzo/Goodies/Tests/Mock/AnyArgument.php b/src/Ouzo/Goodies/Tests/Mock/AnyArgument.php index 71c7797e..b4723852 100644 --- a/src/Ouzo/Goodies/Tests/Mock/AnyArgument.php +++ b/src/Ouzo/Goodies/Tests/Mock/AnyArgument.php @@ -7,11 +7,13 @@ class AnyArgument implements ArgumentMatcher { + #[Override] public function __toString(): string { return "any"; } + #[Override] public function matches(mixed $argument): bool { return true; diff --git a/src/Ouzo/Goodies/Tests/Mock/AnyArgumentList.php b/src/Ouzo/Goodies/Tests/Mock/AnyArgumentList.php index 723e8a69..b064ceff 100644 --- a/src/Ouzo/Goodies/Tests/Mock/AnyArgumentList.php +++ b/src/Ouzo/Goodies/Tests/Mock/AnyArgumentList.php @@ -8,6 +8,7 @@ class AnyArgumentList { + #[Override] public function __toString(): string { return "any arguments"; diff --git a/src/Ouzo/Goodies/Tests/Mock/FluentArgumentMatcher.php b/src/Ouzo/Goodies/Tests/Mock/FluentArgumentMatcher.php index 0122560a..d88efc46 100644 --- a/src/Ouzo/Goodies/Tests/Mock/FluentArgumentMatcher.php +++ b/src/Ouzo/Goodies/Tests/Mock/FluentArgumentMatcher.php @@ -13,11 +13,13 @@ class FluentArgumentMatcher extends FluentFunction implements ArgumentMatcher { private string $description = 'argThat()'; + #[Override] public function matches(mixed $argument): mixed { return Functions::call($this, $argument); } + #[Override] public function __call(string $name, array $arguments): static { parent::__call($name, $arguments); @@ -26,6 +28,7 @@ public function __call(string $name, array $arguments): static return $this; } + #[Override] public function __toString(): string { return $this->description; diff --git a/src/Ouzo/Goodies/Tests/Mock/MethodCall.php b/src/Ouzo/Goodies/Tests/Mock/MethodCall.php index 7a83321f..9ab3aeac 100644 --- a/src/Ouzo/Goodies/Tests/Mock/MethodCall.php +++ b/src/Ouzo/Goodies/Tests/Mock/MethodCall.php @@ -27,6 +27,7 @@ public function toString(): string return $this->name . '(' . Joiner::on(', ')->join(Arrays::map($this->arguments, Functions::toString())) . ')'; } + #[Override] public function __toString(): string { return $this->toString(); diff --git a/src/Ouzo/Goodies/Tests/Mock/NotCalledVerifier.php b/src/Ouzo/Goodies/Tests/Mock/NotCalledVerifier.php index 84735681..f2b92950 100644 --- a/src/Ouzo/Goodies/Tests/Mock/NotCalledVerifier.php +++ b/src/Ouzo/Goodies/Tests/Mock/NotCalledVerifier.php @@ -10,6 +10,7 @@ class NotCalledVerifier extends Verifier { + #[Override] public function __call(string $name, array $arguments): NotCalledVerifier { if (!$this->wasCalled($name, $arguments)) { diff --git a/src/Ouzo/Goodies/Tests/Mock/ReceivedTimesCallVerifier.php b/src/Ouzo/Goodies/Tests/Mock/ReceivedTimesCallVerifier.php index d61d01e5..f2bf3b75 100644 --- a/src/Ouzo/Goodies/Tests/Mock/ReceivedTimesCallVerifier.php +++ b/src/Ouzo/Goodies/Tests/Mock/ReceivedTimesCallVerifier.php @@ -12,12 +12,14 @@ class ReceivedTimesCallVerifier extends Verifier { private int $times; + #[Override] public function __construct(SimpleMock $mock, int $times) { parent::__construct($mock); $this->times = $times; } + #[Override] public function __call(string $name, array $arguments): ReceivedTimesCallVerifier { if ($this->numberOfActualCalls($name, $arguments) === $this->times) { diff --git a/src/Ouzo/Goodies/Utilities/Chain/ChainHandler.php b/src/Ouzo/Goodies/Utilities/Chain/ChainHandler.php index a671f902..6d58fe05 100644 --- a/src/Ouzo/Goodies/Utilities/Chain/ChainHandler.php +++ b/src/Ouzo/Goodies/Utilities/Chain/ChainHandler.php @@ -12,6 +12,7 @@ public function __construct(private Chain $next, private Interceptor $intercepto { } + #[Override] public function proceed(mixed $param): mixed { return $this->interceptor->handle($param, $this->next); diff --git a/src/Ouzo/Goodies/Utilities/Chain/EndChain.php b/src/Ouzo/Goodies/Utilities/Chain/EndChain.php index 38592b95..301c0055 100644 --- a/src/Ouzo/Goodies/Utilities/Chain/EndChain.php +++ b/src/Ouzo/Goodies/Utilities/Chain/EndChain.php @@ -10,6 +10,7 @@ class EndChain implements Chain { + #[Override] public function proceed(mixed $param): Chain { return new EndChain(); diff --git a/src/Ouzo/Goodies/Utilities/Chain/InvocationChain.php b/src/Ouzo/Goodies/Utilities/Chain/InvocationChain.php index 3169bd22..c03c3390 100644 --- a/src/Ouzo/Goodies/Utilities/Chain/InvocationChain.php +++ b/src/Ouzo/Goodies/Utilities/Chain/InvocationChain.php @@ -14,6 +14,7 @@ public function __construct(private Closure $invocation) { } + #[Override] public function proceed(mixed $param): mixed { $invocation = $this->invocation; diff --git a/src/Ouzo/Goodies/Utilities/Extractor.php b/src/Ouzo/Goodies/Utilities/Extractor.php index 6e3613b3..e4c43c8c 100644 --- a/src/Ouzo/Goodies/Utilities/Extractor.php +++ b/src/Ouzo/Goodies/Utilities/Extractor.php @@ -43,22 +43,26 @@ public function __invoke(mixed $input): mixed return $input; } + #[Override] public function offsetGet(mixed $offset): static { $this->operations[] = fn($input) => isset($input[$offset]) ? $input[$offset] : null; return $this; } + #[Override] public function offsetExists(mixed $offset): bool { throw new BadMethodCallException(); } + #[Override] public function offsetSet(mixed $offset, mixed $value): void { throw new BadMethodCallException(); } + #[Override] public function offsetUnset(mixed $offset): void { throw new BadMethodCallException(); diff --git a/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php index 627d09db..36cb4b89 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/BatchingIterator.php @@ -25,12 +25,14 @@ public function __construct(Iterator $iterator, int $chunkSize, int $options = 0 $this->preserveKeys = $options && self::OPTION_PRESERVER_KEYS; } + #[Override] public function rewind(): void { $this->position = 0; $this->iterator->rewind(); } + #[Override] public function valid(): bool { if (!isset($this->currentChunk)) { @@ -39,16 +41,19 @@ public function valid(): bool return !empty($this->currentChunk); } + #[Override] public function key(): int { return $this->position; } + #[Override] public function current(): array { return $this->currentChunk; } + #[Override] public function next(): void { $this->position++; diff --git a/src/Ouzo/Goodies/Utilities/Iterator/FilteringIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/FilteringIterator.php index f7cbf319..a84b09e5 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/FilteringIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/FilteringIterator.php @@ -20,12 +20,14 @@ class FilteringIterator extends FilterIterator { private Closure $predicate; + #[Override] public function __construct(Iterator $iterator, callable $predicate) { parent::__construct($iterator); $this->predicate = Closure::fromCallable($predicate); } + #[Override] public function accept(): bool { $predicate = $this->predicate; diff --git a/src/Ouzo/Goodies/Utilities/Iterator/ForwardingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/ForwardingIterator.php index 9f38025b..b7901688 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/ForwardingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/ForwardingIterator.php @@ -14,26 +14,31 @@ public function __construct(protected Iterator $iterator) { } + #[Override] public function current(): mixed { return $this->iterator->current(); } + #[Override] public function next(): void { $this->iterator->next(); } + #[Override] public function key(): mixed { return $this->iterator->key(); } + #[Override] public function valid(): bool { return $this->iterator->valid(); } + #[Override] public function rewind(): void { $this->iterator->rewind(); diff --git a/src/Ouzo/Goodies/Utilities/Iterator/GeneratingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/GeneratingIterator.php index 8910e515..24d6f453 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/GeneratingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/GeneratingIterator.php @@ -21,6 +21,7 @@ public function __construct(callable $function) $this->function = Closure::fromCallable($function); } + #[Override] public function current(): mixed { if (!$this->initialized) { @@ -30,22 +31,26 @@ public function current(): mixed return $this->current; } + #[Override] public function valid(): bool { return true; } + #[Override] public function key(): int { return $this->index; } + #[Override] public function next(): void { $this->index++; $this->generate(); } + #[Override] public function rewind(): void { $this->index = 0; diff --git a/src/Ouzo/Goodies/Utilities/Iterator/ReindexingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/ReindexingIterator.php index e956e9b8..e364548c 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/ReindexingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/ReindexingIterator.php @@ -10,17 +10,20 @@ class ReindexingIterator extends ForwardingIterator { private int $index; + #[Override] public function key(): int { return $this->index; } + #[Override] public function next(): void { parent::next(); $this->index++; } + #[Override] public function rewind(): void { parent::rewind(); diff --git a/src/Ouzo/Goodies/Utilities/Iterator/SkippingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/SkippingIterator.php index bd5f151a..7fa770c1 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/SkippingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/SkippingIterator.php @@ -12,11 +12,13 @@ class SkippingIterator extends ForwardingIterator { private bool $skipped = false; + #[Override] public function __construct(Iterator $iterator, private int $skipCount) { parent::__construct($iterator); } + #[Override] public function valid(): bool { if (!$this->skipped) { @@ -28,6 +30,7 @@ public function valid(): bool return parent::valid(); } + #[Override] public function rewind(): void { $this->skipped = false; diff --git a/src/Ouzo/Goodies/Utilities/Iterator/TransformingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/TransformingIterator.php index 9f178807..b8873d22 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/TransformingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/TransformingIterator.php @@ -13,12 +13,14 @@ class TransformingIterator extends ForwardingIterator { private Closure $function; + #[Override] public function __construct(Iterator $iterator, callable $function) { parent::__construct($iterator); $this->function = Closure::fromCallable($function); } + #[Override] public function current(): mixed { return call_user_func($this->function, $this->iterator->current()); diff --git a/src/Ouzo/Goodies/Utilities/Iterator/UnbatchingIterator.php b/src/Ouzo/Goodies/Utilities/Iterator/UnbatchingIterator.php index a4d1d18c..274b0643 100644 --- a/src/Ouzo/Goodies/Utilities/Iterator/UnbatchingIterator.php +++ b/src/Ouzo/Goodies/Utilities/Iterator/UnbatchingIterator.php @@ -18,12 +18,14 @@ public function __construct(private Iterator $iterator) { } + #[Override] public function current(): mixed { $this->initializeChunkIterator(); return $this->chunkIterator->current(); } + #[Override] public function next(): void { $this->initializeChunkIterator(); @@ -38,17 +40,20 @@ public function next(): void } } + #[Override] public function key(): int { return $this->position; } + #[Override] public function valid(): bool { $this->initializeChunkIterator(); return $this->chunkIterator->valid(); } + #[Override] public function rewind(): void { $this->position = 0; diff --git a/src/Ouzo/Goodies/Utilities/JsonDecodeException.php b/src/Ouzo/Goodies/Utilities/JsonDecodeException.php index 8d899b8c..99b2cd9b 100644 --- a/src/Ouzo/Goodies/Utilities/JsonDecodeException.php +++ b/src/Ouzo/Goodies/Utilities/JsonDecodeException.php @@ -10,6 +10,7 @@ class JsonDecodeException extends Exception { + #[Override] public function __construct(string $lastErrorMessage = '', int $lastErrorCode = 0) { parent::__construct("JSON decode error: {$lastErrorMessage}", $lastErrorCode); diff --git a/src/Ouzo/Goodies/Utilities/JsonEncodeException.php b/src/Ouzo/Goodies/Utilities/JsonEncodeException.php index a58d801b..41f5cdd2 100644 --- a/src/Ouzo/Goodies/Utilities/JsonEncodeException.php +++ b/src/Ouzo/Goodies/Utilities/JsonEncodeException.php @@ -7,6 +7,7 @@ class JsonEncodeException extends \Exception { + #[Override] public function __construct(string $lastErrorMessage = '', int $lastErrorCode = 0) { parent::__construct("JSON encode error: {$lastErrorMessage}", $lastErrorCode); diff --git a/src/Ouzo/Goodies/Utilities/NonCallableExtractor.php b/src/Ouzo/Goodies/Utilities/NonCallableExtractor.php index e9e261be..566fa7c1 100644 --- a/src/Ouzo/Goodies/Utilities/NonCallableExtractor.php +++ b/src/Ouzo/Goodies/Utilities/NonCallableExtractor.php @@ -31,22 +31,26 @@ public function __call(string $name, mixed $arguments): Extractor return $this->extractor; } + #[Override] public function offsetGet(mixed $offset): Extractor { $this->extractor->offsetGet($offset); return $this->extractor; } + #[Override] public function offsetExists(mixed $offset): bool { throw new BadMethodCallException(); } + #[Override] public function offsetSet(mixed $offset, mixed $value): void { throw new BadMethodCallException(); } + #[Override] public function offsetUnset(mixed $offset): void { throw new BadMethodCallException(); diff --git a/src/Ouzo/Goodies/Utilities/Supplier/ExpiringMemoizingSupplier.php b/src/Ouzo/Goodies/Utilities/Supplier/ExpiringMemoizingSupplier.php index 343fb1b4..d0d3f703 100644 --- a/src/Ouzo/Goodies/Utilities/Supplier/ExpiringMemoizingSupplier.php +++ b/src/Ouzo/Goodies/Utilities/Supplier/ExpiringMemoizingSupplier.php @@ -20,6 +20,7 @@ public function __construct(callable $function, private int $expireTime = 3600) $this->function = Closure::fromCallable($function); } + #[Override] public function get(): mixed { $function = $this->function; diff --git a/src/Ouzo/Goodies/Utilities/Supplier/MemoizingSupplier.php b/src/Ouzo/Goodies/Utilities/Supplier/MemoizingSupplier.php index e3250d6a..e1a72349 100644 --- a/src/Ouzo/Goodies/Utilities/Supplier/MemoizingSupplier.php +++ b/src/Ouzo/Goodies/Utilities/Supplier/MemoizingSupplier.php @@ -19,6 +19,7 @@ public function __construct(callable $function) $this->function = Closure::fromCallable($function); } + #[Override] public function get(): mixed { if (!$this->invoked) { diff --git a/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php b/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php index 8d587037..184cc131 100644 --- a/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php +++ b/src/Ouzo/Goodies/Utilities/Time/TimeUnit.php @@ -122,6 +122,7 @@ private function convertToNanos(int $sourceDuration, string $sourceTimeUnit): in }; } + #[Override] public function __toString(): string { return $this->timeUnit; diff --git a/src/Ouzo/Inject/Injection/Annotation/InjectAttributeInjector.php b/src/Ouzo/Inject/Injection/Annotation/InjectAttributeInjector.php index 99770487..c3bbb87b 100644 --- a/src/Ouzo/Inject/Injection/Annotation/InjectAttributeInjector.php +++ b/src/Ouzo/Inject/Injection/Annotation/InjectAttributeInjector.php @@ -24,6 +24,7 @@ public function __construct( } /** @param ReflectionProperty[] $reflectionProperties */ + #[Override] public function injectForProperties(object $instance, array $reflectionProperties, InstanceFactory $instanceFactory): void { foreach ($reflectionProperties as $reflectionProperty) { @@ -49,6 +50,7 @@ public function injectForProperties(object $instance, array $reflectionPropertie } } + #[Override] public function injectForConstructorParameter(ReflectionMethod $constructor, InstanceFactory $instanceFactory): array { $constructorParameters = []; diff --git a/src/Ouzo/Inject/Injection/Annotation/InjectListAttributeInjector.php b/src/Ouzo/Inject/Injection/Annotation/InjectListAttributeInjector.php index 56c6608e..35ddd03e 100644 --- a/src/Ouzo/Inject/Injection/Annotation/InjectListAttributeInjector.php +++ b/src/Ouzo/Inject/Injection/Annotation/InjectListAttributeInjector.php @@ -23,6 +23,7 @@ public function __construct( } /** @param ReflectionProperty[] $reflectionProperties */ + #[Override] public function injectForProperties(object $instance, array $reflectionProperties, InstanceFactory $instanceFactory): void { foreach ($reflectionProperties as $reflectionProperty) { @@ -43,6 +44,7 @@ public function injectForProperties(object $instance, array $reflectionPropertie } } + #[Override] public function injectForConstructorParameter(ReflectionMethod $constructor, InstanceFactory $instanceFactory): array { $constructorParameters = []; diff --git a/src/Ouzo/Inject/Injection/Creator/EagerInstanceCreator.php b/src/Ouzo/Inject/Injection/Creator/EagerInstanceCreator.php index 376727a3..258e06b4 100644 --- a/src/Ouzo/Inject/Injection/Creator/EagerInstanceCreator.php +++ b/src/Ouzo/Inject/Injection/Creator/EagerInstanceCreator.php @@ -13,6 +13,7 @@ class EagerInstanceCreator implements InstanceCreator { + #[Override] public function create(string $className, ?array $arguments, InstanceRepository $repository, InstanceFactory $instanceFactory): object { if (!empty($arguments)) { @@ -23,6 +24,7 @@ public function create(string $className, ?array $arguments, InstanceRepository return new $className(); } + #[Override] public function createThroughFactory(string $className, ?array $arguments, InstanceRepository $repository, InstanceFactory $instanceFactory, Factory $factory): object { return $factory->create(); diff --git a/src/Ouzo/Inject/Injection/Creator/ProxyManagerInstanceCreator.php b/src/Ouzo/Inject/Injection/Creator/ProxyManagerInstanceCreator.php index 06c68a5e..903ceb01 100644 --- a/src/Ouzo/Inject/Injection/Creator/ProxyManagerInstanceCreator.php +++ b/src/Ouzo/Inject/Injection/Creator/ProxyManagerInstanceCreator.php @@ -22,6 +22,7 @@ public function __construct(Configuration $configuration) $this->factory = new LazyLoadingValueHolderFactory($configuration); } + #[Override] public function create(string $className, ?array $arguments, InstanceRepository $repository, InstanceFactory $instanceFactory): object { return $this->factory->createProxy( @@ -34,6 +35,7 @@ function (&$wrappedObject, LazyLoadingInterface $proxy, $method, array $paramete ); } + #[Override] public function createThroughFactory(string $className, ?array $arguments, InstanceRepository $repository, InstanceFactory $instanceFactory, Factory $factory): object { return $this->factory->createProxy( diff --git a/src/Ouzo/Migrations/Migration/MigrationCommand.php b/src/Ouzo/Migrations/Migration/MigrationCommand.php index fe833f9e..c1da9a27 100644 --- a/src/Ouzo/Migrations/Migration/MigrationCommand.php +++ b/src/Ouzo/Migrations/Migration/MigrationCommand.php @@ -21,6 +21,7 @@ abstract class MigrationCommand extends Command public const string LOG_STDOUT_ARGUMENT = 'log-stdout'; + #[Override] protected function configure() { $this->addOption('db_name', 'N', InputOption::VALUE_REQUIRED, 'Database name') @@ -34,6 +35,7 @@ protected function configure() $this->configureCommand(); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output) : int { if ($input->getOption(self::LOG_STDOUT_ARGUMENT)) { diff --git a/src/Ouzo/Migrations/Migration/MigrationDbConfig.php b/src/Ouzo/Migrations/Migration/MigrationDbConfig.php index cfbff56a..625cf5db 100644 --- a/src/Ouzo/Migrations/Migration/MigrationDbConfig.php +++ b/src/Ouzo/Migrations/Migration/MigrationDbConfig.php @@ -44,6 +44,7 @@ public function getDbName(): string return $this->dbConfig['dbname']; } + #[Override] public function __toString(): string { return Objects::toString($this->dbConfig); diff --git a/src/Ouzo/Migrations/Migration/MigrationFailedException.php b/src/Ouzo/Migrations/Migration/MigrationFailedException.php index d921320e..f4b8775d 100644 --- a/src/Ouzo/Migrations/Migration/MigrationFailedException.php +++ b/src/Ouzo/Migrations/Migration/MigrationFailedException.php @@ -16,6 +16,7 @@ class MigrationFailedException extends Exception private $className; private $version; + #[Override] public function __construct(Throwable $throwable, $className, $version) { parent::__construct($throwable->getMessage(), $throwable->getCode(), $throwable); diff --git a/src/Ouzo/Migrations/Migration/SchemaMigration.php b/src/Ouzo/Migrations/Migration/SchemaMigration.php index 5d876f24..ccfc8455 100644 --- a/src/Ouzo/Migrations/Migration/SchemaMigration.php +++ b/src/Ouzo/Migrations/Migration/SchemaMigration.php @@ -12,6 +12,7 @@ class SchemaMigration extends Model { public static $db; + #[Override] public function __construct($attributes = []) { parent::__construct([