]> source.dussan.org Git - nextcloud-server.git/commitdiff
explicit types
authorRobin Appelman <robin@icewind.nl>
Mon, 31 Oct 2016 13:38:41 +0000 (14:38 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 16 Nov 2016 14:24:29 +0000 (15:24 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Authentication/Token/DefaultToken.php
tests/lib/Authentication/Token/DefaultTokenMapperTest.php

index ecfb1a44f2e823dfc35b913ef115b1da5ca1e92d..127430ea6cbcd749206495e7ea2a304707fd2647 100644 (file)
@@ -92,6 +92,12 @@ class DefaultToken extends Entity implements IToken {
         */
        protected $scope;
 
+       public function __construct() {
+               $this->addType('type', 'int');
+               $this->addType('lastActivity', 'int');
+               $this->addType('lastCheck', 'int');
+       }
+
        public function getId() {
                return $this->id;
        }
@@ -122,8 +128,8 @@ class DefaultToken extends Entity implements IToken {
                return [
                        'id' => $this->id,
                        'name' => $this->name,
-                       'lastActivity' => (int)$this->lastActivity,
-                       'type' => (int)$this->type,
+                       'lastActivity' => $this->lastActivity,
+                       'type' => $this->type,
                        'scope' => $this->getScopeAsArray()
                ];
        }
@@ -161,10 +167,10 @@ class DefaultToken extends Entity implements IToken {
        }
 
        public function setScope($scope) {
-               if (is_string($scope)) {
-                       parent::setScope($scope);
-               } else {
+               if (is_array($scope)) {
                        parent::setScope(json_encode($scope));
+               } else {
+                       parent::setScope((string)$scope);
                }
        }
 }
index 418a4d14f624f21ffafd7b460b7a0c327d5400b2..7520b3c9f65254c4c8b2a1322a99f69b31ec377f 100644 (file)
@@ -122,7 +122,6 @@ class DefaultTokenMapperTest extends TestCase {
        }
 
        public function testGetToken() {
-               $token = '1504445f1524fc801035448a95681a9378ba2e83930c814546c56e5d6ebde221198792fd900c88ed5ead0555780dad1ebce3370d7e154941cd5de87eb419899b';
                $token = new DefaultToken();
                $token->setUid('user2');
                $token->setLoginName('User2');