Completed
Pull Request — master (#51)
by
unknown
01:31
created
src/Store/CookieStore.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use SilverStripe\Control\Cookie;
6 6
 use SilverStripe\HybridSessions\Crypto\CryptoHandler;
7
-use SilverStripe\Core\Config\Config;
8 7
 use SilverStripe\Core\Injector\Injector;
9 8
 
10 9
 /**
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     public function open($save_path, $name)
60 60
     {
61
-        $this->cookie = $name . '_2';
61
+        $this->cookie = $name.'_2';
62 62
 
63 63
         // Read the incoming value, then clear the cookie - we might not be able
64 64
         // to do so later if write() is called after headers are sent
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
         // Verify expiration
113 113
         if ($cookieData) {
114
-            $expiry = (int)substr($cookieData, 0, 10);
114
+            $expiry = (int) substr($cookieData, 0, 10);
115 115
             $data = substr($cookieData, 10);
116 116
 
117 117
             if ($expiry > $this->getNow()) {
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 
165 165
         // Restore the known good cookie value
166 166
         $this->currentCookieData = $this->crypto->encrypt(
167
-            sprintf('%010u', $expiry) . $session_data
167
+            sprintf('%010u', $expiry).$session_data
168 168
         );
169 169
 
170 170
         // Respect auto-expire on browser close for the session cookie (in case the cookie lifetime is zero)
171
-        $cookieLifetime = min((int)$params['lifetime'], $lifetime);
171
+        $cookieLifetime = min((int) $params['lifetime'], $lifetime);
172 172
 
173 173
         Cookie::set(
174 174
             $this->cookie,
Please login to merge, or discard this patch.
src/Store/BaseStore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
     protected function getLifetime()
46 46
     {
47 47
         $params = session_get_cookie_params();
48
-        $cookieLifetime = (int)$params['lifetime'];
49
-        $gcLifetime = (int)ini_get('session.gc_maxlifetime');
48
+        $cookieLifetime = (int) $params['lifetime'];
49
+        $gcLifetime = (int) ini_get('session.gc_maxlifetime');
50 50
 
51 51
         return $cookieLifetime ? min($cookieLifetime, $gcLifetime) : $gcLifetime;
52 52
     }
Please login to merge, or discard this patch.
tests/OpenSSLCryptoTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
         $handler = new OpenSSLCrypto($key, $salt);
20 20
 
21
-        for ($i=0; $i<1000; ++$i) {
21
+        for ($i = 0; $i < 1000; ++$i) {
22 22
             $data = random_bytes(1024 * 4);
23 23
 
24 24
             $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
Please login to merge, or discard this patch.
tests/McryptCryptoTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
         $handler = new McryptCrypto($key, $salt);
20 20
 
21
-        for ($i=0; $i<1000; ++$i) {
21
+        for ($i = 0; $i < 1000; ++$i) {
22 22
             $data = random_bytes(1024 * 4);
23 23
 
24 24
             $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
Please login to merge, or discard this patch.
tests/DatabaseStoreTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     public function testDataCodecIntegrity()
30 30
     {
31
-        for ($i=0; $i<1000; ++$i) {
31
+        for ($i = 0; $i < 1000; ++$i) {
32 32
             $data = random_bytes(1024 * 4);
33 33
 
34 34
             $this->assertEquals($data, DatabaseStore::binaryDataJsonDecode(DatabaseStore::binaryDataJsonEncode($data)));
Please login to merge, or discard this patch.
tests/CookieStoreTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     {
14 14
         $store = Injector::inst()->get(CookieStore::class);
15 15
         $store->setKey(uniqid());
16
-        $store->open(TempFolder::getTempFolder(BASE_PATH) . '/' . __CLASS__, 'SESSIONCOOKIE');
16
+        $store->open(TempFolder::getTempFolder(BASE_PATH).'/'.__CLASS__, 'SESSIONCOOKIE');
17 17
 
18 18
         return $store;
19 19
     }
Please login to merge, or discard this patch.
src/Crypto/McryptCrypto.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 
79 79
         $hash = hash_hmac('sha256', $enc, $this->saltedKey);
80 80
 
81
-        return base64_encode($iv . $hash . $enc);
81
+        return base64_encode($iv.$hash.$enc);
82 82
     }
83 83
 
84 84
     /**
Please login to merge, or discard this patch.
src/Crypto/OpenSSLCrypto.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,9 +64,9 @@
 block discarded – undo
64 64
         $iv = openssl_random_pseudo_bytes($ivlen);
65 65
         $ciphertext_raw = openssl_encrypt($cleartext, $cipher, $this->saltedKey, $options = OPENSSL_RAW_DATA, $iv);
66 66
         $hmac = hash_hmac('sha256', $ciphertext_raw, $this->saltedKey, $as_binary = true);
67
-        $ciphertext = base64_encode($iv . $hmac . $ciphertext_raw);
67
+        $ciphertext = base64_encode($iv.$hmac.$ciphertext_raw);
68 68
 
69
-        return base64_encode($iv . $hmac . $ciphertext_raw);
69
+        return base64_encode($iv.$hmac.$ciphertext_raw);
70 70
     }
71 71
 
72 72
     /**
Please login to merge, or discard this patch.