From a708f018c174e39481a28a5aa25ece2be69a1f66 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 14 Jun 2023 11:17:37 +0000
Subject: [PATCH] Add parameter/property type hints
---
src/HolidaySkipper.php | 12 +++++++-----
src/UcrmHelper.php | 14 +++++++-------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/HolidaySkipper.php b/src/HolidaySkipper.php
index 2035e3f..a621bc3 100644
--- a/src/HolidaySkipper.php
+++ b/src/HolidaySkipper.php
@@ -8,15 +8,15 @@
use Umulmrum\Holiday\Model\HolidayList;
class HolidaySkipper {
- protected $helper;
- protected $skipDays = null;
- protected $holidays = null;
+ protected UcrmHelper $helper;
+ protected ?array $skipDays = null;
+ protected ?HolidayList $holidays = null;
function __construct(UcrmHelper $ucrmHelper) {
$this->helper = $ucrmHelper;
}
- protected function configure(array $years) {
+ protected function configure(array $years): void {
$config = $this->helper->getConfig();
if ($this->skipDays === NULL) {
@@ -39,7 +39,7 @@
}
}
- function processInvoice(string $invoiceId) {
+ function processInvoice(string $invoiceId): bool {
$crm = $this->helper->getApi();
$invoiceData = $crm->get('/invoices/' . $invoiceId);
if ($invoiceData['status'] != 0) {
@@ -71,5 +71,7 @@
} else {
echo 'Invoice ' . $invoiceId . ': nothing to do' . "\n";
}
+
+ return $changed > 0;
}
}
diff --git a/src/UcrmHelper.php b/src/UcrmHelper.php
index 2bde977..0c35cdc 100644
--- a/src/UcrmHelper.php
+++ b/src/UcrmHelper.php
@@ -3,9 +3,9 @@
namespace SIPL\UCRM\Holidays;
class UcrmHelper {
- protected $rootDirectory;
- protected $api = NULL;
- protected $config = NULL;
+ protected string $rootDirectory;
+ protected ?\Ubnt\UcrmPluginSdk\Service\UcrmApi $api = NULL;
+ protected ?array $config = NULL;
protected $event = NULL;
function __construct(?string $rootDirectory = NULL) {
@@ -15,18 +15,18 @@
$this->rootDirectory = $rootDirectory;
}
- function getRootDirectory() {
+ function getRootDirectory(): string {
return $this->rootDirectory;
}
- function getApi() {
+ function getApi(): \Ubnt\UcrmPluginSdk\Service\UcrmApi {
if ($this->api === NULL) {
$this->api = \Ubnt\UcrmPluginSdk\Service\UcrmApi::create($this->rootDirectory);
}
return $this->api;
}
- function getConfig() {
+ function getConfig(): array {
if ($this->config === NULL) {
$configManager = \Ubnt\UcrmPluginSdk\Service\PluginConfigManager::create($this->rootDirectory);
$this->config = $configManager->loadConfig();
@@ -34,7 +34,7 @@
return $this->config;
}
- function getCurrentEvent() {
+ function getCurrentEvent(): array {
if ($this->event === NULL) {
try {
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
--
Gitblit v1.10.0