Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_antivirus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-03-21 21:16:19 +0300
committerRobin Appelman <robin@icewind.nl>2022-04-13 15:21:12 +0300
commit28fa3e8976b507d175a4bfda52494a61abbb4bdb (patch)
tree07c0ded22c513aef516feb19da0d1d97b9567a33
parent1823ab0316fd75a09bef6959a775ef47d48be530 (diff)
typings for AppConfig
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/AppConfig.php33
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/AppConfig.php b/lib/AppConfig.php
index 7657e60..8e8f2a8 100644
--- a/lib/AppConfig.php
+++ b/lib/AppConfig.php
@@ -28,15 +28,15 @@ use OCP\IConfig;
* @method null setAvChunkSize(int $chunkSize)
* @method null setAvPath(string $avPath)
* @method null setAvInfectedAction(string $avInfectedAction)
+ * @method null setAvIcapScanBackground(string $scanBackground)
+ * @method null setAvIcapRequestService($reqService)
* @method null setAvStreamMaxLength(int $length)
*/
class AppConfig {
- private $appName = 'files_antivirus';
+ private string $appName = 'files_antivirus';
+ private IConfig $config;
- /** @var IConfig */
- private $config;
-
- private $defaults = [
+ private array $defaults = [
'av_mode' => 'executable',
'av_socket' => '/var/run/clamav/clamd.ctl',
'av_host' => '',
@@ -58,7 +58,7 @@ class AppConfig {
$this->config = $config;
}
- public function getAvChunkSize() {
+ public function getAvChunkSize(): int {
// See http://php.net/manual/en/function.stream-wrapper-register.php#74765
// and \OC_Helper::streamCopy
return 8192;
@@ -72,7 +72,7 @@ class AppConfig {
* Get full commandline
* @return string
*/
- public function getCmdline() {
+ public function getCmdline(): string {
$avCmdOptions = $this->getAvCmdOptions();
$shellArgs = [];
@@ -96,7 +96,7 @@ class AppConfig {
* Get all setting values as an array
* @return array
*/
- public function getAllValues() {
+ public function getAllValues(): array {
$keys = array_keys($this->defaults);
$values = array_map([$this, 'getAppValue'], $keys);
$preparedKeys = array_map([$this, 'camelCase'], $keys);
@@ -108,7 +108,7 @@ class AppConfig {
* @param string $key
* @return string
*/
- public function getAppValue($key) {
+ public function getAppValue(string $key): string {
$defaultValue = null;
if (array_key_exists($key, $this->defaults)) {
$defaultValue = $this->defaults[$key];
@@ -121,7 +121,7 @@ class AppConfig {
* @param string $key
* @param string $value
*/
- public function setAppValue($key, $value) {
+ public function setAppValue(string $key, string $value) {
$this->config->setAppValue($this->appName, $key, $value);
}
@@ -131,7 +131,7 @@ class AppConfig {
* @param array $args
* @throws \BadFunctionCallException
*/
- protected function setter($key, $args) {
+ protected function setter(string $key, array $args) {
if (array_key_exists($key, $this->defaults)) {
$this->setAppValue($key, $args[0]);
} else {
@@ -145,7 +145,7 @@ class AppConfig {
* @return string
* @throws \BadFunctionCallException
*/
- protected function getter($key) {
+ protected function getter(string $key): string {
if (array_key_exists($key, $this->defaults)) {
return $this->getAppValue($key);
}
@@ -158,7 +158,7 @@ class AppConfig {
* @param string $property
* @return string
*/
- protected function camelCase($property) {
+ protected function camelCase(string $property): string {
$split = explode('_', $property);
$ucFirst = implode('', array_map('ucfirst', $split));
return lcfirst($ucFirst);
@@ -169,7 +169,7 @@ class AppConfig {
* @param string $property
* @return string
*/
- protected function propertyToKey($property) {
+ protected function propertyToKey(string $property): string {
$parts = preg_split('/(?=[A-Z])/', $property);
$column = null;
@@ -186,12 +186,13 @@ class AppConfig {
/**
* Get/set an option value by calling getSomeOption method
+ *
* @param string $methodName
* @param array $args
- * @return string|null
+ * @return string|void
* @throws \BadFunctionCallException
*/
- public function __call($methodName, $args) {
+ public function __call(string $methodName, array $args) {
$attr = lcfirst(substr($methodName, 3));
$key = $this->propertyToKey($attr);
if (strpos($methodName, 'set') === 0) {