Completed
Pull Request — master (#5421)
by Blizzz
16:06
created
lib/private/Session/Internal.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@
 block discarded – undo
164 164
 	 * @param array $parameters
165 165
 	 * @param bool $silence whether to suppress warnings
166 166
 	 * @throws \ErrorException via trapError
167
-	 * @return mixed
167
+	 * @return string
168 168
 	 */
169 169
 	private function invoke($functionName, array $parameters = [], $silence = false) {
170 170
 		try {
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -38,143 +38,143 @@
 block discarded – undo
38 38
  * @package OC\Session
39 39
  */
40 40
 class Internal extends Session {
41
-	/**
42
-	 * @param string $name
43
-	 * @throws \Exception
44
-	 */
45
-	public function __construct($name) {
46
-		set_error_handler(array($this, 'trapError'));
47
-		$this->invoke('session_name', [$name]);
48
-		try {
49
-			$this->invoke('session_start');
50
-		} catch (\Exception $e) {
51
-			setcookie($this->invoke('session_name'), null, -1, \OC::$WEBROOT ?: '/');
52
-		}
53
-		restore_error_handler();
54
-		if (!isset($_SESSION)) {
55
-			throw new \Exception('Failed to start session');
56
-		}
57
-	}
41
+    /**
42
+     * @param string $name
43
+     * @throws \Exception
44
+     */
45
+    public function __construct($name) {
46
+        set_error_handler(array($this, 'trapError'));
47
+        $this->invoke('session_name', [$name]);
48
+        try {
49
+            $this->invoke('session_start');
50
+        } catch (\Exception $e) {
51
+            setcookie($this->invoke('session_name'), null, -1, \OC::$WEBROOT ?: '/');
52
+        }
53
+        restore_error_handler();
54
+        if (!isset($_SESSION)) {
55
+            throw new \Exception('Failed to start session');
56
+        }
57
+    }
58 58
 
59
-	/**
60
-	 * @param string $key
61
-	 * @param integer $value
62
-	 */
63
-	public function set($key, $value) {
64
-		$this->validateSession();
65
-		$_SESSION[$key] = $value;
66
-	}
59
+    /**
60
+     * @param string $key
61
+     * @param integer $value
62
+     */
63
+    public function set($key, $value) {
64
+        $this->validateSession();
65
+        $_SESSION[$key] = $value;
66
+    }
67 67
 
68
-	/**
69
-	 * @param string $key
70
-	 * @return mixed
71
-	 */
72
-	public function get($key) {
73
-		if (!$this->exists($key)) {
74
-			return null;
75
-		}
76
-		return $_SESSION[$key];
77
-	}
68
+    /**
69
+     * @param string $key
70
+     * @return mixed
71
+     */
72
+    public function get($key) {
73
+        if (!$this->exists($key)) {
74
+            return null;
75
+        }
76
+        return $_SESSION[$key];
77
+    }
78 78
 
79
-	/**
80
-	 * @param string $key
81
-	 * @return bool
82
-	 */
83
-	public function exists($key) {
84
-		return isset($_SESSION[$key]);
85
-	}
79
+    /**
80
+     * @param string $key
81
+     * @return bool
82
+     */
83
+    public function exists($key) {
84
+        return isset($_SESSION[$key]);
85
+    }
86 86
 
87
-	/**
88
-	 * @param string $key
89
-	 */
90
-	public function remove($key) {
91
-		if (isset($_SESSION[$key])) {
92
-			unset($_SESSION[$key]);
93
-		}
94
-	}
87
+    /**
88
+     * @param string $key
89
+     */
90
+    public function remove($key) {
91
+        if (isset($_SESSION[$key])) {
92
+            unset($_SESSION[$key]);
93
+        }
94
+    }
95 95
 
96
-	public function clear() {
97
-		$this->invoke('session_unset');
98
-		$this->regenerateId();
99
-		$this->invoke('session_start', [], true);
100
-		$_SESSION = [];
101
-	}
96
+    public function clear() {
97
+        $this->invoke('session_unset');
98
+        $this->regenerateId();
99
+        $this->invoke('session_start', [], true);
100
+        $_SESSION = [];
101
+    }
102 102
 
103
-	public function close() {
104
-		$this->invoke('session_write_close');
105
-		parent::close();
106
-	}
103
+    public function close() {
104
+        $this->invoke('session_write_close');
105
+        parent::close();
106
+    }
107 107
 
108
-	/**
109
-	 * Wrapper around session_regenerate_id
110
-	 *
111
-	 * @param bool $deleteOldSession Whether to delete the old associated session file or not.
112
-	 * @return void
113
-	 */
114
-	public function regenerateId($deleteOldSession = true) {
115
-		try {
116
-			@session_regenerate_id($deleteOldSession);
117
-		} catch (\Error $e) {
118
-			$this->trapError($e->getCode(), $e->getMessage());
119
-		}
120
-	}
108
+    /**
109
+     * Wrapper around session_regenerate_id
110
+     *
111
+     * @param bool $deleteOldSession Whether to delete the old associated session file or not.
112
+     * @return void
113
+     */
114
+    public function regenerateId($deleteOldSession = true) {
115
+        try {
116
+            @session_regenerate_id($deleteOldSession);
117
+        } catch (\Error $e) {
118
+            $this->trapError($e->getCode(), $e->getMessage());
119
+        }
120
+    }
121 121
 
122
-	/**
123
-	 * Wrapper around session_id
124
-	 *
125
-	 * @return string
126
-	 * @throws SessionNotAvailableException
127
-	 * @since 9.1.0
128
-	 */
129
-	public function getId() {
130
-		$id = $this->invoke('session_id', [], true);
131
-		if ($id === '') {
132
-			throw new SessionNotAvailableException();
133
-		}
134
-		return $id;
135
-	}
122
+    /**
123
+     * Wrapper around session_id
124
+     *
125
+     * @return string
126
+     * @throws SessionNotAvailableException
127
+     * @since 9.1.0
128
+     */
129
+    public function getId() {
130
+        $id = $this->invoke('session_id', [], true);
131
+        if ($id === '') {
132
+            throw new SessionNotAvailableException();
133
+        }
134
+        return $id;
135
+    }
136 136
 
137
-	/**
138
-	 * @throws \Exception
139
-	 */
140
-	public function reopen() {
141
-		throw new \Exception('The session cannot be reopened - reopen() is ony to be used in unit testing.');
142
-	}
137
+    /**
138
+     * @throws \Exception
139
+     */
140
+    public function reopen() {
141
+        throw new \Exception('The session cannot be reopened - reopen() is ony to be used in unit testing.');
142
+    }
143 143
 
144
-	/**
145
-	 * @param int $errorNumber
146
-	 * @param string $errorString
147
-	 * @throws \ErrorException
148
-	 */
149
-	public function trapError($errorNumber, $errorString) {
150
-		throw new \ErrorException($errorString);
151
-	}
144
+    /**
145
+     * @param int $errorNumber
146
+     * @param string $errorString
147
+     * @throws \ErrorException
148
+     */
149
+    public function trapError($errorNumber, $errorString) {
150
+        throw new \ErrorException($errorString);
151
+    }
152 152
 
153
-	/**
154
-	 * @throws \Exception
155
-	 */
156
-	private function validateSession() {
157
-		if ($this->sessionClosed) {
158
-			throw new SessionNotAvailableException('Session has been closed - no further changes to the session are allowed');
159
-		}
160
-	}
153
+    /**
154
+     * @throws \Exception
155
+     */
156
+    private function validateSession() {
157
+        if ($this->sessionClosed) {
158
+            throw new SessionNotAvailableException('Session has been closed - no further changes to the session are allowed');
159
+        }
160
+    }
161 161
 
162
-	/**
163
-	 * @param string $functionName the full session_* function name
164
-	 * @param array $parameters
165
-	 * @param bool $silence whether to suppress warnings
166
-	 * @throws \ErrorException via trapError
167
-	 * @return mixed
168
-	 */
169
-	private function invoke($functionName, array $parameters = [], $silence = false) {
170
-		try {
171
-			if($silence) {
172
-				return @call_user_func_array($functionName, $parameters);
173
-			} else {
174
-				return call_user_func_array($functionName, $parameters);
175
-			}
176
-		} catch(\Error $e) {
177
-			$this->trapError($e->getCode(), $e->getMessage());
178
-		}
179
-	}
162
+    /**
163
+     * @param string $functionName the full session_* function name
164
+     * @param array $parameters
165
+     * @param bool $silence whether to suppress warnings
166
+     * @throws \ErrorException via trapError
167
+     * @return mixed
168
+     */
169
+    private function invoke($functionName, array $parameters = [], $silence = false) {
170
+        try {
171
+            if($silence) {
172
+                return @call_user_func_array($functionName, $parameters);
173
+            } else {
174
+                return call_user_func_array($functionName, $parameters);
175
+            }
176
+        } catch(\Error $e) {
177
+            $this->trapError($e->getCode(), $e->getMessage());
178
+        }
179
+    }
180 180
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,12 +168,12 @@
 block discarded – undo
168 168
 	 */
169 169
 	private function invoke($functionName, array $parameters = [], $silence = false) {
170 170
 		try {
171
-			if($silence) {
171
+			if ($silence) {
172 172
 				return @call_user_func_array($functionName, $parameters);
173 173
 			} else {
174 174
 				return call_user_func_array($functionName, $parameters);
175 175
 			}
176
-		} catch(\Error $e) {
176
+		} catch (\Error $e) {
177 177
 			$this->trapError($e->getCode(), $e->getMessage());
178 178
 		}
179 179
 	}
Please login to merge, or discard this patch.