From 8fe536fb538a084f3ecb3cab9085a36335c0f5ae Mon Sep 17 00:00:00 2001 From: bota Date: Wed, 12 Aug 2026 13:44:14 +0300 Subject: [PATCH] Issue #535: Added class constant type declarations Signed-off-by: bota --- phpcs.xml | 1 + src/App/src/InputFilter/Input/EmailInput.php | 2 +- .../src/InputFilter/Input/FirstNameInput.php | 2 +- .../src/InputFilter/Input/IdentityInput.php | 4 +- .../src/InputFilter/Input/LastNameInput.php | 2 +- .../src/InputFilter/Input/PasswordInput.php | 4 +- .../ContentNegotiationMiddleware.php | 2 +- .../src/Middleware/DeprecationMiddleware.php | 2 +- src/App/src/Service/ErrorReportService.php | 2 +- .../src/DBAL/Types/AdminRoleEnumType.php | 2 +- .../src/DBAL/Types/AdminStatusEnumType.php | 2 +- src/Core/src/App/src/ConfigProvider.php | 3 +- .../src/DBAL/Types/SuccessFailureEnumType.php | 2 +- src/Core/src/App/src/DBAL/Types/UuidType.php | 2 +- .../src/App/src/DBAL/Types/YesNoEnumType.php | 2 +- src/Core/src/App/src/Message.php | 120 +++++++++--------- .../DBAL/Types/SettingIdentifierEnumType.php | 2 +- .../Types/UserResetPasswordStatusEnumType.php | 2 +- .../User/src/DBAL/Types/UserRoleEnumType.php | 2 +- .../src/DBAL/Types/UserStatusEnumType.php | 2 +- src/User/src/Service/UserAvatarService.php | 2 +- test/Functional/AbstractFunctionalTest.php | 2 +- 22 files changed, 84 insertions(+), 82 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index f257552..6af8b9f 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -24,4 +24,5 @@ src/Core/src/App/src/Migration/* + diff --git a/src/App/src/InputFilter/Input/EmailInput.php b/src/App/src/InputFilter/Input/EmailInput.php index b62c62d..8768b40 100644 --- a/src/App/src/InputFilter/Input/EmailInput.php +++ b/src/App/src/InputFilter/Input/EmailInput.php @@ -14,7 +14,7 @@ class EmailInput extends Input { - public const EMAIL_MAX_LENGTH = 191; + public const int EMAIL_MAX_LENGTH = 191; public function __construct(?string $name = null, bool $isRequired = true) { diff --git a/src/App/src/InputFilter/Input/FirstNameInput.php b/src/App/src/InputFilter/Input/FirstNameInput.php index 29323a8..52f559f 100644 --- a/src/App/src/InputFilter/Input/FirstNameInput.php +++ b/src/App/src/InputFilter/Input/FirstNameInput.php @@ -13,7 +13,7 @@ class FirstNameInput extends Input { - public const FIRSTNAME_MAX_LENGTH = 191; + public const int FIRSTNAME_MAX_LENGTH = 191; public function __construct(?string $name = null, bool $isRequired = true) { diff --git a/src/App/src/InputFilter/Input/IdentityInput.php b/src/App/src/InputFilter/Input/IdentityInput.php index c4ac066..148f88c 100644 --- a/src/App/src/InputFilter/Input/IdentityInput.php +++ b/src/App/src/InputFilter/Input/IdentityInput.php @@ -13,8 +13,8 @@ class IdentityInput extends Input { - public const IDENTITY_MIN_LENGTH = 3; - public const IDENTITY_MAX_LENGTH = 100; + public const int IDENTITY_MIN_LENGTH = 3; + public const int IDENTITY_MAX_LENGTH = 100; public function __construct(?string $name = null, bool $isRequired = true) { diff --git a/src/App/src/InputFilter/Input/LastNameInput.php b/src/App/src/InputFilter/Input/LastNameInput.php index c94b45e..9192295 100644 --- a/src/App/src/InputFilter/Input/LastNameInput.php +++ b/src/App/src/InputFilter/Input/LastNameInput.php @@ -13,7 +13,7 @@ class LastNameInput extends Input { - public const LASTNAME_MAX_LENGTH = 191; + public const int LASTNAME_MAX_LENGTH = 191; public function __construct(?string $name = null, bool $isRequired = true) { diff --git a/src/App/src/InputFilter/Input/PasswordInput.php b/src/App/src/InputFilter/Input/PasswordInput.php index 0dc1dde..f37792a 100644 --- a/src/App/src/InputFilter/Input/PasswordInput.php +++ b/src/App/src/InputFilter/Input/PasswordInput.php @@ -13,8 +13,8 @@ class PasswordInput extends Input { - public const PASSWORD_MIN_LENGTH = 8; - public const PASSWORD_MAX_LENGTH = 150; + public const int PASSWORD_MIN_LENGTH = 8; + public const int PASSWORD_MAX_LENGTH = 150; public function __construct(?string $name = null, bool $isRequired = true) { diff --git a/src/App/src/Middleware/ContentNegotiationMiddleware.php b/src/App/src/Middleware/ContentNegotiationMiddleware.php index 6bacef5..39590bc 100644 --- a/src/App/src/Middleware/ContentNegotiationMiddleware.php +++ b/src/App/src/Middleware/ContentNegotiationMiddleware.php @@ -31,7 +31,7 @@ class ContentNegotiationMiddleware implements MiddlewareInterface { - public const DEFAULT_HEADERS = 'default'; + public const string DEFAULT_HEADERS = 'default'; /** * @param array $config diff --git a/src/App/src/Middleware/DeprecationMiddleware.php b/src/App/src/Middleware/DeprecationMiddleware.php index 48710a6..1ae0018 100644 --- a/src/App/src/Middleware/DeprecationMiddleware.php +++ b/src/App/src/Middleware/DeprecationMiddleware.php @@ -25,7 +25,7 @@ class DeprecationMiddleware implements MiddlewareInterface { - public const RESOURCE_DEPRECATION_ATTRIBUTE = ResourceDeprecation::class; + public const string RESOURCE_DEPRECATION_ATTRIBUTE = ResourceDeprecation::class; /** * @param array $config diff --git a/src/App/src/Service/ErrorReportService.php b/src/App/src/Service/ErrorReportService.php index bc0a8b3..6734607 100644 --- a/src/App/src/Service/ErrorReportService.php +++ b/src/App/src/Service/ErrorReportService.php @@ -27,7 +27,7 @@ class ErrorReportService implements ErrorReportServiceInterface { - private const HEADER_NAME = 'Error-Reporting-Token'; + private const string HEADER_NAME = 'Error-Reporting-Token'; private Filesystem $fileSystem; private ?string $token = null; diff --git a/src/Core/src/Admin/src/DBAL/Types/AdminRoleEnumType.php b/src/Core/src/Admin/src/DBAL/Types/AdminRoleEnumType.php index 046535d..1db5858 100644 --- a/src/Core/src/Admin/src/DBAL/Types/AdminRoleEnumType.php +++ b/src/Core/src/Admin/src/DBAL/Types/AdminRoleEnumType.php @@ -9,7 +9,7 @@ class AdminRoleEnumType extends AbstractEnumType { - public const NAME = 'admin_role_enum'; + public const string NAME = 'admin_role_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/Admin/src/DBAL/Types/AdminStatusEnumType.php b/src/Core/src/Admin/src/DBAL/Types/AdminStatusEnumType.php index 613c074..110fb48 100644 --- a/src/Core/src/Admin/src/DBAL/Types/AdminStatusEnumType.php +++ b/src/Core/src/Admin/src/DBAL/Types/AdminStatusEnumType.php @@ -9,7 +9,7 @@ class AdminStatusEnumType extends AbstractEnumType { - public const NAME = 'admin_status_enum'; + public const string NAME = 'admin_status_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/App/src/ConfigProvider.php b/src/Core/src/App/src/ConfigProvider.php index e19f4bf..1733330 100644 --- a/src/Core/src/App/src/ConfigProvider.php +++ b/src/Core/src/App/src/ConfigProvider.php @@ -93,7 +93,8 @@ */ class ConfigProvider { - public const REGEXP_UUID = '{id:[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}}'; + public const string REGEXP_UUID = + '{id:[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}}'; /** * @return ConfigType diff --git a/src/Core/src/App/src/DBAL/Types/SuccessFailureEnumType.php b/src/Core/src/App/src/DBAL/Types/SuccessFailureEnumType.php index 4a90283..49ad00a 100644 --- a/src/Core/src/App/src/DBAL/Types/SuccessFailureEnumType.php +++ b/src/Core/src/App/src/DBAL/Types/SuccessFailureEnumType.php @@ -8,7 +8,7 @@ class SuccessFailureEnumType extends AbstractEnumType { - public const NAME = 'success_failure_enum'; + public const string NAME = 'success_failure_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/App/src/DBAL/Types/UuidType.php b/src/Core/src/App/src/DBAL/Types/UuidType.php index 852e1d2..e0f968e 100644 --- a/src/Core/src/App/src/DBAL/Types/UuidType.php +++ b/src/Core/src/App/src/DBAL/Types/UuidType.php @@ -8,7 +8,7 @@ class UuidType extends \Ramsey\Uuid\Doctrine\UuidType { - public const NAME = 'uuid'; + public const string NAME = 'uuid'; public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { diff --git a/src/Core/src/App/src/DBAL/Types/YesNoEnumType.php b/src/Core/src/App/src/DBAL/Types/YesNoEnumType.php index 8bafeb0..753e2ff 100644 --- a/src/Core/src/App/src/DBAL/Types/YesNoEnumType.php +++ b/src/Core/src/App/src/DBAL/Types/YesNoEnumType.php @@ -8,7 +8,7 @@ class YesNoEnumType extends AbstractEnumType { - public const NAME = 'yes_no_enum'; + public const string NAME = 'yes_no_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/App/src/Message.php b/src/Core/src/App/src/Message.php index 2a46c21..4a7bc14 100644 --- a/src/Core/src/App/src/Message.php +++ b/src/Core/src/App/src/Message.php @@ -10,68 +10,68 @@ class Message { - public const ACCOUNT_UPDATED = 'Your account was updated successfully.'; - public const ADMIN_CONFIRM_DELETION = 'Please confirm the admin deletion.'; - public const ADMIN_CREATED = 'Admin created successfully.'; - public const ADMIN_DELETED = 'Admin deleted successfully'; - public const ADMIN_INACTIVE = 'Admin account is inactive.'; - public const ADMIN_NOT_FOUND = 'Admin not found.'; - public const ADMIN_UPDATED = 'Admin updated successfully.'; - public const AN_ERROR_OCCURRED = 'An error occurred, please try again later.'; - public const DUPLICATE_EMAIL = 'An account with this email address already exists.'; - public const DUPLICATE_IDENTITY = 'An account with this identity already exists.'; - public const ERROR_REPORT_OK = 'Error report successfully saved.'; - public const ERROR_REPORT_NOT_ALLOWED = 'You are not allowed to report errors.'; - public const ERROR_REPORT_NOT_ENABLED = 'Remote error reporting is not enabled.'; - public const INVALID_CLIENT_ID = 'Invalid client_id.'; - public const INVALID_CONFIG = 'Invalid configuration value: "%s"'; - public const INVALID_CSRF = 'Invalid CSRF.'; - public const INVALID_CURRENT_PASSWORD = 'Current password is incorrect.'; - public const INVALID_VALUE = 'The value specified for "%s" is invalid.'; - public const MAIL_NOT_SENT_TO = 'Could not send mail to "%s".'; - public const MAIL_SENT_RECOVER_IDENTITY = 'If the provided email identifies an account in our system, ' + public const string ACCOUNT_UPDATED = 'Your account was updated successfully.'; + public const string ADMIN_CONFIRM_DELETION = 'Please confirm the admin deletion.'; + public const string ADMIN_CREATED = 'Admin created successfully.'; + public const string ADMIN_DELETED = 'Admin deleted successfully'; + public const string ADMIN_INACTIVE = 'Admin account is inactive.'; + public const string ADMIN_NOT_FOUND = 'Admin not found.'; + public const string ADMIN_UPDATED = 'Admin updated successfully.'; + public const string AN_ERROR_OCCURRED = 'An error occurred, please try again later.'; + public const string DUPLICATE_EMAIL = 'An account with this email address already exists.'; + public const string DUPLICATE_IDENTITY = 'An account with this identity already exists.'; + public const string ERROR_REPORT_OK = 'Error report successfully saved.'; + public const string ERROR_REPORT_NOT_ALLOWED = 'You are not allowed to report errors.'; + public const string ERROR_REPORT_NOT_ENABLED = 'Remote error reporting is not enabled.'; + public const string INVALID_CLIENT_ID = 'Invalid client_id.'; + public const string INVALID_CONFIG = 'Invalid configuration value: "%s"'; + public const string INVALID_CSRF = 'Invalid CSRF.'; + public const string INVALID_CURRENT_PASSWORD = 'Current password is incorrect.'; + public const string INVALID_VALUE = 'The value specified for "%s" is invalid.'; + public const string MAIL_NOT_SENT_TO = 'Could not send mail to "%s".'; + public const string MAIL_SENT_RECOVER_IDENTITY = 'If the provided email identifies an account in our system, ' . 'you will receive an email with your account\'s identity.'; - public const MAIL_SENT_RESET_PASSWORD = 'If the provided email identifies an account in our system, ' + public const string MAIL_SENT_RESET_PASSWORD = 'If the provided email identifies an account in our system, ' . 'you will receive an email with further instructions on resetting your account\'s password.'; - public const MAIL_SENT_USER_ACTIVATION = 'User activation mail has been successfully sent to "%s"'; - public const MISSING_CONFIG = 'Missing configuration value: "%s".'; - public const NOT_ACCEPTABLE = 'Not acceptable.'; - public const RESET_PASSWORD_EXPIRED = 'Reset password hash is invalid (expired).'; - public const RESET_PASSWORD_NOT_FOUND = 'Reset password request not found.'; - public const RESET_PASSWORD_OK = 'Password successfully modified.'; - public const RESET_PASSWORD_USED = 'Reset password hash is invalid (used).'; - public const RESET_PASSWORD_VALID = 'Reset password hash is valid.'; - public const RESOURCE_ALREADY_REGISTERED = 'Resource "%s" is already registered.'; - public const RESOURCE_NOT_ALLOWED = 'You are not allowed to access this resource.'; - public const RESOURCE_NOT_FOUND = '%s not found.'; - public const RESTRICTION_IMAGE = 'File must be an image> Accepted mim type(s): %s'; - public const RESTRICTION_ROLES = 'At least one role is required.'; - public const ROLE_NOT_FOUND = 'Role not found.'; - public const SERVICE_NOT_FOUND = 'Service %s not found in the container.'; - public const SETTING_NOT_FOUND = 'Setting "%s" not found.'; - public const TEMPLATE_NOT_FOUND = 'Template "%s" not found.'; - public const UNSUPPORTED_MEDIA_TYPE = 'Unsupported Media Type.'; - public const USER_ACTIVATED = 'User account has been activated.'; - public const USER_ALREADY_ACTIVATED = 'User account is already active.'; - public const USER_ALREADY_DEACTIVATED = 'User account is already inactive.'; - public const USER_AVATAR_MISSING = 'User avatar not found.'; - public const USER_AVATAR_UPDATED = 'User avatar updated successfully.'; - public const USER_CONFIRM_DELETION = 'Please confirm the user deletion.'; - public const USER_CREATED = 'User created successfully.'; - public const USER_DEACTIVATED = 'User account has been deactivated.'; - public const USER_DELETED = 'User account deleted successfully.'; - public const USER_NOT_ACTIVATED = 'User account must be activated first.'; - public const USER_NOT_FOUND = 'User not found.'; - public const USER_UPDATED = 'User updated successfully.'; - public const VALIDATOR_INVALID_CHARACTERS = 'The value specified contains invalid characters.'; - public const VALIDATOR_INVALID_DATA = 'The submitted request contains invalid data.'; - public const VALIDATOR_INVALID_EMAIL = 'The value specified must be a valid email address.'; - public const VALIDATOR_LENGTH_MAX = 'The value specified must have at most %d characters.'; - public const VALIDATOR_LENGTH_MIN = 'The value specified must have at least %d characters.'; - public const VALIDATOR_LENGTH_MIN_MAX = 'The value specified must have between %d and %d characters.'; - public const VALIDATOR_MISMATCH = '"%s" and "%s" do not match.'; - public const VALIDATOR_REQUIRED_FIELD = 'This field is required and cannot be empty.'; - public const VALIDATOR_REQUIRED_UPLOAD = 'A file must be uploaded first.'; + public const string MAIL_SENT_USER_ACTIVATION = 'User activation mail has been successfully sent to "%s"'; + public const string MISSING_CONFIG = 'Missing configuration value: "%s".'; + public const string NOT_ACCEPTABLE = 'Not acceptable.'; + public const string RESET_PASSWORD_EXPIRED = 'Reset password hash is invalid (expired).'; + public const string RESET_PASSWORD_NOT_FOUND = 'Reset password request not found.'; + public const string RESET_PASSWORD_OK = 'Password successfully modified.'; + public const string RESET_PASSWORD_USED = 'Reset password hash is invalid (used).'; + public const string RESET_PASSWORD_VALID = 'Reset password hash is valid.'; + public const string RESOURCE_ALREADY_REGISTERED = 'Resource "%s" is already registered.'; + public const string RESOURCE_NOT_ALLOWED = 'You are not allowed to access this resource.'; + public const string RESOURCE_NOT_FOUND = '%s not found.'; + public const string RESTRICTION_IMAGE = 'File must be an image> Accepted mim type(s): %s'; + public const string RESTRICTION_ROLES = 'At least one role is required.'; + public const string ROLE_NOT_FOUND = 'Role not found.'; + public const string SERVICE_NOT_FOUND = 'Service %s not found in the container.'; + public const string SETTING_NOT_FOUND = 'Setting "%s" not found.'; + public const string TEMPLATE_NOT_FOUND = 'Template "%s" not found.'; + public const string UNSUPPORTED_MEDIA_TYPE = 'Unsupported Media Type.'; + public const string USER_ACTIVATED = 'User account has been activated.'; + public const string USER_ALREADY_ACTIVATED = 'User account is already active.'; + public const string USER_ALREADY_DEACTIVATED = 'User account is already inactive.'; + public const string USER_AVATAR_MISSING = 'User avatar not found.'; + public const string USER_AVATAR_UPDATED = 'User avatar updated successfully.'; + public const string USER_CONFIRM_DELETION = 'Please confirm the user deletion.'; + public const string USER_CREATED = 'User created successfully.'; + public const string USER_DEACTIVATED = 'User account has been deactivated.'; + public const string USER_DELETED = 'User account deleted successfully.'; + public const string USER_NOT_ACTIVATED = 'User account must be activated first.'; + public const string USER_NOT_FOUND = 'User not found.'; + public const string USER_UPDATED = 'User updated successfully.'; + public const string VALIDATOR_INVALID_CHARACTERS = 'The value specified contains invalid characters.'; + public const string VALIDATOR_INVALID_DATA = 'The submitted request contains invalid data.'; + public const string VALIDATOR_INVALID_EMAIL = 'The value specified must be a valid email address.'; + public const string VALIDATOR_LENGTH_MAX = 'The value specified must have at most %d characters.'; + public const string VALIDATOR_LENGTH_MIN = 'The value specified must have at least %d characters.'; + public const string VALIDATOR_LENGTH_MIN_MAX = 'The value specified must have between %d and %d characters.'; + public const string VALIDATOR_MISMATCH = '"%s" and "%s" do not match.'; + public const string VALIDATOR_REQUIRED_FIELD = 'This field is required and cannot be empty.'; + public const string VALIDATOR_REQUIRED_UPLOAD = 'A file must be uploaded first.'; /** * @return non-empty-string diff --git a/src/Core/src/Setting/src/DBAL/Types/SettingIdentifierEnumType.php b/src/Core/src/Setting/src/DBAL/Types/SettingIdentifierEnumType.php index d0edf7c..240ec61 100644 --- a/src/Core/src/Setting/src/DBAL/Types/SettingIdentifierEnumType.php +++ b/src/Core/src/Setting/src/DBAL/Types/SettingIdentifierEnumType.php @@ -9,7 +9,7 @@ class SettingIdentifierEnumType extends AbstractEnumType { - public const NAME = 'setting_enum'; + public const string NAME = 'setting_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/User/src/DBAL/Types/UserResetPasswordStatusEnumType.php b/src/Core/src/User/src/DBAL/Types/UserResetPasswordStatusEnumType.php index 55cf851..4623e48 100644 --- a/src/Core/src/User/src/DBAL/Types/UserResetPasswordStatusEnumType.php +++ b/src/Core/src/User/src/DBAL/Types/UserResetPasswordStatusEnumType.php @@ -9,7 +9,7 @@ class UserResetPasswordStatusEnumType extends AbstractEnumType { - public const NAME = 'user_reset_password_status_enum'; + public const string NAME = 'user_reset_password_status_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/User/src/DBAL/Types/UserRoleEnumType.php b/src/Core/src/User/src/DBAL/Types/UserRoleEnumType.php index 6025cab..3878280 100644 --- a/src/Core/src/User/src/DBAL/Types/UserRoleEnumType.php +++ b/src/Core/src/User/src/DBAL/Types/UserRoleEnumType.php @@ -9,7 +9,7 @@ class UserRoleEnumType extends AbstractEnumType { - public const NAME = 'user_role_enum'; + public const string NAME = 'user_role_enum'; public function getEnumClass(): string { diff --git a/src/Core/src/User/src/DBAL/Types/UserStatusEnumType.php b/src/Core/src/User/src/DBAL/Types/UserStatusEnumType.php index 7629839..ea6cad1 100644 --- a/src/Core/src/User/src/DBAL/Types/UserStatusEnumType.php +++ b/src/Core/src/User/src/DBAL/Types/UserStatusEnumType.php @@ -9,7 +9,7 @@ class UserStatusEnumType extends AbstractEnumType { - public const NAME = 'user_status_enum'; + public const string NAME = 'user_status_enum'; public function getEnumClass(): string { diff --git a/src/User/src/Service/UserAvatarService.php b/src/User/src/Service/UserAvatarService.php index 3662db7..69f3c7b 100644 --- a/src/User/src/Service/UserAvatarService.php +++ b/src/User/src/Service/UserAvatarService.php @@ -24,7 +24,7 @@ class UserAvatarService implements UserAvatarServiceInterface { - public const EXTENSIONS = [ + public const array EXTENSIONS = [ 'image/jpg' => 'jpg', 'image/jpeg' => 'jpg', 'image/png' => 'png', diff --git a/test/Functional/AbstractFunctionalTest.php b/test/Functional/AbstractFunctionalTest.php index 6086451..d6e3202 100644 --- a/test/Functional/AbstractFunctionalTest.php +++ b/test/Functional/AbstractFunctionalTest.php @@ -45,7 +45,7 @@ class AbstractFunctionalTest extends TestCase protected Application $app; protected ContainerInterface $container; - protected const DEFAULT_PASSWORD = 'dotkernel'; + protected const string DEFAULT_PASSWORD = 'dotkernel'; /** * @throws NotFoundExceptionInterface