@@ -23,101 +23,101 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class SVNHelper |
25 | 25 | { |
26 | - /** |
|
27 | - * @var integer |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var integer |
|
28 | + */ |
|
29 | 29 | public const ERROR_LOCAL_PATH_DOES_NOT_EXIST = 22401; |
30 | 30 | |
31 | - /** |
|
32 | - * @var integer |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var integer |
|
33 | + */ |
|
34 | 34 | public const ERROR_INVALID_REP_URL = 22402; |
35 | 35 | |
36 | - /** |
|
37 | - * @var integer |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var integer |
|
38 | + */ |
|
39 | 39 | public const ERROR_PATH_IS_OUTSIDE_REPOSITORY = 22403; |
40 | 40 | |
41 | - /** |
|
42 | - * @var integer |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var integer |
|
43 | + */ |
|
44 | 44 | public const ERROR_TARGET_FOLDER_IS_A_FILE = 22404; |
45 | 45 | |
46 | - /** |
|
47 | - * @var integer |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var integer |
|
48 | + */ |
|
49 | 49 | public const ERROR_CANNOT_ADD_INEXISTENT_FILE = 22405; |
50 | 50 | |
51 | - /** |
|
52 | - * @var integer |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var integer |
|
53 | + */ |
|
54 | 54 | public const ERROR_TARGET_PATH_NOT_FOUND = 22406; |
55 | 55 | |
56 | - /** |
|
57 | - * @var integer |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var integer |
|
58 | + */ |
|
59 | 59 | public const ERROR_INVALID_TARGET_TYPE = 22407; |
60 | 60 | |
61 | - /** |
|
62 | - * @var integer |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var integer |
|
63 | + */ |
|
64 | 64 | public const ERROR_INVALID_LOG_CALLBACK = 22408; |
65 | 65 | |
66 | - /** |
|
67 | - * @var SVNHelper_Target_Folder |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var SVNHelper_Target_Folder |
|
68 | + */ |
|
69 | 69 | protected $target; |
70 | 70 | |
71 | - /** |
|
72 | - * @var string |
|
73 | - */ |
|
71 | + /** |
|
72 | + * @var string |
|
73 | + */ |
|
74 | 74 | protected $path; |
75 | 75 | |
76 | - /** |
|
77 | - * @var string |
|
78 | - */ |
|
76 | + /** |
|
77 | + * @var string |
|
78 | + */ |
|
79 | 79 | protected $url; |
80 | 80 | |
81 | - /** |
|
82 | - * @var string |
|
83 | - */ |
|
81 | + /** |
|
82 | + * @var string |
|
83 | + */ |
|
84 | 84 | protected $user; |
85 | 85 | |
86 | - /** |
|
87 | - * @var string |
|
88 | - */ |
|
86 | + /** |
|
87 | + * @var string |
|
88 | + */ |
|
89 | 89 | protected $pass; |
90 | 90 | |
91 | - /** |
|
92 | - * @var array |
|
93 | - */ |
|
91 | + /** |
|
92 | + * @var array |
|
93 | + */ |
|
94 | 94 | protected $options = array( |
95 | 95 | 'binaries-path' => '' |
96 | 96 | ); |
97 | 97 | |
98 | - /** |
|
99 | - * @var boolean |
|
100 | - */ |
|
98 | + /** |
|
99 | + * @var boolean |
|
100 | + */ |
|
101 | 101 | protected $isWindows = false; |
102 | 102 | |
103 | - /** |
|
104 | - * @var array |
|
105 | - */ |
|
103 | + /** |
|
104 | + * @var array |
|
105 | + */ |
|
106 | 106 | protected $normalize = array( |
107 | 107 | 'from' => '\\', |
108 | 108 | 'to' => '/' |
109 | 109 | ); |
110 | 110 | |
111 | - /** |
|
112 | - * @var string |
|
113 | - */ |
|
111 | + /** |
|
112 | + * @var string |
|
113 | + */ |
|
114 | 114 | protected $sourcePath; |
115 | 115 | |
116 | - /** |
|
117 | - * @param string $repPath The path to the repository |
|
118 | - * @param string $repURL The SVN URL to the repository |
|
119 | - * @throws SVNHelper_Exception |
|
120 | - */ |
|
116 | + /** |
|
117 | + * @param string $repPath The path to the repository |
|
118 | + * @param string $repURL The SVN URL to the repository |
|
119 | + * @throws SVNHelper_Exception |
|
120 | + */ |
|
121 | 121 | public function __construct(string $repPath, string $repURL) |
122 | 122 | { |
123 | 123 | $this->isWindows = substr(PHP_OS, 0, 3) == 'WIN'; |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | return $this->pass; |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Normalizes slashes in the path according to the |
|
183 | - * operating system, i.e. forward slashes for NIX-systems |
|
184 | - * and backward slashes for Windows. |
|
185 | - * |
|
186 | - * @param string $path An absolute path to normalize |
|
187 | - * @param bool $relativize Whether to return a path relative to the repository |
|
188 | - * @throws SVNHelper_Exception |
|
189 | - * @return string |
|
190 | - */ |
|
181 | + /** |
|
182 | + * Normalizes slashes in the path according to the |
|
183 | + * operating system, i.e. forward slashes for NIX-systems |
|
184 | + * and backward slashes for Windows. |
|
185 | + * |
|
186 | + * @param string $path An absolute path to normalize |
|
187 | + * @param bool $relativize Whether to return a path relative to the repository |
|
188 | + * @throws SVNHelper_Exception |
|
189 | + * @return string |
|
190 | + */ |
|
191 | 191 | public function normalizePath($path, $relativize=false) |
192 | 192 | { |
193 | 193 | if(empty($path)) { |
@@ -222,32 +222,32 @@ discard block |
||
222 | 222 | ); |
223 | 223 | } |
224 | 224 | |
225 | - /** |
|
226 | - * Retrieves the path slash style according to the |
|
227 | - * current operating system. |
|
228 | - * |
|
229 | - * @return string |
|
230 | - */ |
|
225 | + /** |
|
226 | + * Retrieves the path slash style according to the |
|
227 | + * current operating system. |
|
228 | + * |
|
229 | + * @return string |
|
230 | + */ |
|
231 | 231 | public function getSlash() |
232 | 232 | { |
233 | 233 | return $this->normalize['to']; |
234 | 234 | } |
235 | 235 | |
236 | - /** |
|
237 | - * Keeps instances of files. |
|
238 | - * @var SVNHelper_Target[] |
|
239 | - */ |
|
236 | + /** |
|
237 | + * Keeps instances of files. |
|
238 | + * @var SVNHelper_Target[] |
|
239 | + */ |
|
240 | 240 | protected $targets = array(); |
241 | 241 | |
242 | - /** |
|
243 | - * Retrieves a file instance from the SVN repository: |
|
244 | - * this allows all possible operations on the file as |
|
245 | - * well as accessing more information on it. |
|
246 | - * |
|
247 | - * @param string $path A path to the file, relative to the repository path or absolute. |
|
248 | - * @return SVNHelper_Target_File |
|
249 | - * @throws SVNHelper_Exception |
|
250 | - */ |
|
242 | + /** |
|
243 | + * Retrieves a file instance from the SVN repository: |
|
244 | + * this allows all possible operations on the file as |
|
245 | + * well as accessing more information on it. |
|
246 | + * |
|
247 | + * @param string $path A path to the file, relative to the repository path or absolute. |
|
248 | + * @return SVNHelper_Target_File |
|
249 | + * @throws SVNHelper_Exception |
|
250 | + */ |
|
251 | 251 | public function getFile($path) |
252 | 252 | { |
253 | 253 | $path = $this->filterPath($path); |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | return $this->getTarget('File', $this->relativizePath($path)); |
256 | 256 | } |
257 | 257 | |
258 | - /** |
|
259 | - * Retrieves a folder instance from the SVN repository: |
|
260 | - * This allows all possible operations on the folder as |
|
261 | - * well as accessing more information on it. |
|
262 | - * |
|
263 | - * @param string $path |
|
264 | - * @return SVNHelper_Target_Folder |
|
265 | - * @throws SVNHelper_Exception |
|
266 | - */ |
|
258 | + /** |
|
259 | + * Retrieves a folder instance from the SVN repository: |
|
260 | + * This allows all possible operations on the folder as |
|
261 | + * well as accessing more information on it. |
|
262 | + * |
|
263 | + * @param string $path |
|
264 | + * @return SVNHelper_Target_Folder |
|
265 | + * @throws SVNHelper_Exception |
|
266 | + */ |
|
267 | 267 | public function getFolder($path) |
268 | 268 | { |
269 | 269 | $path = $this->filterPath($path); |
@@ -271,13 +271,13 @@ discard block |
||
271 | 271 | return $this->getTarget('Folder', $this->relativizePath($path)); |
272 | 272 | } |
273 | 273 | |
274 | - /** |
|
275 | - * Passes the path through realpath and ensures it exists. |
|
276 | - * |
|
277 | - * @param string $path |
|
278 | - * @throws SVNHelper_Exception |
|
279 | - * @return string |
|
280 | - */ |
|
274 | + /** |
|
275 | + * Passes the path through realpath and ensures it exists. |
|
276 | + * |
|
277 | + * @param string $path |
|
278 | + * @throws SVNHelper_Exception |
|
279 | + * @return string |
|
280 | + */ |
|
281 | 281 | protected function filterPath($path) |
282 | 282 | { |
283 | 283 | if(empty($path)) { |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - /** |
|
306 | - * Retrieves a target file or folder within the repository. |
|
307 | - * |
|
308 | - * @param string $type The target type, "File" or "Folder". |
|
309 | - * @param string $relativePath A path relative to the root folder. |
|
310 | - * @return SVNHelper_Target |
|
311 | - */ |
|
305 | + /** |
|
306 | + * Retrieves a target file or folder within the repository. |
|
307 | + * |
|
308 | + * @param string $type The target type, "File" or "Folder". |
|
309 | + * @param string $relativePath A path relative to the root folder. |
|
310 | + * @return SVNHelper_Target |
|
311 | + */ |
|
312 | 312 | protected function getTarget($type, $relativePath) |
313 | 313 | { |
314 | 314 | $key = $type.':'.$relativePath; |
@@ -356,33 +356,33 @@ discard block |
||
356 | 356 | return $this->url; |
357 | 357 | } |
358 | 358 | |
359 | - /** |
|
360 | - * Updates the whole SVN repository from the root folder. |
|
361 | - * @return SVNHelper_CommandResult |
|
362 | - */ |
|
359 | + /** |
|
360 | + * Updates the whole SVN repository from the root folder. |
|
361 | + * @return SVNHelper_CommandResult |
|
362 | + */ |
|
363 | 363 | public function runUpdate() |
364 | 364 | { |
365 | 365 | return $this->createUpdate($this->target)->execute(); |
366 | 366 | } |
367 | 367 | |
368 | - /** |
|
369 | - * Creates an update command for the target file or folder. |
|
370 | - * This can be configured further before it is executed. |
|
371 | - * |
|
372 | - * @param SVNHelper_Target $target |
|
373 | - * @return SVNHelper_Command_Update |
|
374 | - */ |
|
368 | + /** |
|
369 | + * Creates an update command for the target file or folder. |
|
370 | + * This can be configured further before it is executed. |
|
371 | + * |
|
372 | + * @param SVNHelper_Target $target |
|
373 | + * @return SVNHelper_Command_Update |
|
374 | + */ |
|
375 | 375 | public function createUpdate(SVNHelper_Target $target) |
376 | 376 | { |
377 | 377 | return $this->createCommand('Update', $target); |
378 | 378 | } |
379 | 379 | |
380 | - /** |
|
381 | - * Creates an add command for the targt file or folder. |
|
382 | - * |
|
383 | - * @param SVNHelper_Target $target |
|
384 | - * @return SVNHelper_Command_Add |
|
385 | - */ |
|
380 | + /** |
|
381 | + * Creates an add command for the targt file or folder. |
|
382 | + * |
|
383 | + * @param SVNHelper_Target $target |
|
384 | + * @return SVNHelper_Command_Add |
|
385 | + */ |
|
386 | 386 | public function createAdd(SVNHelper_Target $target) |
387 | 387 | { |
388 | 388 | return $this->createCommand('Add', $target); |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | return $this->createCommand('Info', $target); |
400 | 400 | } |
401 | 401 | |
402 | - /** |
|
403 | - * Creates a status command for the target file or folder. |
|
404 | - * |
|
405 | - * @param SVNHelper_Target $target |
|
406 | - * @return SVNHelper_Command_Status |
|
407 | - */ |
|
402 | + /** |
|
403 | + * Creates a status command for the target file or folder. |
|
404 | + * |
|
405 | + * @param SVNHelper_Target $target |
|
406 | + * @return SVNHelper_Command_Status |
|
407 | + */ |
|
408 | 408 | public function createStatus(SVNHelper_Target $target) |
409 | 409 | { |
410 | 410 | return $this->createCommand('Status', $target); |
@@ -429,28 +429,28 @@ discard block |
||
429 | 429 | return $cmd; |
430 | 430 | } |
431 | 431 | |
432 | - /** |
|
433 | - * Creates a path relative to the repository for the target |
|
434 | - * file or folder, from an absolute path. |
|
435 | - * |
|
436 | - * @param string $path An absolute path. |
|
437 | - * @return string |
|
438 | - */ |
|
432 | + /** |
|
433 | + * Creates a path relative to the repository for the target |
|
434 | + * file or folder, from an absolute path. |
|
435 | + * |
|
436 | + * @param string $path An absolute path. |
|
437 | + * @return string |
|
438 | + */ |
|
439 | 439 | public function relativizePath($path) |
440 | 440 | { |
441 | 441 | return $this->normalizePath($path, true); |
442 | 442 | } |
443 | 443 | |
444 | - /** |
|
445 | - * Adds a folder: creates it as necessary (recursive), |
|
446 | - * and adds it to be committed if it is not versioned yet. |
|
447 | - * Use this instead of {@link getFolder()} when you are |
|
448 | - * not sure that it exists yet, and will need it. |
|
449 | - * |
|
450 | - * @param string $path Absolute or relative path to the folder |
|
451 | - * @throws SVNHelper_Exception |
|
452 | - * @return SVNHelper_Target_Folder |
|
453 | - */ |
|
444 | + /** |
|
445 | + * Adds a folder: creates it as necessary (recursive), |
|
446 | + * and adds it to be committed if it is not versioned yet. |
|
447 | + * Use this instead of {@link getFolder()} when you are |
|
448 | + * not sure that it exists yet, and will need it. |
|
449 | + * |
|
450 | + * @param string $path Absolute or relative path to the folder |
|
451 | + * @throws SVNHelper_Exception |
|
452 | + * @return SVNHelper_Target_Folder |
|
453 | + */ |
|
454 | 454 | public function addFolder($path) |
455 | 455 | { |
456 | 456 | if(is_dir($path)) { |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | |
501 | 501 | protected static $logCallback; |
502 | 502 | |
503 | - /** |
|
504 | - * Sets the callback function/method to use for |
|
505 | - * SVH helper log messages. This gets the message |
|
506 | - * and the SVNHelper instance as parameters. |
|
507 | - * |
|
508 | - * @param callable $callback |
|
509 | - * @throws SVNHelper_Exception |
|
510 | - */ |
|
503 | + /** |
|
504 | + * Sets the callback function/method to use for |
|
505 | + * SVH helper log messages. This gets the message |
|
506 | + * and the SVNHelper instance as parameters. |
|
507 | + * |
|
508 | + * @param callable $callback |
|
509 | + * @throws SVNHelper_Exception |
|
510 | + */ |
|
511 | 511 | public static function setLogCallback($callback) |
512 | 512 | { |
513 | 513 | if(!is_callable($callback)) { |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - /** |
|
532 | - * Retrieves information about the file, and adds it |
|
533 | - * to be committed later if it not versioned yet. |
|
534 | - * |
|
535 | - * @param string $path |
|
536 | - * @return SVNHelper_Target_File |
|
537 | - */ |
|
531 | + /** |
|
532 | + * Retrieves information about the file, and adds it |
|
533 | + * to be committed later if it not versioned yet. |
|
534 | + * |
|
535 | + * @param string $path |
|
536 | + * @return SVNHelper_Target_File |
|
537 | + */ |
|
538 | 538 | public function addFile($path) |
539 | 539 | { |
540 | 540 | return $this->getFile($path)->runAdd(); |
541 | 541 | } |
542 | 542 | |
543 | - /** |
|
544 | - * Commits all changes in the repository. |
|
545 | - * @param string $message The commit message to log. |
|
546 | - */ |
|
543 | + /** |
|
544 | + * Commits all changes in the repository. |
|
545 | + * @param string $message The commit message to log. |
|
546 | + */ |
|
547 | 547 | public function runCommit($message) |
548 | 548 | { |
549 | 549 | $this->createCommit($this->getFolder($this->path), $message)->execute(); |
@@ -34,46 +34,46 @@ discard block |
||
34 | 34 | public const TYPE_ERROR = 'error'; |
35 | 35 | public const TYPE_SUCCESS = 'success'; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $message = ''; |
41 | 41 | |
42 | - /** |
|
43 | - * @var bool |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var bool |
|
44 | + */ |
|
45 | 45 | protected $valid = true; |
46 | 46 | |
47 | - /** |
|
48 | - * @var object |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var object |
|
49 | + */ |
|
50 | 50 | protected $subject; |
51 | 51 | |
52 | - /** |
|
53 | - * @var integer |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var integer |
|
54 | + */ |
|
55 | 55 | protected $code = 0; |
56 | 56 | |
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | 60 | protected $type = ''; |
61 | 61 | |
62 | - /** |
|
63 | - * @var integer |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var integer |
|
64 | + */ |
|
65 | 65 | private static $counter = 0; |
66 | 66 | |
67 | - /** |
|
68 | - * @var int |
|
69 | - */ |
|
67 | + /** |
|
68 | + * @var int |
|
69 | + */ |
|
70 | 70 | private $id; |
71 | 71 | |
72 | - /** |
|
73 | - * The subject being validated. |
|
74 | - * |
|
75 | - * @param object $subject |
|
76 | - */ |
|
72 | + /** |
|
73 | + * The subject being validated. |
|
74 | + * |
|
75 | + * @param object $subject |
|
76 | + */ |
|
77 | 77 | public function __construct(object $subject) |
78 | 78 | { |
79 | 79 | $this->subject = $subject; |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | $this->id = self::$counter; |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * Retrieves the ID of the result, which is unique within a request. |
|
88 | - * |
|
89 | - * @return int |
|
90 | - */ |
|
86 | + /** |
|
87 | + * Retrieves the ID of the result, which is unique within a request. |
|
88 | + * |
|
89 | + * @return int |
|
90 | + */ |
|
91 | 91 | public function getID() : int |
92 | 92 | { |
93 | 93 | return $this->id; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether the validation was successful. |
|
98 | - * |
|
99 | - * @return bool |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Whether the validation was successful. |
|
98 | + * |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | 101 | public function isValid() : bool |
102 | 102 | { |
103 | 103 | return $this->valid; |
@@ -128,33 +128,33 @@ discard block |
||
128 | 128 | return $this->type === $type; |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Retrieves the subject that was validated. |
|
133 | - * |
|
134 | - * @return object |
|
135 | - */ |
|
131 | + /** |
|
132 | + * Retrieves the subject that was validated. |
|
133 | + * |
|
134 | + * @return object |
|
135 | + */ |
|
136 | 136 | public function getSubject() : object |
137 | 137 | { |
138 | 138 | return $this->subject; |
139 | 139 | } |
140 | 140 | |
141 | - /** |
|
142 | - * Makes the result a success, with the specified message. |
|
143 | - * |
|
144 | - * @param string $message Should not contain a date, just the system specific info. |
|
145 | - * @return $this |
|
146 | - */ |
|
141 | + /** |
|
142 | + * Makes the result a success, with the specified message. |
|
143 | + * |
|
144 | + * @param string $message Should not contain a date, just the system specific info. |
|
145 | + * @return $this |
|
146 | + */ |
|
147 | 147 | public function makeSuccess(string $message, int $code=0) : OperationResult |
148 | 148 | { |
149 | 149 | return $this->setMessage(self::TYPE_SUCCESS, $message, $code, true); |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Sets the result as an error. |
|
154 | - * |
|
155 | - * @param string $message Should be as detailed as possible. |
|
156 | - * @return $this |
|
157 | - */ |
|
152 | + /** |
|
153 | + * Sets the result as an error. |
|
154 | + * |
|
155 | + * @param string $message Should be as detailed as possible. |
|
156 | + * @return $this |
|
157 | + */ |
|
158 | 158 | public function makeError(string $message, int $code=0) : OperationResult |
159 | 159 | { |
160 | 160 | return $this->setMessage(self::TYPE_ERROR, $message, $code, false); |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | return $this->type; |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Retrieves the error message, if an error occurred. |
|
207 | - * |
|
208 | - * @return string The error message, or an empty string if no error occurred. |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Retrieves the error message, if an error occurred. |
|
207 | + * |
|
208 | + * @return string The error message, or an empty string if no error occurred. |
|
209 | + */ |
|
210 | 210 | public function getErrorMessage() : string |
211 | 211 | { |
212 | 212 | return $this->getMessage(self::TYPE_ERROR); |
213 | 213 | } |
214 | 214 | |
215 | - /** |
|
216 | - * Retrieves the success message, if one has been provided. |
|
217 | - * |
|
218 | - * @return string |
|
219 | - */ |
|
215 | + /** |
|
216 | + * Retrieves the success message, if one has been provided. |
|
217 | + * |
|
218 | + * @return string |
|
219 | + */ |
|
220 | 220 | public function getSuccessMessage() : string |
221 | 221 | { |
222 | 222 | return $this->getMessage(self::TYPE_SUCCESS); |
@@ -232,21 +232,21 @@ discard block |
||
232 | 232 | return $this->getMessage(self::TYPE_WARNING); |
233 | 233 | } |
234 | 234 | |
235 | - /** |
|
236 | - * Whether a specific error/success code has been specified. |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
235 | + /** |
|
236 | + * Whether a specific error/success code has been specified. |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | 240 | public function hasCode() : bool |
241 | 241 | { |
242 | 242 | return $this->code > 0; |
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
246 | - * Retrieves the error/success code, if any. |
|
247 | - * |
|
248 | - * @return int The error code, or 0 if none. |
|
249 | - */ |
|
245 | + /** |
|
246 | + * Retrieves the error/success code, if any. |
|
247 | + * |
|
248 | + * @return int The error code, or 0 if none. |
|
249 | + */ |
|
250 | 250 | public function getCode() : int |
251 | 251 | { |
252 | 252 | return $this->code; |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class ConvertHelper_TimeConverter |
25 | 25 | { |
26 | - /** |
|
27 | - * @var float |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var float |
|
28 | + */ |
|
29 | 29 | private $seconds; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array<int,array<string,string|int>>|NULL |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array<int,array<string,string|int>>|NULL |
|
33 | + */ |
|
34 | 34 | private static $units; |
35 | 35 | |
36 | - /** |
|
37 | - * @param float $seconds |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @param float $seconds |
|
38 | + */ |
|
39 | 39 | public function __construct($seconds) |
40 | 40 | { |
41 | 41 | $this->seconds = $seconds; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $this->initUnits(); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Creates the list of units once per request as needed. |
|
48 | - */ |
|
46 | + /** |
|
47 | + * Creates the list of units once per request as needed. |
|
48 | + */ |
|
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | 51 | if(isset(self::$units)) |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Resolves the list of converted units. |
|
117 | - * |
|
118 | - * @return string[] |
|
119 | - */ |
|
115 | + /** |
|
116 | + * Resolves the list of converted units. |
|
117 | + * |
|
118 | + * @return string[] |
|
119 | + */ |
|
120 | 120 | private function resolveTokens() : array |
121 | 121 | { |
122 | 122 | $seconds = $this->seconds; |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | public const TOKEN_MONTHS = 'm'; |
42 | 42 | public const TOKEN_YEARS = 'y'; |
43 | 43 | |
44 | - /** |
|
45 | - * @var DateInterval |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var DateInterval |
|
46 | + */ |
|
47 | 47 | protected $interval; |
48 | 48 | |
49 | - /** |
|
50 | - * @var int |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var int |
|
51 | + */ |
|
52 | 52 | protected $seconds; |
53 | 53 | |
54 | 54 | /** |
@@ -92,22 +92,22 @@ discard block |
||
92 | 92 | return new ConvertHelper_DateInterval($seconds); |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Creates the interval from an existing regular interval instance. |
|
97 | - * |
|
98 | - * @param DateInterval $interval |
|
99 | - * @return ConvertHelper_DateInterval |
|
100 | - */ |
|
95 | + /** |
|
96 | + * Creates the interval from an existing regular interval instance. |
|
97 | + * |
|
98 | + * @param DateInterval $interval |
|
99 | + * @return ConvertHelper_DateInterval |
|
100 | + */ |
|
101 | 101 | public static function fromInterval(DateInterval $interval) |
102 | 102 | { |
103 | 103 | return self::fromSeconds(ConvertHelper::interval2seconds($interval)); |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * Retrieves the PHP native date interval. |
|
108 | - * |
|
109 | - * @return DateInterval |
|
110 | - */ |
|
106 | + /** |
|
107 | + * Retrieves the PHP native date interval. |
|
108 | + * |
|
109 | + * @return DateInterval |
|
110 | + */ |
|
111 | 111 | public function getInterval() : DateInterval |
112 | 112 | { |
113 | 113 | return $this->interval; |
@@ -143,31 +143,31 @@ discard block |
||
143 | 143 | return $this->getToken(self::TOKEN_YEARS); |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Retrieves a specific time token, e.g. "h" (for hours). |
|
148 | - * Using the constants to specifiy the tokens is recommended. |
|
149 | - * |
|
150 | - * @param string $token |
|
151 | - * @return int |
|
152 | - * |
|
153 | - * @see ConvertHelper_DateInterval::TOKEN_SECONDS |
|
154 | - * @see ConvertHelper_DateInterval::TOKEN_MINUTES |
|
155 | - * @see ConvertHelper_DateInterval::TOKEN_HOURS |
|
156 | - * @see ConvertHelper_DateInterval::TOKEN_DAYS |
|
157 | - * @see ConvertHelper_DateInterval::TOKEN_MONTHS |
|
158 | - * @see ConvertHelper_DateInterval::TOKEN_YEARS |
|
159 | - */ |
|
146 | + /** |
|
147 | + * Retrieves a specific time token, e.g. "h" (for hours). |
|
148 | + * Using the constants to specifiy the tokens is recommended. |
|
149 | + * |
|
150 | + * @param string $token |
|
151 | + * @return int |
|
152 | + * |
|
153 | + * @see ConvertHelper_DateInterval::TOKEN_SECONDS |
|
154 | + * @see ConvertHelper_DateInterval::TOKEN_MINUTES |
|
155 | + * @see ConvertHelper_DateInterval::TOKEN_HOURS |
|
156 | + * @see ConvertHelper_DateInterval::TOKEN_DAYS |
|
157 | + * @see ConvertHelper_DateInterval::TOKEN_MONTHS |
|
158 | + * @see ConvertHelper_DateInterval::TOKEN_YEARS |
|
159 | + */ |
|
160 | 160 | public function getToken(string $token) : int |
161 | 161 | { |
162 | 162 | return (int)$this->interval->$token; |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * The total amount of seconds in the interval (including |
|
167 | - * everything, from seconds to days, months, years...). |
|
168 | - * |
|
169 | - * @return int |
|
170 | - */ |
|
165 | + /** |
|
166 | + * The total amount of seconds in the interval (including |
|
167 | + * everything, from seconds to days, months, years...). |
|
168 | + * |
|
169 | + * @return int |
|
170 | + */ |
|
171 | 171 | public function getTotalSeconds() : int |
172 | 172 | { |
173 | 173 | return $this->seconds; |
@@ -20,48 +20,48 @@ discard block |
||
20 | 20 | public const CONTEXT_WEB = 'web'; |
21 | 21 | |
22 | 22 | /** |
23 | - * @var Throwable |
|
24 | - */ |
|
23 | + * @var Throwable |
|
24 | + */ |
|
25 | 25 | protected $exception; |
26 | 26 | |
27 | - /** |
|
28 | - * @var ConvertHelper_ThrowableInfo_Call[] |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var ConvertHelper_ThrowableInfo_Call[] |
|
29 | + */ |
|
30 | 30 | protected $calls = array(); |
31 | 31 | |
32 | - /** |
|
33 | - * @var integer |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var integer |
|
34 | + */ |
|
35 | 35 | protected $code = 0; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $message; |
41 | 41 | |
42 | - /** |
|
43 | - * @var integer |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var integer |
|
44 | + */ |
|
45 | 45 | protected $callsCount = 0; |
46 | 46 | |
47 | - /** |
|
48 | - * @var ConvertHelper_ThrowableInfo|NULL |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var ConvertHelper_ThrowableInfo|NULL |
|
49 | + */ |
|
50 | 50 | protected $previous = null; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | protected $referer = ''; |
56 | 56 | |
57 | - /** |
|
58 | - * @var Microtime |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var Microtime |
|
59 | + */ |
|
60 | 60 | protected $date; |
61 | 61 | |
62 | - /** |
|
63 | - * @var string |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var string |
|
64 | + */ |
|
65 | 65 | protected $context = self::CONTEXT_WEB; |
66 | 66 | |
67 | 67 | /** |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | return isset($this->previous); |
128 | 128 | } |
129 | 129 | |
130 | - /** |
|
131 | - * Retrieves the information on the previous exception. |
|
132 | - * |
|
133 | - * NOTE: Throws an exception if there is no previous |
|
134 | - * exception. Use hasPrevious() first to avoid this. |
|
135 | - * |
|
136 | - * @throws ConvertHelper_Exception |
|
137 | - * @return ConvertHelper_ThrowableInfo |
|
138 | - * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
139 | - */ |
|
130 | + /** |
|
131 | + * Retrieves the information on the previous exception. |
|
132 | + * |
|
133 | + * NOTE: Throws an exception if there is no previous |
|
134 | + * exception. Use hasPrevious() first to avoid this. |
|
135 | + * |
|
136 | + * @throws ConvertHelper_Exception |
|
137 | + * @return ConvertHelper_ThrowableInfo |
|
138 | + * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
139 | + */ |
|
140 | 140 | public function getPrevious() : ConvertHelper_ThrowableInfo |
141 | 141 | { |
142 | 142 | if(isset($this->previous)) { |
@@ -155,68 +155,68 @@ discard block |
||
155 | 155 | return !empty($this->code); |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Improved text-only exception trace. |
|
160 | - */ |
|
158 | + /** |
|
159 | + * Improved text-only exception trace. |
|
160 | + */ |
|
161 | 161 | public function toString() : string |
162 | 162 | { |
163 | 163 | return (new ConvertHelper_ThrowableInfo_StringConverter($this)) |
164 | 164 | ->toString(); |
165 | 165 | } |
166 | 166 | |
167 | - /** |
|
168 | - * Retrieves the URL of the page in which the exception |
|
169 | - * was thrown, if applicable: in CLI context, this will |
|
170 | - * return an empty string. |
|
171 | - * |
|
172 | - * @return string |
|
173 | - */ |
|
167 | + /** |
|
168 | + * Retrieves the URL of the page in which the exception |
|
169 | + * was thrown, if applicable: in CLI context, this will |
|
170 | + * return an empty string. |
|
171 | + * |
|
172 | + * @return string |
|
173 | + */ |
|
174 | 174 | public function getReferer() : string |
175 | 175 | { |
176 | 176 | return $this->referer; |
177 | 177 | } |
178 | 178 | |
179 | - /** |
|
180 | - * Whether the exception occurred in a command line context. |
|
181 | - * @return bool |
|
182 | - */ |
|
179 | + /** |
|
180 | + * Whether the exception occurred in a command line context. |
|
181 | + * @return bool |
|
182 | + */ |
|
183 | 183 | public function isCommandLine() : bool |
184 | 184 | { |
185 | 185 | return $this->getContext() === self::CONTEXT_COMMAND_LINE; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Whether the exception occurred during an http request. |
|
190 | - * @return bool |
|
191 | - */ |
|
188 | + /** |
|
189 | + * Whether the exception occurred during an http request. |
|
190 | + * @return bool |
|
191 | + */ |
|
192 | 192 | public function isWebRequest() : bool |
193 | 193 | { |
194 | 194 | return $this->getContext() === self::CONTEXT_WEB; |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Retrieves the context identifier, i.e. if the exception |
|
199 | - * occurred in a command line context or regular web request. |
|
200 | - * |
|
201 | - * @return string |
|
202 | - * |
|
203 | - * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
204 | - * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
205 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
206 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
207 | - */ |
|
197 | + /** |
|
198 | + * Retrieves the context identifier, i.e. if the exception |
|
199 | + * occurred in a command line context or regular web request. |
|
200 | + * |
|
201 | + * @return string |
|
202 | + * |
|
203 | + * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
204 | + * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
205 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
206 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
207 | + */ |
|
208 | 208 | public function getContext() : string |
209 | 209 | { |
210 | 210 | return $this->context; |
211 | 211 | } |
212 | 212 | |
213 | - /** |
|
214 | - * Retrieves the date of the exception, and approximate time: |
|
215 | - * since exceptions do not store time, this is captured the |
|
216 | - * moment the ThrowableInfo is created. |
|
217 | - * |
|
218 | - * @return Microtime |
|
219 | - */ |
|
213 | + /** |
|
214 | + * Retrieves the date of the exception, and approximate time: |
|
215 | + * since exceptions do not store time, this is captured the |
|
216 | + * moment the ThrowableInfo is created. |
|
217 | + * |
|
218 | + * @return Microtime |
|
219 | + */ |
|
220 | 220 | public function getDate() : Microtime |
221 | 221 | { |
222 | 222 | return $this->date; |
@@ -237,24 +237,24 @@ discard block |
||
237 | 237 | return ConvertHelper_ThrowableInfo_Serializer::serialize($this); |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * Sets the maximum folder depth to show in the |
|
242 | - * file paths, to avoid them being too long. |
|
243 | - * |
|
244 | - * @param int $depth |
|
245 | - * @return ConvertHelper_ThrowableInfo |
|
246 | - */ |
|
240 | + /** |
|
241 | + * Sets the maximum folder depth to show in the |
|
242 | + * file paths, to avoid them being too long. |
|
243 | + * |
|
244 | + * @param int $depth |
|
245 | + * @return ConvertHelper_ThrowableInfo |
|
246 | + */ |
|
247 | 247 | public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo |
248 | 248 | { |
249 | 249 | return $this->setOption('folder-depth', $depth); |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Retrieves the current folder depth option value. |
|
254 | - * |
|
255 | - * @return int |
|
256 | - * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
257 | - */ |
|
252 | + /** |
|
253 | + * Retrieves the current folder depth option value. |
|
254 | + * |
|
255 | + * @return int |
|
256 | + * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
257 | + */ |
|
258 | 258 | public function getFolderDepth() : int |
259 | 259 | { |
260 | 260 | $depth = $this->getOption('folder-depth'); |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | return 2; |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
269 | - * Retrieves all function calls that led to the error, |
|
270 | - * ordered from latest to earliest (the first one in |
|
271 | - * the stack is actually the last call). |
|
272 | - * |
|
273 | - * @return ConvertHelper_ThrowableInfo_Call[] |
|
274 | - */ |
|
268 | + /** |
|
269 | + * Retrieves all function calls that led to the error, |
|
270 | + * ordered from latest to earliest (the first one in |
|
271 | + * the stack is actually the last call). |
|
272 | + * |
|
273 | + * @return ConvertHelper_ThrowableInfo_Call[] |
|
274 | + */ |
|
275 | 275 | public function getCalls() |
276 | 276 | { |
277 | 277 | return $this->calls; |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | return $this->calls[0]; |
288 | 288 | } |
289 | 289 | |
290 | - /** |
|
291 | - * Returns the amount of function and method calls in the stack trace. |
|
292 | - * @return int |
|
293 | - */ |
|
290 | + /** |
|
291 | + * Returns the amount of function and method calls in the stack trace. |
|
292 | + * @return int |
|
293 | + */ |
|
294 | 294 | public function countCalls() : int |
295 | 295 | { |
296 | 296 | return $this->callsCount; |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | public const TYPE_LF = 'LF'; |
30 | 30 | public const TYPE_CR = 'CR'; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $char; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $type; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $description; |
46 | 46 | |
47 | 47 | /** |
@@ -56,33 +56,33 @@ discard block |
||
56 | 56 | $this->description = $description; |
57 | 57 | } |
58 | 58 | |
59 | - /** |
|
60 | - * The actual EOL character. |
|
61 | - * @return string |
|
62 | - */ |
|
59 | + /** |
|
60 | + * The actual EOL character. |
|
61 | + * @return string |
|
62 | + */ |
|
63 | 63 | public function getCharacter() : string |
64 | 64 | { |
65 | 65 | return $this->char; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * A more detailed, human readable description of the character. |
|
70 | - * @return string |
|
71 | - */ |
|
68 | + /** |
|
69 | + * A more detailed, human readable description of the character. |
|
70 | + * @return string |
|
71 | + */ |
|
72 | 72 | public function getDescription() : string |
73 | 73 | { |
74 | 74 | return $this->description; |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * The EOL character type, e.g. "CR+LF", "CR"... |
|
79 | - * @return string |
|
80 | - * |
|
81 | - * @see ConvertHelper_EOL::TYPE_CR |
|
82 | - * @see ConvertHelper_EOL::TYPE_CRLF |
|
83 | - * @see ConvertHelper_EOL::TYPE_LF |
|
84 | - * @see ConvertHelper_EOL::TYPE_LFCR |
|
85 | - */ |
|
77 | + /** |
|
78 | + * The EOL character type, e.g. "CR+LF", "CR"... |
|
79 | + * @return string |
|
80 | + * |
|
81 | + * @see ConvertHelper_EOL::TYPE_CR |
|
82 | + * @see ConvertHelper_EOL::TYPE_CRLF |
|
83 | + * @see ConvertHelper_EOL::TYPE_LF |
|
84 | + * @see ConvertHelper_EOL::TYPE_LFCR |
|
85 | + */ |
|
86 | 86 | public function getType() : string |
87 | 87 | { |
88 | 88 | return $this->type; |
@@ -10,45 +10,45 @@ discard block |
||
10 | 10 | public const TYPE_METHOD_CALL = 'method'; |
11 | 11 | public const TYPE_SCRIPT_START = 'start'; |
12 | 12 | |
13 | - /** |
|
14 | - * @var ConvertHelper_ThrowableInfo |
|
15 | - */ |
|
13 | + /** |
|
14 | + * @var ConvertHelper_ThrowableInfo |
|
15 | + */ |
|
16 | 16 | protected $info; |
17 | 17 | |
18 | - /** |
|
19 | - * @var VariableInfo[] |
|
20 | - */ |
|
18 | + /** |
|
19 | + * @var VariableInfo[] |
|
20 | + */ |
|
21 | 21 | protected $args = array(); |
22 | 22 | |
23 | - /** |
|
24 | - * The source file, if any |
|
25 | - * @var string |
|
26 | - */ |
|
23 | + /** |
|
24 | + * The source file, if any |
|
25 | + * @var string |
|
26 | + */ |
|
27 | 27 | protected $file = ''; |
28 | 28 | |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | 32 | protected $class = ''; |
33 | 33 | |
34 | - /** |
|
35 | - * @var integer |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var integer |
|
36 | + */ |
|
37 | 37 | protected $line = 0; |
38 | 38 | |
39 | - /** |
|
40 | - * @var int |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var int |
|
41 | + */ |
|
42 | 42 | protected $position = 1; |
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | 47 | protected $function = ''; |
48 | 48 | |
49 | - /** |
|
50 | - * @var string |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var string |
|
51 | + */ |
|
52 | 52 | protected $type = self::TYPE_SCRIPT_START; |
53 | 53 | |
54 | 54 | /** |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - /** |
|
83 | - * 1-based position of the call in the calls list. |
|
84 | - * @return int |
|
85 | - */ |
|
82 | + /** |
|
83 | + * 1-based position of the call in the calls list. |
|
84 | + * @return int |
|
85 | + */ |
|
86 | 86 | public function getPosition() : int |
87 | 87 | { |
88 | 88 | return $this->position; |
@@ -93,18 +93,18 @@ discard block |
||
93 | 93 | return $this->line; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether the call had any arguments. |
|
98 | - * @return bool |
|
99 | - */ |
|
96 | + /** |
|
97 | + * Whether the call had any arguments. |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function hasArguments() : bool |
101 | 101 | { |
102 | 102 | return !empty($this->args); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * @return VariableInfo[] |
|
107 | - */ |
|
105 | + /** |
|
106 | + * @return VariableInfo[] |
|
107 | + */ |
|
108 | 108 | public function getArguments() |
109 | 109 | { |
110 | 110 | return $this->args; |
@@ -244,31 +244,31 @@ discard block |
||
244 | 244 | return implode(', ', $tokens); |
245 | 245 | } |
246 | 246 | |
247 | - /** |
|
248 | - * Retrieves the type of call: typically a function |
|
249 | - * call, or a method call of an object. Note that the |
|
250 | - * first call in a script does not have either. |
|
251 | - * |
|
252 | - * @return string |
|
253 | - * |
|
254 | - * @see ConvertHelper_ThrowableInfo_Call::TYPE_FUNCTION_CALL |
|
255 | - * @see ConvertHelper_ThrowableInfo_Call::TYPE_METHOD_CALL |
|
256 | - * @see ConvertHelper_ThrowableInfo_Call::TYPE_SCRIPT_START |
|
257 | - * @see ConvertHelper_ThrowableInfo_Call::hasFunction() |
|
258 | - * @see ConvertHelper_ThrowableInfo_Call::hasClass() |
|
259 | - */ |
|
247 | + /** |
|
248 | + * Retrieves the type of call: typically a function |
|
249 | + * call, or a method call of an object. Note that the |
|
250 | + * first call in a script does not have either. |
|
251 | + * |
|
252 | + * @return string |
|
253 | + * |
|
254 | + * @see ConvertHelper_ThrowableInfo_Call::TYPE_FUNCTION_CALL |
|
255 | + * @see ConvertHelper_ThrowableInfo_Call::TYPE_METHOD_CALL |
|
256 | + * @see ConvertHelper_ThrowableInfo_Call::TYPE_SCRIPT_START |
|
257 | + * @see ConvertHelper_ThrowableInfo_Call::hasFunction() |
|
258 | + * @see ConvertHelper_ThrowableInfo_Call::hasClass() |
|
259 | + */ |
|
260 | 260 | public function getType() : string |
261 | 261 | { |
262 | 262 | return $this->type; |
263 | 263 | } |
264 | 264 | |
265 | - /** |
|
266 | - * Serializes the call to an array, with all |
|
267 | - * necessary information. Can be used to restore |
|
268 | - * the call later using {@link ConvertHelper_ThrowableInfo_Call::fromSerialized()}. |
|
269 | - * |
|
270 | - * @return array<string,mixed> |
|
271 | - */ |
|
265 | + /** |
|
266 | + * Serializes the call to an array, with all |
|
267 | + * necessary information. Can be used to restore |
|
268 | + * the call later using {@link ConvertHelper_ThrowableInfo_Call::fromSerialized()}. |
|
269 | + * |
|
270 | + * @return array<string,mixed> |
|
271 | + */ |
|
272 | 272 | public function serialize() : array |
273 | 273 | { |
274 | 274 | $result = array( |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | public const SECONDS_PER_MONTH_APPROX = 2505600; // imprecise - for 29 days, only for approximations. |
35 | 35 | public const SECONDS_PER_YEAR = 31536000; |
36 | 36 | |
37 | - /** |
|
38 | - * @var int|NULL |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var int|NULL |
|
39 | + */ |
|
40 | 40 | protected $dateFrom; |
41 | 41 | |
42 | - /** |
|
43 | - * @var int|NULL |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var int|NULL |
|
44 | + */ |
|
45 | 45 | protected $dateTo; |
46 | 46 | |
47 | - /** |
|
48 | - * @var bool |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var bool |
|
49 | + */ |
|
50 | 50 | protected $future = false; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | protected $interval = ''; |
56 | 56 | |
57 | - /** |
|
58 | - * @var int |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var int |
|
59 | + */ |
|
60 | 60 | protected $difference = 0; |
61 | 61 | |
62 | - /** |
|
63 | - * @var int |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var int |
|
64 | + */ |
|
65 | 65 | protected $dateDiff = 0; |
66 | 66 | |
67 | - /** |
|
68 | - * @var array<string,array<string,string>>|NULL |
|
69 | - */ |
|
67 | + /** |
|
68 | + * @var array<string,array<string,string>>|NULL |
|
69 | + */ |
|
70 | 70 | protected static $texts = null; |
71 | 71 | |
72 | 72 | public function __construct() |
@@ -86,17 +86,17 @@ discard block |
||
86 | 86 | self::$texts = null; |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Sets the origin date to calculate from. |
|
91 | - * |
|
92 | - * NOTE: if this is further in the future than |
|
93 | - * the to: date, it will be considered as a |
|
94 | - * calculation for something to come, i.e. |
|
95 | - * "In two days". |
|
96 | - * |
|
97 | - * @param DateTime $date |
|
98 | - * @return ConvertHelper_DurationConverter |
|
99 | - */ |
|
89 | + /** |
|
90 | + * Sets the origin date to calculate from. |
|
91 | + * |
|
92 | + * NOTE: if this is further in the future than |
|
93 | + * the to: date, it will be considered as a |
|
94 | + * calculation for something to come, i.e. |
|
95 | + * "In two days". |
|
96 | + * |
|
97 | + * @param DateTime $date |
|
98 | + * @return ConvertHelper_DurationConverter |
|
99 | + */ |
|
100 | 100 | public function setDateFrom(DateTime $date) : ConvertHelper_DurationConverter |
101 | 101 | { |
102 | 102 | $this->dateFrom = ConvertHelper::date2timestamp($date); |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Sets the date to calculate to. Defaults to |
|
109 | - * the current time if not set. |
|
110 | - * |
|
111 | - * @param DateTime $date |
|
112 | - * @return ConvertHelper_DurationConverter |
|
113 | - */ |
|
107 | + /** |
|
108 | + * Sets the date to calculate to. Defaults to |
|
109 | + * the current time if not set. |
|
110 | + * |
|
111 | + * @param DateTime $date |
|
112 | + * @return ConvertHelper_DurationConverter |
|
113 | + */ |
|
114 | 114 | public function setDateTo(DateTime $date) : ConvertHelper_DurationConverter |
115 | 115 | { |
116 | 116 | $this->dateTo = ConvertHelper::date2timestamp($date); |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Converts the specified dates to a human-readable string. |
|
123 | - * |
|
124 | - * @throws ConvertHelper_Exception |
|
125 | - * @return string |
|
126 | - * |
|
127 | - * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
128 | - */ |
|
121 | + /** |
|
122 | + * Converts the specified dates to a human-readable string. |
|
123 | + * |
|
124 | + * @throws ConvertHelper_Exception |
|
125 | + * @return string |
|
126 | + * |
|
127 | + * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
128 | + */ |
|
129 | 129 | public function convert() : string |
130 | 130 | { |
131 | 131 | $this->initTexts(); |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | public const VALIDATION_ERROR_NEGATIVE_VALUE = 43803; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | protected $sizeString; |
38 | 38 | |
39 | 39 | /** |
@@ -41,44 +41,44 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $sizeDefinition; |
43 | 43 | |
44 | - /** |
|
45 | - * @var integer |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var integer |
|
46 | + */ |
|
47 | 47 | protected $bytes = 0; |
48 | 48 | |
49 | - /** |
|
50 | - * @var bool |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | 52 | protected $valid = true; |
53 | 53 | |
54 | - /** |
|
55 | - * @var string |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $units = null; |
58 | 58 | |
59 | - /** |
|
60 | - * @var string |
|
61 | - */ |
|
59 | + /** |
|
60 | + * @var string |
|
61 | + */ |
|
62 | 62 | protected $number = ''; |
63 | 63 | |
64 | - /** |
|
65 | - * @var string |
|
66 | - */ |
|
64 | + /** |
|
65 | + * @var string |
|
66 | + */ |
|
67 | 67 | protected $errorMessage = ''; |
68 | 68 | |
69 | - /** |
|
70 | - * @var int |
|
71 | - */ |
|
69 | + /** |
|
70 | + * @var int |
|
71 | + */ |
|
72 | 72 | protected $errorCode = 0; |
73 | 73 | |
74 | - /** |
|
75 | - * Create a new instance for the specified size string. |
|
76 | - * |
|
77 | - * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = " 50 MB ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case-insensitive, so "50 MB" = "50 mb". |
|
78 | - * |
|
79 | - * @throws ConvertHelper_Exception |
|
80 | - * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
81 | - */ |
|
74 | + /** |
|
75 | + * Create a new instance for the specified size string. |
|
76 | + * |
|
77 | + * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = " 50 MB ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case-insensitive, so "50 MB" = "50 mb". |
|
78 | + * |
|
79 | + * @throws ConvertHelper_Exception |
|
80 | + * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME |
|
81 | + */ |
|
82 | 82 | public function __construct(string $sizeString) |
83 | 83 | { |
84 | 84 | $this->sizeString = $this->cleanString($sizeString); |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | $this->convert(); |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Gets the amount of bytes contained in the size notation. |
|
91 | - * @return int |
|
92 | - */ |
|
89 | + /** |
|
90 | + * Gets the amount of bytes contained in the size notation. |
|
91 | + * @return int |
|
92 | + */ |
|
93 | 93 | public function toBytes() : int |
94 | 94 | { |
95 | 95 | return $this->bytes; |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Converts the size notation to a human-readable string, e.g. "50 MB". |
|
100 | - * |
|
101 | - * @param int $precision |
|
102 | - * @return string |
|
103 | - * @see ConvertHelper::bytes2readable() |
|
104 | - */ |
|
98 | + /** |
|
99 | + * Converts the size notation to a human-readable string, e.g. "50 MB". |
|
100 | + * |
|
101 | + * @param int $precision |
|
102 | + * @return string |
|
103 | + * @see ConvertHelper::bytes2readable() |
|
104 | + */ |
|
105 | 105 | public function toString(int $precision=1) : string |
106 | 106 | { |
107 | 107 | return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase()); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Retrieves the detected number's base. |
|
112 | - * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid. |
|
113 | - */ |
|
110 | + /** |
|
111 | + * Retrieves the detected number's base. |
|
112 | + * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid. |
|
113 | + */ |
|
114 | 114 | public function getBase() : int |
115 | 115 | { |
116 | 116 | if($this->isValid()) { |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Retrieves the detected storage size instance, if |
|
125 | - * the size string is valid. |
|
126 | - * |
|
127 | - * @return ConvertHelper_StorageSizeEnum_Size|NULL |
|
128 | - * @see ConvertHelper_StorageSizeEnum_Size |
|
129 | - */ |
|
123 | + /** |
|
124 | + * Retrieves the detected storage size instance, if |
|
125 | + * the size string is valid. |
|
126 | + * |
|
127 | + * @return ConvertHelper_StorageSizeEnum_Size|NULL |
|
128 | + * @see ConvertHelper_StorageSizeEnum_Size |
|
129 | + */ |
|
130 | 130 | public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size |
131 | 131 | { |
132 | 132 | if($this->isValid()) { |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | return null; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * Checks whether the size notation was valid and could be parsed |
|
141 | - * into a meaningful byte value. If this returns `false`, it is |
|
142 | - * possible to use the `getErrorXXX` methods to retrieve information |
|
143 | - * on what went wrong. |
|
144 | - * |
|
145 | - * @return bool |
|
146 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
147 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
148 | - */ |
|
139 | + /** |
|
140 | + * Checks whether the size notation was valid and could be parsed |
|
141 | + * into a meaningful byte value. If this returns `false`, it is |
|
142 | + * possible to use the `getErrorXXX` methods to retrieve information |
|
143 | + * on what went wrong. |
|
144 | + * |
|
145 | + * @return bool |
|
146 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
147 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
148 | + */ |
|
149 | 149 | public function isValid() : bool |
150 | 150 | { |
151 | 151 | return $this->valid; |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Retrieves the error message if the size notation validation failed. |
|
156 | - * |
|
157 | - * @return string |
|
158 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
159 | - */ |
|
154 | + /** |
|
155 | + * Retrieves the error message if the size notation validation failed. |
|
156 | + * |
|
157 | + * @return string |
|
158 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
159 | + */ |
|
160 | 160 | public function getErrorMessage() : string |
161 | 161 | { |
162 | 162 | return $this->errorMessage; |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
204 | - /** |
|
205 | - * Detects the units and the number in the size notation string. |
|
206 | - * Populates the `units` and `number` properties. |
|
207 | - * |
|
208 | - * @return bool Whether the string could be parsed successfully. |
|
209 | - */ |
|
204 | + /** |
|
205 | + * Detects the units and the number in the size notation string. |
|
206 | + * Populates the `units` and `number` properties. |
|
207 | + * |
|
208 | + * @return bool Whether the string could be parsed successfully. |
|
209 | + */ |
|
210 | 210 | protected function detectParts() : bool |
211 | 211 | { |
212 | 212 | $units = ConvertHelper_StorageSizeEnum::getSizeNames(); |
@@ -242,16 +242,16 @@ discard block |
||
242 | 242 | return true; |
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
246 | - * If the validation fails, this is used to store the reason for retrieval later. |
|
247 | - * |
|
248 | - * @param string $message |
|
249 | - * @param int $code |
|
250 | - * |
|
251 | - * @see ConvertHelper_SizeNotation::isValid() |
|
252 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
253 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
254 | - */ |
|
245 | + /** |
|
246 | + * If the validation fails, this is used to store the reason for retrieval later. |
|
247 | + * |
|
248 | + * @param string $message |
|
249 | + * @param int $code |
|
250 | + * |
|
251 | + * @see ConvertHelper_SizeNotation::isValid() |
|
252 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
253 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
254 | + */ |
|
255 | 255 | protected function setError(string $message, int $code) : void |
256 | 256 | { |
257 | 257 | $this->valid = false; |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | $this->errorCode = $code; |
260 | 260 | } |
261 | 261 | |
262 | - /** |
|
263 | - * Retrieves the error code, if the size notation validation failed. |
|
264 | - * |
|
265 | - * @return int |
|
266 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
267 | - */ |
|
262 | + /** |
|
263 | + * Retrieves the error code, if the size notation validation failed. |
|
264 | + * |
|
265 | + * @return int |
|
266 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
267 | + */ |
|
268 | 268 | public function getErrorCode() : int |
269 | 269 | { |
270 | 270 | return $this->errorCode; |