@@ -22,47 +22,47 @@ |
||
22 | 22 | namespace OC\App\CodeChecker; |
23 | 23 | |
24 | 24 | class EmptyCheck implements ICheck { |
25 | - /** |
|
26 | - * @param int $errorCode |
|
27 | - * @param string $errorObject |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function getDescription($errorCode, $errorObject) { |
|
31 | - return ''; |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param int $errorCode |
|
27 | + * @param string $errorObject |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function getDescription($errorCode, $errorObject) { |
|
31 | + return ''; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return array E.g.: `'ClassName' => 'oc version',` |
|
36 | - */ |
|
37 | - public function getClasses() { |
|
38 | - return []; |
|
39 | - } |
|
34 | + /** |
|
35 | + * @return array E.g.: `'ClassName' => 'oc version',` |
|
36 | + */ |
|
37 | + public function getClasses() { |
|
38 | + return []; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
43 | - */ |
|
44 | - public function getConstants() { |
|
45 | - return []; |
|
46 | - } |
|
41 | + /** |
|
42 | + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
43 | + */ |
|
44 | + public function getConstants() { |
|
45 | + return []; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return array E.g.: `'functionName' => 'oc version',` |
|
50 | - */ |
|
51 | - public function getFunctions() { |
|
52 | - return []; |
|
53 | - } |
|
48 | + /** |
|
49 | + * @return array E.g.: `'functionName' => 'oc version',` |
|
50 | + */ |
|
51 | + public function getFunctions() { |
|
52 | + return []; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
57 | - */ |
|
58 | - public function getMethods() { |
|
59 | - return []; |
|
60 | - } |
|
55 | + /** |
|
56 | + * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
57 | + */ |
|
58 | + public function getMethods() { |
|
59 | + return []; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function checkStrongComparisons() { |
|
66 | - return false; |
|
67 | - } |
|
62 | + /** |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function checkStrongComparisons() { |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | } |
@@ -23,57 +23,57 @@ |
||
23 | 23 | namespace OC\App\CodeChecker; |
24 | 24 | |
25 | 25 | class StrongComparisonCheck implements ICheck { |
26 | - /** @var ICheck */ |
|
27 | - protected $check; |
|
26 | + /** @var ICheck */ |
|
27 | + protected $check; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param ICheck $check |
|
31 | - */ |
|
32 | - public function __construct(ICheck $check) { |
|
33 | - $this->check = $check; |
|
34 | - } |
|
29 | + /** |
|
30 | + * @param ICheck $check |
|
31 | + */ |
|
32 | + public function __construct(ICheck $check) { |
|
33 | + $this->check = $check; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param int $errorCode |
|
38 | - * @param string $errorObject |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getDescription($errorCode, $errorObject) { |
|
42 | - return $this->check->getDescription($errorCode, $errorObject); |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param int $errorCode |
|
38 | + * @param string $errorObject |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getDescription($errorCode, $errorObject) { |
|
42 | + return $this->check->getDescription($errorCode, $errorObject); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function getClasses() { |
|
49 | - return $this->check->getClasses(); |
|
50 | - } |
|
45 | + /** |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function getClasses() { |
|
49 | + return $this->check->getClasses(); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function getConstants() { |
|
56 | - return $this->check->getConstants(); |
|
57 | - } |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function getConstants() { |
|
56 | + return $this->check->getConstants(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function getFunctions() { |
|
63 | - return $this->check->getFunctions(); |
|
64 | - } |
|
59 | + /** |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function getFunctions() { |
|
63 | + return $this->check->getFunctions(); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - public function getMethods() { |
|
70 | - return $this->check->getMethods(); |
|
71 | - } |
|
66 | + /** |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + public function getMethods() { |
|
70 | + return $this->check->getMethods(); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function checkStrongComparisons() { |
|
77 | - return true; |
|
78 | - } |
|
73 | + /** |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function checkStrongComparisons() { |
|
77 | + return true; |
|
78 | + } |
|
79 | 79 | } |
@@ -22,35 +22,35 @@ |
||
22 | 22 | namespace OC\App\CodeChecker; |
23 | 23 | |
24 | 24 | interface ICheck { |
25 | - /** |
|
26 | - * @param int $errorCode |
|
27 | - * @param string $errorObject |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function getDescription($errorCode, $errorObject); |
|
25 | + /** |
|
26 | + * @param int $errorCode |
|
27 | + * @param string $errorObject |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function getDescription($errorCode, $errorObject); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return array E.g.: `'ClassName' => 'oc version',` |
|
34 | - */ |
|
35 | - public function getClasses(); |
|
32 | + /** |
|
33 | + * @return array E.g.: `'ClassName' => 'oc version',` |
|
34 | + */ |
|
35 | + public function getClasses(); |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
39 | - */ |
|
40 | - public function getConstants(); |
|
37 | + /** |
|
38 | + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
39 | + */ |
|
40 | + public function getConstants(); |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return array E.g.: `'functionName' => 'oc version',` |
|
44 | - */ |
|
45 | - public function getFunctions(); |
|
42 | + /** |
|
43 | + * @return array E.g.: `'functionName' => 'oc version',` |
|
44 | + */ |
|
45 | + public function getFunctions(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
49 | - */ |
|
50 | - public function getMethods(); |
|
47 | + /** |
|
48 | + * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
49 | + */ |
|
50 | + public function getMethods(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function checkStrongComparisons(); |
|
52 | + /** |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function checkStrongComparisons(); |
|
56 | 56 | } |
@@ -30,200 +30,200 @@ |
||
30 | 30 | * @package OC\App |
31 | 31 | */ |
32 | 32 | class PlatformRepository { |
33 | - public function __construct() { |
|
34 | - $this->packages = $this->initialize(); |
|
35 | - } |
|
36 | - |
|
37 | - protected function initialize() { |
|
38 | - $loadedExtensions = get_loaded_extensions(); |
|
39 | - $packages = array(); |
|
40 | - |
|
41 | - // Extensions scanning |
|
42 | - foreach ($loadedExtensions as $name) { |
|
43 | - if (in_array($name, array('standard', 'Core'))) { |
|
44 | - continue; |
|
45 | - } |
|
46 | - |
|
47 | - $ext = new \ReflectionExtension($name); |
|
48 | - try { |
|
49 | - $prettyVersion = $ext->getVersion(); |
|
50 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
51 | - } catch (\UnexpectedValueException $e) { |
|
52 | - $prettyVersion = '0'; |
|
53 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
54 | - } |
|
55 | - |
|
56 | - $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
57 | - } |
|
58 | - |
|
59 | - foreach ($loadedExtensions as $name) { |
|
60 | - $prettyVersion = null; |
|
61 | - switch ($name) { |
|
62 | - case 'curl': |
|
63 | - $curlVersion = curl_version(); |
|
64 | - $prettyVersion = $curlVersion['version']; |
|
65 | - break; |
|
66 | - |
|
67 | - case 'iconv': |
|
68 | - $prettyVersion = ICONV_VERSION; |
|
69 | - break; |
|
70 | - |
|
71 | - case 'intl': |
|
72 | - $name = 'ICU'; |
|
73 | - if (defined('INTL_ICU_VERSION')) { |
|
74 | - $prettyVersion = INTL_ICU_VERSION; |
|
75 | - } else { |
|
76 | - $reflector = new \ReflectionExtension('intl'); |
|
77 | - |
|
78 | - ob_start(); |
|
79 | - $reflector->info(); |
|
80 | - $output = ob_get_clean(); |
|
81 | - |
|
82 | - preg_match('/^ICU version => (.*)$/m', $output, $matches); |
|
83 | - $prettyVersion = $matches[1]; |
|
84 | - } |
|
85 | - |
|
86 | - break; |
|
87 | - |
|
88 | - case 'libxml': |
|
89 | - $prettyVersion = LIBXML_DOTTED_VERSION; |
|
90 | - break; |
|
91 | - |
|
92 | - case 'openssl': |
|
93 | - $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { |
|
94 | - return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96)); |
|
95 | - }, OPENSSL_VERSION_TEXT); |
|
96 | - break; |
|
97 | - |
|
98 | - case 'pcre': |
|
99 | - $prettyVersion = preg_replace('{^(\S+).*}', '$1', PCRE_VERSION); |
|
100 | - break; |
|
101 | - |
|
102 | - case 'uuid': |
|
103 | - $prettyVersion = phpversion('uuid'); |
|
104 | - break; |
|
105 | - |
|
106 | - case 'xsl': |
|
107 | - $prettyVersion = LIBXSLT_DOTTED_VERSION; |
|
108 | - break; |
|
109 | - |
|
110 | - default: |
|
111 | - // None handled extensions have no special cases, skip |
|
112 | - continue 2; |
|
113 | - } |
|
114 | - |
|
115 | - try { |
|
116 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
117 | - } catch (\UnexpectedValueException $e) { |
|
118 | - continue; |
|
119 | - } |
|
120 | - |
|
121 | - $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
122 | - } |
|
123 | - |
|
124 | - return $packages; |
|
125 | - } |
|
126 | - |
|
127 | - private function buildPackageName($name) { |
|
128 | - return str_replace(' ', '-', $name); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @param $name |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function findLibrary($name) { |
|
136 | - $extName = $this->buildPackageName($name); |
|
137 | - if (isset($this->packages[$extName])) { |
|
138 | - return $this->packages[$extName]; |
|
139 | - } |
|
140 | - return null; |
|
141 | - } |
|
142 | - |
|
143 | - private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; |
|
144 | - |
|
145 | - /** |
|
146 | - * Normalizes a version string to be able to perform comparisons on it |
|
147 | - * |
|
148 | - * https://github.com/composer/composer/blob/master/src/Composer/Package/Version/VersionParser.php#L94 |
|
149 | - * |
|
150 | - * @param string $version |
|
151 | - * @param string $fullVersion optional complete version string to give more context |
|
152 | - * @throws \UnexpectedValueException |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function normalizeVersion($version, $fullVersion = null) { |
|
156 | - $version = trim($version); |
|
157 | - if (null === $fullVersion) { |
|
158 | - $fullVersion = $version; |
|
159 | - } |
|
160 | - // ignore aliases and just assume the alias is required instead of the source |
|
161 | - if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { |
|
162 | - $version = $match[1]; |
|
163 | - } |
|
164 | - // match master-like branches |
|
165 | - if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { |
|
166 | - return '9999999-dev'; |
|
167 | - } |
|
168 | - if ('dev-' === strtolower(substr($version, 0, 4))) { |
|
169 | - return 'dev-' . substr($version, 4); |
|
170 | - } |
|
171 | - // match classical versioning |
|
172 | - if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
173 | - $version = $matches[1] |
|
174 | - . (!empty($matches[2]) ? $matches[2] : '.0') |
|
175 | - . (!empty($matches[3]) ? $matches[3] : '.0') |
|
176 | - . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
177 | - $index = 5; |
|
178 | - } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) { // match date-based versioning |
|
179 | - $version = preg_replace('{\D}', '-', $matches[1]); |
|
180 | - $index = 2; |
|
181 | - } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
182 | - $version = $matches[1] |
|
183 | - . (!empty($matches[2]) ? $matches[2] : '.0') |
|
184 | - . (!empty($matches[3]) ? $matches[3] : '.0') |
|
185 | - . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
186 | - $index = 5; |
|
187 | - } |
|
188 | - // add version modifiers if a version was matched |
|
189 | - if (isset($index)) { |
|
190 | - if (!empty($matches[$index])) { |
|
191 | - if ('stable' === $matches[$index]) { |
|
192 | - return $version; |
|
193 | - } |
|
194 | - $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : ''); |
|
195 | - } |
|
196 | - if (!empty($matches[$index + 2])) { |
|
197 | - $version .= '-dev'; |
|
198 | - } |
|
199 | - return $version; |
|
200 | - } |
|
201 | - $extraMessage = ''; |
|
202 | - if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) { |
|
203 | - $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version'; |
|
204 | - } elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) { |
|
205 | - $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; |
|
206 | - } |
|
207 | - throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param string $stability |
|
212 | - */ |
|
213 | - private function expandStability($stability) { |
|
214 | - $stability = strtolower($stability); |
|
215 | - switch ($stability) { |
|
216 | - case 'a': |
|
217 | - return 'alpha'; |
|
218 | - case 'b': |
|
219 | - return 'beta'; |
|
220 | - case 'p': |
|
221 | - case 'pl': |
|
222 | - return 'patch'; |
|
223 | - case 'rc': |
|
224 | - return 'RC'; |
|
225 | - default: |
|
226 | - return $stability; |
|
227 | - } |
|
228 | - } |
|
33 | + public function __construct() { |
|
34 | + $this->packages = $this->initialize(); |
|
35 | + } |
|
36 | + |
|
37 | + protected function initialize() { |
|
38 | + $loadedExtensions = get_loaded_extensions(); |
|
39 | + $packages = array(); |
|
40 | + |
|
41 | + // Extensions scanning |
|
42 | + foreach ($loadedExtensions as $name) { |
|
43 | + if (in_array($name, array('standard', 'Core'))) { |
|
44 | + continue; |
|
45 | + } |
|
46 | + |
|
47 | + $ext = new \ReflectionExtension($name); |
|
48 | + try { |
|
49 | + $prettyVersion = $ext->getVersion(); |
|
50 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
51 | + } catch (\UnexpectedValueException $e) { |
|
52 | + $prettyVersion = '0'; |
|
53 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
54 | + } |
|
55 | + |
|
56 | + $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
57 | + } |
|
58 | + |
|
59 | + foreach ($loadedExtensions as $name) { |
|
60 | + $prettyVersion = null; |
|
61 | + switch ($name) { |
|
62 | + case 'curl': |
|
63 | + $curlVersion = curl_version(); |
|
64 | + $prettyVersion = $curlVersion['version']; |
|
65 | + break; |
|
66 | + |
|
67 | + case 'iconv': |
|
68 | + $prettyVersion = ICONV_VERSION; |
|
69 | + break; |
|
70 | + |
|
71 | + case 'intl': |
|
72 | + $name = 'ICU'; |
|
73 | + if (defined('INTL_ICU_VERSION')) { |
|
74 | + $prettyVersion = INTL_ICU_VERSION; |
|
75 | + } else { |
|
76 | + $reflector = new \ReflectionExtension('intl'); |
|
77 | + |
|
78 | + ob_start(); |
|
79 | + $reflector->info(); |
|
80 | + $output = ob_get_clean(); |
|
81 | + |
|
82 | + preg_match('/^ICU version => (.*)$/m', $output, $matches); |
|
83 | + $prettyVersion = $matches[1]; |
|
84 | + } |
|
85 | + |
|
86 | + break; |
|
87 | + |
|
88 | + case 'libxml': |
|
89 | + $prettyVersion = LIBXML_DOTTED_VERSION; |
|
90 | + break; |
|
91 | + |
|
92 | + case 'openssl': |
|
93 | + $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { |
|
94 | + return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96)); |
|
95 | + }, OPENSSL_VERSION_TEXT); |
|
96 | + break; |
|
97 | + |
|
98 | + case 'pcre': |
|
99 | + $prettyVersion = preg_replace('{^(\S+).*}', '$1', PCRE_VERSION); |
|
100 | + break; |
|
101 | + |
|
102 | + case 'uuid': |
|
103 | + $prettyVersion = phpversion('uuid'); |
|
104 | + break; |
|
105 | + |
|
106 | + case 'xsl': |
|
107 | + $prettyVersion = LIBXSLT_DOTTED_VERSION; |
|
108 | + break; |
|
109 | + |
|
110 | + default: |
|
111 | + // None handled extensions have no special cases, skip |
|
112 | + continue 2; |
|
113 | + } |
|
114 | + |
|
115 | + try { |
|
116 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
117 | + } catch (\UnexpectedValueException $e) { |
|
118 | + continue; |
|
119 | + } |
|
120 | + |
|
121 | + $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
122 | + } |
|
123 | + |
|
124 | + return $packages; |
|
125 | + } |
|
126 | + |
|
127 | + private function buildPackageName($name) { |
|
128 | + return str_replace(' ', '-', $name); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @param $name |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function findLibrary($name) { |
|
136 | + $extName = $this->buildPackageName($name); |
|
137 | + if (isset($this->packages[$extName])) { |
|
138 | + return $this->packages[$extName]; |
|
139 | + } |
|
140 | + return null; |
|
141 | + } |
|
142 | + |
|
143 | + private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; |
|
144 | + |
|
145 | + /** |
|
146 | + * Normalizes a version string to be able to perform comparisons on it |
|
147 | + * |
|
148 | + * https://github.com/composer/composer/blob/master/src/Composer/Package/Version/VersionParser.php#L94 |
|
149 | + * |
|
150 | + * @param string $version |
|
151 | + * @param string $fullVersion optional complete version string to give more context |
|
152 | + * @throws \UnexpectedValueException |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function normalizeVersion($version, $fullVersion = null) { |
|
156 | + $version = trim($version); |
|
157 | + if (null === $fullVersion) { |
|
158 | + $fullVersion = $version; |
|
159 | + } |
|
160 | + // ignore aliases and just assume the alias is required instead of the source |
|
161 | + if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { |
|
162 | + $version = $match[1]; |
|
163 | + } |
|
164 | + // match master-like branches |
|
165 | + if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { |
|
166 | + return '9999999-dev'; |
|
167 | + } |
|
168 | + if ('dev-' === strtolower(substr($version, 0, 4))) { |
|
169 | + return 'dev-' . substr($version, 4); |
|
170 | + } |
|
171 | + // match classical versioning |
|
172 | + if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
173 | + $version = $matches[1] |
|
174 | + . (!empty($matches[2]) ? $matches[2] : '.0') |
|
175 | + . (!empty($matches[3]) ? $matches[3] : '.0') |
|
176 | + . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
177 | + $index = 5; |
|
178 | + } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) { // match date-based versioning |
|
179 | + $version = preg_replace('{\D}', '-', $matches[1]); |
|
180 | + $index = 2; |
|
181 | + } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
182 | + $version = $matches[1] |
|
183 | + . (!empty($matches[2]) ? $matches[2] : '.0') |
|
184 | + . (!empty($matches[3]) ? $matches[3] : '.0') |
|
185 | + . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
186 | + $index = 5; |
|
187 | + } |
|
188 | + // add version modifiers if a version was matched |
|
189 | + if (isset($index)) { |
|
190 | + if (!empty($matches[$index])) { |
|
191 | + if ('stable' === $matches[$index]) { |
|
192 | + return $version; |
|
193 | + } |
|
194 | + $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : ''); |
|
195 | + } |
|
196 | + if (!empty($matches[$index + 2])) { |
|
197 | + $version .= '-dev'; |
|
198 | + } |
|
199 | + return $version; |
|
200 | + } |
|
201 | + $extraMessage = ''; |
|
202 | + if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) { |
|
203 | + $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version'; |
|
204 | + } elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) { |
|
205 | + $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; |
|
206 | + } |
|
207 | + throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param string $stability |
|
212 | + */ |
|
213 | + private function expandStability($stability) { |
|
214 | + $stability = strtolower($stability); |
|
215 | + switch ($stability) { |
|
216 | + case 'a': |
|
217 | + return 'alpha'; |
|
218 | + case 'b': |
|
219 | + return 'beta'; |
|
220 | + case 'p': |
|
221 | + case 'pl': |
|
222 | + return 'patch'; |
|
223 | + case 'rc': |
|
224 | + return 'RC'; |
|
225 | + default: |
|
226 | + return $stability; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | } |
@@ -28,41 +28,41 @@ |
||
28 | 28 | use OCP\Preview\IProvider; |
29 | 29 | |
30 | 30 | abstract class Provider implements IProvider { |
31 | - private $options; |
|
31 | + private $options; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor |
|
35 | - * |
|
36 | - * @param array $options |
|
37 | - */ |
|
38 | - public function __construct(array $options = []) { |
|
39 | - $this->options = $options; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Constructor |
|
35 | + * |
|
36 | + * @param array $options |
|
37 | + */ |
|
38 | + public function __construct(array $options = []) { |
|
39 | + $this->options = $options; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string Regex with the mimetypes that are supported by this provider |
|
44 | - */ |
|
45 | - abstract public function getMimeType(); |
|
42 | + /** |
|
43 | + * @return string Regex with the mimetypes that are supported by this provider |
|
44 | + */ |
|
45 | + abstract public function getMimeType(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Check if a preview can be generated for $path |
|
49 | - * |
|
50 | - * @param \OCP\Files\FileInfo $file |
|
51 | - * @return bool |
|
52 | - */ |
|
53 | - public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | - return true; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Check if a preview can be generated for $path |
|
49 | + * |
|
50 | + * @param \OCP\Files\FileInfo $file |
|
51 | + * @return bool |
|
52 | + */ |
|
53 | + public function isAvailable(\OCP\Files\FileInfo $file) { |
|
54 | + return true; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | - * |
|
60 | - * @param string $path Path of file |
|
61 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | - * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | - * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | - * @return bool|\OCP\IImage false if no preview was generated |
|
66 | - */ |
|
67 | - abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
57 | + /** |
|
58 | + * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path |
|
59 | + * |
|
60 | + * @param string $path Path of file |
|
61 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
62 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
63 | + * @param bool $scalingup Disable/Enable upscaling of previews |
|
64 | + * @param \OC\Files\View $fileview fileview object of user folder |
|
65 | + * @return bool|\OCP\IImage false if no preview was generated |
|
66 | + */ |
|
67 | + abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
68 | 68 | } |
@@ -22,15 +22,15 @@ |
||
22 | 22 | namespace OC\Share20; |
23 | 23 | |
24 | 24 | class Hooks { |
25 | - public static function post_deleteUser($arguments) { |
|
26 | - \OC::$server->getShareManager()->userDeleted($arguments['uid']); |
|
27 | - } |
|
25 | + public static function post_deleteUser($arguments) { |
|
26 | + \OC::$server->getShareManager()->userDeleted($arguments['uid']); |
|
27 | + } |
|
28 | 28 | |
29 | - public static function post_deleteGroup($arguments) { |
|
30 | - \OC::$server->getShareManager()->groupDeleted($arguments['gid']); |
|
31 | - } |
|
29 | + public static function post_deleteGroup($arguments) { |
|
30 | + \OC::$server->getShareManager()->groupDeleted($arguments['gid']); |
|
31 | + } |
|
32 | 32 | |
33 | - public static function post_removeFromGroup($arguments) { |
|
34 | - \OC::$server->getShareManager()->userDeletedFromGroup($arguments['uid'], $arguments['gid']); |
|
35 | - } |
|
33 | + public static function post_removeFromGroup($arguments) { |
|
34 | + \OC::$server->getShareManager()->userDeletedFromGroup($arguments['uid'], $arguments['gid']); |
|
35 | + } |
|
36 | 36 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | |
28 | 28 | class ModuleAlreadyExistsException extends GenericEncryptionException { |
29 | 29 | |
30 | - /** |
|
31 | - * @param string $id |
|
32 | - * @param string $name |
|
33 | - */ |
|
34 | - public function __construct($id, $name) { |
|
35 | - parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); |
|
36 | - } |
|
30 | + /** |
|
31 | + * @param string $id |
|
32 | + * @param string $name |
|
33 | + */ |
|
34 | + public function __construct($id, $name) { |
|
35 | + parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"'); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -28,8 +28,8 @@ |
||
28 | 28 | |
29 | 29 | class EncryptionHeaderToLargeException extends GenericEncryptionException { |
30 | 30 | |
31 | - public function __construct() { |
|
32 | - parent::__construct('max header size exceeded'); |
|
33 | - } |
|
31 | + public function __construct() { |
|
32 | + parent::__construct('max header size exceeded'); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | |
28 | 28 | class EncryptionHeaderKeyExistsException extends GenericEncryptionException { |
29 | 29 | |
30 | - /** |
|
31 | - * @param string $key |
|
32 | - */ |
|
33 | - public function __construct($key) { |
|
34 | - parent::__construct('header key "'. $key . '" already reserved by ownCloud'); |
|
35 | - } |
|
30 | + /** |
|
31 | + * @param string $key |
|
32 | + */ |
|
33 | + public function __construct($key) { |
|
34 | + parent::__construct('header key "'. $key . '" already reserved by ownCloud'); |
|
35 | + } |
|
36 | 36 | } |