diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-10-17 00:55:48 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-10-17 10:58:27 +0200 |
commit | c94f9f5e5f41b197dcbfbdc3526b8c5e6198d786 (patch) | |
tree | d06ce53b1c897dee2e0f74e42bc6cb7d416638d7 /apps/files_external/lib/Lib/FrontendDefinitionTrait.php | |
parent | 2d75321c2360fb20bf3705ef0b6c82ab320cc3ae (diff) | |
download | nextcloud-server-c94f9f5e5f41b197dcbfbdc3526b8c5e6198d786.tar.gz nextcloud-server-c94f9f5e5f41b197dcbfbdc3526b8c5e6198d786.zip |
Add corresponding interface to trait
Since we can't specify that we want a class implementing a trait yet in
PHP
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/files_external/lib/Lib/FrontendDefinitionTrait.php')
-rw-r--r-- | apps/files_external/lib/Lib/FrontendDefinitionTrait.php | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/apps/files_external/lib/Lib/FrontendDefinitionTrait.php b/apps/files_external/lib/Lib/FrontendDefinitionTrait.php index b10d3a0b276..6b2dc8672f3 100644 --- a/apps/files_external/lib/Lib/FrontendDefinitionTrait.php +++ b/apps/files_external/lib/Lib/FrontendDefinitionTrait.php @@ -29,62 +29,45 @@ namespace OCA\Files_External\Lib; trait FrontendDefinitionTrait { /** @var string human-readable mechanism name */ - private $text; + private string $text = ""; /** @var DefinitionParameter[] parameters for mechanism */ - private $parameters = []; + private array $parameters = []; /** @var string[] custom JS */ - private $customJs = []; + private array $customJs = []; - /** - * @return string - */ - public function getText() { + public function getText(): string { return $this->text; } - /** - * @param string $text - * @return $this - */ - public function setText($text) { + public function setText(string $text): self { $this->text = $text; return $this; } - /** - * @param FrontendDefinitionTrait $a - * @param FrontendDefinitionTrait $b - * @return int - */ - public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) { + public static function lexicalCompare(IFrontendDefinition $a, IFrontendDefinition $b): int { return strcmp($a->getText(), $b->getText()); } /** * @return DefinitionParameter[] */ - public function getParameters() { + public function getParameters(): array { return $this->parameters; } /** * @param DefinitionParameter[] $parameters - * @return self */ - public function addParameters(array $parameters) { + public function addParameters(array $parameters): self { foreach ($parameters as $parameter) { $this->addParameter($parameter); } return $this; } - /** - * @param DefinitionParameter $parameter - * @return self - */ - public function addParameter(DefinitionParameter $parameter) { + public function addParameter(DefinitionParameter $parameter): self { $this->parameters[$parameter->getName()] = $parameter; return $this; } @@ -92,7 +75,7 @@ trait FrontendDefinitionTrait { /** * @return string[] */ - public function getCustomJs() { + public function getCustomJs(): array { return $this->customJs; } @@ -100,17 +83,15 @@ trait FrontendDefinitionTrait { * @param string $custom * @return self */ - public function addCustomJs($custom) { + public function addCustomJs(string $custom): self { $this->customJs[] = $custom; return $this; } /** * Serialize into JSON for client-side JS - * - * @return array */ - public function jsonSerializeDefinition() { + public function jsonSerializeDefinition(): array { $configuration = []; foreach ($this->getParameters() as $parameter) { $configuration[$parameter->getName()] = $parameter; @@ -126,11 +107,8 @@ trait FrontendDefinitionTrait { /** * Check if parameters are satisfied in a StorageConfig - * - * @param StorageConfig $storage - * @return bool */ - public function validateStorageDefinition(StorageConfig $storage) { + public function validateStorageDefinition(StorageConfig $storage): bool { foreach ($this->getParameters() as $name => $parameter) { $value = $storage->getBackendOption($name); if (!is_null($value) || !$parameter->isOptional()) { |