git subrepo commit (merge) mailcow/src/mailcow-dockerized

subrepo: subdir:   "mailcow/src/mailcow-dockerized"
  merged:   "02ae5285"
upstream: origin:   "https://github.com/mailcow/mailcow-dockerized.git"
  branch:   "master"
  commit:   "649a5c01"
git-subrepo: version:  "0.4.3"
  origin:   "???"
  commit:   "???"
Change-Id: I870ad468fba026cc5abf3c5699ed1e12ff28b32b
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php
index 8e7806e..c346e5a 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php
@@ -2,22 +2,33 @@
 
 namespace RobThree\Auth\Providers\Time;
 
+use DateTime;
+
 /**
  * Takes the time from any webserver by doing a HEAD request on the specified URL and extracting the 'Date:' header
  */
 class HttpTimeProvider implements ITimeProvider
 {
+    /** @var string */
     public $url;
-    public $options;
+
+    /** @var string */
     public $expectedtimeformat;
 
-    function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
+    /** @var array */
+    public $options;
+
+    /**
+     * @param string $url
+     * @param string $expectedtimeformat
+     * @param array $options
+     */
+    public function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
     {
         $this->url = $url;
         $this->expectedtimeformat = $expectedtimeformat;
-        $this->options = $options;
-        if ($this->options === null) {
-            $this->options = array(
+        if ($options === null) {
+            $options = array(
                 'http' => array(
                     'method' => 'HEAD',
                     'follow_location' => false,
@@ -32,9 +43,14 @@
                 )
             );
         }
+        $this->options = $options;
     }
 
-    public function getTime() {
+    /**
+     * {@inheritdoc}
+     */
+    public function getTime()
+    {
         try {
             $context  = stream_context_create($this->options);
             $fd = fopen($this->url, 'rb', false, $context);
@@ -42,13 +58,14 @@
             fclose($fd);
 
             foreach ($headers['wrapper_data'] as $h) {
-                if (strcasecmp(substr($h, 0, 5), 'Date:') === 0)
-                    return \DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h,5)))->getTimestamp();
+                if (strcasecmp(substr($h, 0, 5), 'Date:') === 0) {
+                    return DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h, 5)))->getTimestamp();
+                }
             }
-            throw new \TimeException(sprintf('Unable to retrieve time from %s (Invalid or no "Date:" header found)', $this->url));
+            throw new \Exception('Invalid or no "Date:" header found');
+        } catch (\Exception $ex) {
+            throw new TimeException(sprintf('Unable to retrieve time from %s (%s)', $this->url, $ex->getMessage()));
         }
-        catch (Exception $ex) {
-            throw new \TimeException(sprintf('Unable to retrieve time from %s (%s)', $this->url, $ex->getMessage()));
-        }
+
     }
-}
\ No newline at end of file
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php
index a3b87a2..4799f17 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php
@@ -4,5 +4,8 @@
 
 interface ITimeProvider
 {
+    /**
+     * @return int the current timestamp according to this provider
+     */
     public function getTime();
-}
\ No newline at end of file
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php
index 572cedc..2fe6846 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php
@@ -2,8 +2,10 @@
 
 namespace RobThree\Auth\Providers\Time;
 
-class LocalMachineTimeProvider implements ITimeProvider {
-    public function getTime() {
+class LocalMachineTimeProvider implements ITimeProvider
+{
+    public function getTime()
+    {
         return time();
     }
-}
\ No newline at end of file
+}
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/NTPTimeProvider.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/NTPTimeProvider.php
index d69a3a6..a701850 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/NTPTimeProvider.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/NTPTimeProvider.php
@@ -7,24 +7,40 @@
  */
 class NTPTimeProvider implements ITimeProvider
 {
+    /** @var string */
     public $host;
+
+    /** @var int */
     public $port;
+
+    /** @var int */
     public $timeout;
 
-    function __construct($host = 'time.google.com', $port = 123, $timeout = 1)
+    /**
+     * @param string $host
+     * @param int $port
+     * @param int $timeout
+     */
+    public function __construct($host = 'time.google.com', $port = 123, $timeout = 1)
     {
         $this->host = $host;
 
-        if (!is_int($port) || $port <= 0 || $port > 65535)
-            throw new \TimeException('Port must be 0 < port < 65535');
+        if (!is_int($port) || $port <= 0 || $port > 65535) {
+            throw new TimeException('Port must be 0 < port < 65535');
+        }
         $this->port = $port;
 
-        if (!is_int($timeout) || $timeout < 0)
-            throw new \TimeException('Timeout must be >= 0');
+        if (!is_int($timeout) || $timeout < 0) {
+            throw new TimeException('Timeout must be >= 0');
+        }
         $this->timeout = $timeout;
     }
 
-    public function getTime() {
+    /**
+     * {@inheritdoc}
+     */
+    public function getTime()
+    {
         try {
             /* Create a socket and connect to NTP server */
             $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
@@ -36,19 +52,19 @@
             socket_send($sock, $msg, strlen($msg), 0);
 
             /* Receive response and close socket */
-            if (socket_recv($sock, $recv, 48, MSG_WAITALL) === false)
+            if (socket_recv($sock, $recv, 48, MSG_WAITALL) === false) {
                 throw new \Exception(socket_strerror(socket_last_error($sock)));
+            }
             socket_close($sock);
 
             /* Interpret response */
             $data = unpack('N12', $recv);
-            $timestamp = sprintf('%u', $data[9]);
+            $timestamp = (int) sprintf('%u', $data[9]);
 
             /* NTP is number of seconds since 0000 UT on 1 January 1900 Unix time is seconds since 0000 UT on 1 January 1970 */
             return $timestamp - 2208988800;
-        }
-        catch (Exception $ex) {
-            throw new \TimeException(sprintf('Unable to retrieve time from %s (%s)', $this->host, $ex->getMessage()));
+        } catch (\Exception $ex) {
+            throw new TimeException(sprintf('Unable to retrieve time from %s (%s)', $this->host, $ex->getMessage()));
         }
     }
 }
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php
index 8de544d..c5a06e2 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/lib/vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace RobThree\Auth\Providers\Time;
+
 use RobThree\Auth\TwoFactorAuthException;
 
-class TimeException extends TwoFactorAuthException {}
\ No newline at end of file
+class TimeException extends TwoFactorAuthException {}