From 4dafae6ba4e01515996264785a3c131f785987fa Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Fri, 25 Aug 2023 11:17:54 +0200 Subject: [PATCH] Fix "Creation of dynamic property module_name is deprecated" (#749) --- .../user/controllers/admin/Providers.php | 5 +- .../modules/user/mappers/AuthProvider.php | 7 +- .../user/models/AuthProviderModule.php | 92 ++++++++++++---- application/modules/user/models/Provider.php | 100 ++++++++++++------ .../user/views/admin/providers/index.php | 2 +- 5 files changed, 145 insertions(+), 61 deletions(-) diff --git a/application/modules/user/controllers/admin/Providers.php b/application/modules/user/controllers/admin/Providers.php index c5fac271a..64694b04a 100644 --- a/application/modules/user/controllers/admin/Providers.php +++ b/application/modules/user/controllers/admin/Providers.php @@ -1,14 +1,15 @@ db()->delete('auth_providers', ['key' => $key])->execute(); - $provider_users = $this->db()->delete('users_auth_providers', ['provider' => $key])->execute(); + $this->db()->delete('users_auth_providers', ['provider' => $key])->execute(); return $provider === 1; } diff --git a/application/modules/user/models/AuthProviderModule.php b/application/modules/user/models/AuthProviderModule.php index e57ac1fbb..e40616f9f 100644 --- a/application/modules/user/models/AuthProviderModule.php +++ b/application/modules/user/models/AuthProviderModule.php @@ -8,23 +8,69 @@ class AuthProviderModule extends \Ilch\Model { + /** + * @var string + */ + protected $name; + + /** + * @var string + */ protected $provider; + + /** + * @var string + */ protected $module; + + /** + * @var string + */ protected $auth_controller; + + /** + * @var string + */ protected $auth_action; + + /** + * @var string + */ protected $unlink_controller; + + /** + * @var string + */ protected $unlink_action; public function __construct() { } + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + * @return AuthProviderModule + */ + public function setName(string $name): AuthProviderModule + { + $this->name = $name; + return $this; + } + /** * Gets the value of provider. * - * @return mixed + * @return string */ - public function getProvider() + public function getProvider(): string { return $this->provider; } @@ -32,11 +78,11 @@ public function getProvider() /** * Sets the value of provider. * - * @param mixed $provider the provider + * @param string $provider the provider * * @return self */ - public function setProvider($provider) + public function setProvider(string $provider): AuthProviderModule { $this->provider = $provider; @@ -46,9 +92,9 @@ public function setProvider($provider) /** * Gets the value of module. * - * @return mixed + * @return string */ - public function getModule() + public function getModule(): string { return $this->module; } @@ -60,7 +106,7 @@ public function getModule() * * @return self */ - public function setModule($module) + public function setModule($module): AuthProviderModule { $this->module = $module; @@ -70,9 +116,9 @@ public function setModule($module) /** * Gets the value of auth_controller. * - * @return mixed + * @return string */ - public function getAuthController() + public function getAuthController(): string { return $this->auth_controller; } @@ -80,11 +126,11 @@ public function getAuthController() /** * Sets the value of auth_controller. * - * @param mixed $auth_controller the auth controller + * @param string $auth_controller the auth controller * * @return self */ - public function setAuthController($auth_controller) + public function setAuthController(string $auth_controller): AuthProviderModule { $this->auth_controller = $auth_controller; @@ -94,9 +140,9 @@ public function setAuthController($auth_controller) /** * Gets the value of auth_action. * - * @return mixed + * @return string */ - public function getAuthAction() + public function getAuthAction(): string { return $this->auth_action; } @@ -104,11 +150,11 @@ public function getAuthAction() /** * Sets the value of auth_action. * - * @param mixed $auth_action the auth action + * @param string $auth_action the auth action * * @return self */ - public function setAuthAction($auth_action) + public function setAuthAction(string $auth_action): AuthProviderModule { $this->auth_action = $auth_action; @@ -118,9 +164,9 @@ public function setAuthAction($auth_action) /** * Gets the value of unlink_controller. * - * @return mixed + * @return string */ - public function getUnlinkController() + public function getUnlinkController(): string { return $this->unlink_controller; } @@ -128,11 +174,11 @@ public function getUnlinkController() /** * Sets the value of unlink_controller. * - * @param mixed $unlink_controller the unlink controller + * @param string $unlink_controller the unlink controller * * @return self */ - public function setUnlinkController($unlink_controller) + public function setUnlinkController(string $unlink_controller): AuthProviderModule { $this->unlink_controller = $unlink_controller; @@ -142,9 +188,9 @@ public function setUnlinkController($unlink_controller) /** * Gets the value of unlink_action. * - * @return mixed + * @return string */ - public function getUnlinkAction() + public function getUnlinkAction(): string { return $this->unlink_action; } @@ -152,11 +198,11 @@ public function getUnlinkAction() /** * Sets the value of unlink_action. * - * @param mixed $unlink_action the unlink action + * @param string $unlink_action the unlink action * * @return self */ - public function setUnlinkAction($unlink_action) + public function setUnlinkAction(string $unlink_action): AuthProviderModule { $this->unlink_action = $unlink_action; diff --git a/application/modules/user/models/Provider.php b/application/modules/user/models/Provider.php index 0e8d641b9..363e27b48 100644 --- a/application/modules/user/models/Provider.php +++ b/application/modules/user/models/Provider.php @@ -1,6 +1,6 @@ key; } @@ -73,7 +87,7 @@ public function getKey() * * @return self */ - protected function setKey($key) + protected function setKey($key): Provider { $this->key = $key; @@ -83,9 +97,9 @@ protected function setKey($key) /** * Gets the Human readable name. * - * @return mixed + * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -93,11 +107,11 @@ public function getName() /** * Sets the Human readable name. * - * @param mixed $name the name + * @param string $name the name * * @return self */ - protected function setName($name) + protected function setName(string $name): Provider { $this->name = $name; @@ -107,9 +121,9 @@ protected function setName($name) /** * Gets the Font-awesome icon. * - * @return mixed + * @return string */ - public function getIcon() + public function getIcon(): string { return $this->icon; } @@ -117,11 +131,11 @@ public function getIcon() /** * Sets the Font-awesome icon. * - * @param mixed $icon the icon + * @param string $icon the icon * * @return self */ - protected function setIcon($icon) + protected function setIcon(string $icon): Provider { $this->icon = $icon; @@ -131,9 +145,9 @@ protected function setIcon($icon) /** * Gets the Module providing the auth functionality of this provider. * - * @return mixed + * @return string|null */ - public function getModule() + public function getModule(): ?string { return $this->module; } @@ -141,11 +155,11 @@ public function getModule() /** * Sets the Module providing the auth functionality of this provider. * - * @param mixed $module the module + * @param string $module the module * * @return self */ - protected function setModule($module) + protected function setModule(string $module): Provider { $this->module = $module; @@ -155,9 +169,9 @@ protected function setModule($module) /** * Gets the value of auth_controller. * - * @return mixed + * @return string|null */ - public function getAuthController() + public function getAuthController(): ?string { return $this->auth_controller; } @@ -165,11 +179,11 @@ public function getAuthController() /** * Sets the value of auth_controller. * - * @param mixed $auth_controller the auth controller + * @param string $auth_controller the auth controller * * @return self */ - protected function setAuthController($auth_controller) + protected function setAuthController(string $auth_controller): Provider { $this->auth_controller = $auth_controller; @@ -179,9 +193,9 @@ protected function setAuthController($auth_controller) /** * Gets the value of auth_action. * - * @return mixed + * @return string|null */ - public function getAuthAction() + public function getAuthAction(): ?string { return $this->auth_action; } @@ -189,11 +203,11 @@ public function getAuthAction() /** * Sets the value of auth_action. * - * @param mixed $auth_action the auth action + * @param string $auth_action the auth action * * @return self */ - protected function setAuthAction($auth_action) + protected function setAuthAction(string $auth_action): Provider { $this->auth_action = $auth_action; @@ -203,9 +217,9 @@ protected function setAuthAction($auth_action) /** * Gets the value of unlink_controller. * - * @return mixed + * @return string|null */ - public function getUnlinkController() + public function getUnlinkController(): ?string { return $this->unlink_controller; } @@ -213,11 +227,11 @@ public function getUnlinkController() /** * Sets the value of unlink_controller. * - * @param mixed $unlink_controller the unlink controller + * @param string $unlink_controller the unlink controller * * @return self */ - protected function setUnlinkController($unlink_controller) + protected function setUnlinkController(string $unlink_controller): Provider { $this->unlink_controller = $unlink_controller; @@ -227,9 +241,9 @@ protected function setUnlinkController($unlink_controller) /** * Gets the value of unlink_action. * - * @return mixed + * @return string|null */ - public function getUnlinkAction() + public function getUnlinkAction(): ?string { return $this->unlink_action; } @@ -237,14 +251,36 @@ public function getUnlinkAction() /** * Sets the value of unlink_action. * - * @param mixed $unlink_action the unlink action + * @param string $unlink_action the unlink action * * @return self */ - protected function setUnlinkAction($unlink_action) + protected function setUnlinkAction(string $unlink_action): Provider { $this->unlink_action = $unlink_action; return $this; } + + /** + * Get the localised module name. + * + * @return string|null + */ + public function getModuleName(): ?string + { + return $this->module_name; + } + + /** + * Set the localised module name. + * + * @param string $module_name + * @return Provider + */ + protected function setModuleName(string $module_name): Provider + { + $this->module_name = $module_name; + return $this; + } } diff --git a/application/modules/user/views/admin/providers/index.php b/application/modules/user/views/admin/providers/index.php index 8098e998d..03bcf6940 100644 --- a/application/modules/user/views/admin/providers/index.php +++ b/application/modules/user/views/admin/providers/index.php @@ -29,7 +29,7 @@ - escape($provider->module_name) ?> (getModule() ?>) + escape($provider->getModuleName()) ?> (getModule() ?>)