@@ -40,6 +40,9 @@ |
||
| 40 | 40 | |
| 41 | 41 | protected $_updated = false; |
| 42 | 42 | |
| 43 | + /** |
|
| 44 | + * @param string $name |
|
| 45 | + */ |
|
| 43 | 46 | public function __construct($name, SaitoCacheEngineInterface $CacheEngine = null, $options = []) { |
| 44 | 47 | $this->_settings = $options + $this->_settings; |
| 45 | 48 | $this->_now = time(); |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | if ($this->_settings['maxItems']) { |
| 50 | 50 | $this->_gcFuzzy = $this->_settings['maxItemsFuzzy']; |
| 51 | - $this->_gcMax = (int)($this->_settings['maxItems'] * (1 + $this->_gcFuzzy)); |
|
| 52 | - $this->_gcMin = (int)($this->_gcMax * (1 - $this->_gcFuzzy)); |
|
| 51 | + $this->_gcMax = (int) ($this->_settings['maxItems'] * (1 + $this->_gcFuzzy)); |
|
| 52 | + $this->_gcMin = (int) ($this->_gcMax * (1 - $this->_gcFuzzy)); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | protected function _sort() { |
| 195 | 195 | // keep items which were last used/updated |
| 196 | - uasort($this->_cache, function ($a, $b) { |
|
| 196 | + uasort($this->_cache, function($a, $b) { |
|
| 197 | 197 | if ($a['metadata']['content_last_updated'] === $b['metadata']['content_last_updated']) { |
| 198 | 198 | return 0; |
| 199 | 199 | } |
@@ -8,10 +8,16 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | protected $_CU; |
| 10 | 10 | |
| 11 | + /** |
|
| 12 | + * @return \Saito\User\ForumsUserInterface |
|
| 13 | + */ |
|
| 11 | 14 | public function getCurrentUser() { |
| 12 | 15 | return $this->_CU; |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + /** |
|
| 19 | + * @param \Saito\User\ForumsUserInterface $CU |
|
| 20 | + */ |
|
| 15 | 21 | public function setCurrentUser($CU) { |
| 16 | 22 | $this->_CU = $CU; |
| 17 | 23 | } |
@@ -19,8 +25,7 @@ discard block |
||
| 19 | 25 | /** |
| 20 | 26 | * Checks if answering an entry is allowed |
| 21 | 27 | * |
| 22 | - * @param array $entry |
|
| 23 | - * @return boolean |
|
| 28 | + * @return string|false |
|
| 24 | 29 | */ |
| 25 | 30 | public function isAnsweringForbidden() { |
| 26 | 31 | if ($this->isLocked()) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $timeLimit = (\Configure::read('Saito.Settings.edit_period') * 60) + strtotime($posting->get('time')); |
| 63 | 63 | $isOverTimeLimit = time() > $timeLimit; |
| 64 | 64 | |
| 65 | - $isUsersPosting = (int)$User->getId() === (int)$posting->get('user_id'); |
|
| 65 | + $isUsersPosting = (int) $User->getId() === (int) $posting->get('user_id'); |
|
| 66 | 66 | |
| 67 | 67 | if ($User->isMod()) { |
| 68 | 68 | // Mods |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function hasNewAnswers() { |
| 125 | 125 | if (!$this->isRoot()) { |
| 126 | - throw new \RuntimeException('Posting with id ' . $this->get('id') . ' is no root posting.'); |
|
| 126 | + throw new \RuntimeException('Posting with id '.$this->get('id').' is no root posting.'); |
|
| 127 | 127 | } |
| 128 | 128 | if (!isset($this->_CU['last_refresh'])) { |
| 129 | 129 | return false; |
@@ -63,6 +63,9 @@ |
||
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | + /** |
|
| 67 | + * @param integer $id |
|
| 68 | + */ |
|
| 66 | 69 | protected function _loginUser($id) { |
| 67 | 70 | // see: http://stackoverflow.com/a/10411128/1372085 |
| 68 | 71 | $this->_logoutUser(); |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | public function assertRedirectedTo($url = '') { |
| 84 | 84 | $this->assertEquals( |
| 85 | 85 | $this->headers['Location'], |
| 86 | - \Router::fullBaseUrl() . $this->controller->request->webroot . $url |
|
| 86 | + \Router::fullBaseUrl().$this->controller->request->webroot.$url |
|
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -76,6 +76,9 @@ |
||
| 76 | 76 | return $out; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | + /** |
|
| 80 | + * @param \Saito\Posting\PostingInterface $node |
|
| 81 | + */ |
|
| 79 | 82 | protected function _renderThreadLine($node, array $posting, $level) { |
| 80 | 83 | $id = $posting['Entry']['id']; |
| 81 | 84 | $useLineCache = $level > 0 && $this->_LineCache; |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | $categoryId = $posting['Category']['id']; |
| 95 | 95 | if (!isset(self::$_catL10n[$categoryId])) { |
| 96 | 96 | $accession = $posting['Category']['accession']; |
| 97 | - $catAcs = h(__d('nondynamic', 'category_acs_' . $accession . '_exp')); |
|
| 97 | + $catAcs = h(__d('nondynamic', 'category_acs_'.$accession.'_exp')); |
|
| 98 | 98 | $catDesc = h($posting['Category']['description']); |
| 99 | 99 | $catTitle = h($posting['Category']['category']); |
| 100 | 100 | $category = <<<EOF |
@@ -9,6 +9,9 @@ |
||
| 9 | 9 | |
| 10 | 10 | protected $_Cookie; |
| 11 | 11 | |
| 12 | + /** |
|
| 13 | + * @param \CurrentUserComponent $CurrentUser |
|
| 14 | + */ |
|
| 12 | 15 | public function write($CurrentUser) { |
| 13 | 16 | $cookie = [ |
| 14 | 17 | 'id' => $CurrentUser->getId(), |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * is last refresh newer than $timestamp |
| 26 | 26 | * |
| 27 | 27 | * @param mixed $timestamp int unix-timestamp or date as string |
| 28 | - * @return mixed bool or null if not determinable |
|
| 28 | + * @return null|boolean bool or null if not determinable |
|
| 29 | 29 | */ |
| 30 | 30 | public function isNewerThan($timestamp) { |
| 31 | 31 | if (is_string($timestamp)) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * Increments value of a field |
| 126 | 126 | * |
| 127 | 127 | * @param $id |
| 128 | - * @param $field |
|
| 128 | + * @param string $field |
|
| 129 | 129 | * @param int $amount |
| 130 | 130 | * @throws InvalidArgumentException |
| 131 | 131 | */ |
@@ -197,6 +197,9 @@ discard block |
||
| 197 | 197 | $this->dispatchSaitoEvent($event, $data); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | + /** |
|
| 201 | + * @param string $event |
|
| 202 | + */ |
|
| 200 | 203 | public function dispatchSaitoEvent($event, $data) { |
| 201 | 204 | if (!$this->_SEM) { |
| 202 | 205 | $this->_SEM = SaitoEventManager::getInstance(); |
@@ -225,7 +228,7 @@ discard block |
||
| 225 | 228 | * |
| 226 | 229 | * falls back to local definition if available |
| 227 | 230 | * |
| 228 | - * @param $name |
|
| 231 | + * @param string $name |
|
| 229 | 232 | * @return mixed |
| 230 | 233 | * @throws UnexpectedValueException |
| 231 | 234 | */ |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function requireFields(&$data, array $required) { |
| 76 | 76 | return $this->_mapFields($data, $required, |
| 77 | - function (&$data, $model, $field) { |
|
| 77 | + function(&$data, $model, $field) { |
|
| 78 | 78 | if (!isset($data[$model][$field])) { |
| 79 | 79 | return false; |
| 80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function unsetFields(&$data, array $unset = ['id']) { |
| 86 | 86 | return $this->_mapFields($data, $unset, |
| 87 | - function (&$data, $model, $field) { |
|
| 87 | + function(&$data, $model, $field) { |
|
| 88 | 88 | if (isset($data[$model][$field])) { |
| 89 | 89 | unset($data[$model][$field]); |
| 90 | 90 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | $operator = '-'; |
| 139 | 139 | $amount *= -1; |
| 140 | 140 | } |
| 141 | - $field = $this->alias . '.' . $field; |
|
| 141 | + $field = $this->alias.'.'.$field; |
|
| 142 | 142 | $this->updateAll([$field => "$field $operator $amount"], |
| 143 | - [$this->alias . '.id' => $id]); |
|
| 143 | + [$this->alias.'.id' => $id]); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | public function pipeMerger(array $data) { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | protected static function _anonymizeIp($ip) { |
| 214 | 214 | $strlen = strlen($ip); |
| 215 | 215 | if ($strlen > 6) : |
| 216 | - $divider = (int)floor($strlen / 4) + 1; |
|
| 216 | + $divider = (int) floor($strlen / 4) + 1; |
|
| 217 | 217 | $ip = substr_replace($ip, '…', $divider, $strlen - (2 * $divider)); |
| 218 | 218 | endif; |
| 219 | 219 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @throws UnexpectedValueException |
| 231 | 231 | */ |
| 232 | 232 | protected function _setting($name) { |
| 233 | - $setting = Configure::read('Saito.Settings.' . $name); |
|
| 233 | + $setting = Configure::read('Saito.Settings.'.$name); |
|
| 234 | 234 | if ($setting !== null) { |
| 235 | 235 | return $setting; |
| 236 | 236 | } |
@@ -78,8 +78,8 @@ |
||
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * |
| 81 | - * @param int $entry_id |
|
| 82 | - * @param int $user_id |
|
| 81 | + * @param int $entryId |
|
| 82 | + * @param int $userId |
|
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | 85 | public function isBookmarked($entryId, $userId) { |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | public function validateUniqueBookmark() { |
| 72 | 72 | $fields = array( |
| 73 | - $this->alias . '.user_id' => $this->data['Bookmark']['user_id'], |
|
| 74 | - $this->alias . '.entry_id' => $this->data['Bookmark']['entry_id'], |
|
| 73 | + $this->alias.'.user_id' => $this->data['Bookmark']['user_id'], |
|
| 74 | + $this->alias.'.entry_id' => $this->data['Bookmark']['entry_id'], |
|
| 75 | 75 | ); |
| 76 | 76 | return $this->isUnique($fields, false); |
| 77 | 77 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | array( |
| 89 | 89 | 'contain' => false, |
| 90 | 90 | 'conditions' => array( |
| 91 | - $this->alias . '.entry_id' => $entryId, |
|
| 92 | - $this->alias . '.user_id' => $userId, |
|
| 91 | + $this->alias.'.entry_id' => $entryId, |
|
| 92 | + $this->alias.'.user_id' => $userId, |
|
| 93 | 93 | ) |
| 94 | 94 | ) |
| 95 | 95 | ); |
@@ -518,7 +518,7 @@ |
||
| 518 | 518 | /** |
| 519 | 519 | * trees for multiple tids |
| 520 | 520 | * |
| 521 | - * @param $ids |
|
| 521 | + * @param integer[] $ids |
|
| 522 | 522 | * @param null $order |
| 523 | 523 | * @param null $fieldlist |
| 524 | 524 | * @return array|bool false if no threads or array with Posting |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | 'category_id' => $User->Categories->getAllowed() |
| 212 | 212 | ]; |
| 213 | 213 | |
| 214 | - $_cacheKey = 'Entry.recentEntries-' . md5(serialize($options)); |
|
| 214 | + $_cacheKey = 'Entry.recentEntries-'.md5(serialize($options)); |
|
| 215 | 215 | $_cachedEntry = Cache::read($_cacheKey, 'entries'); |
| 216 | 216 | if ($_cachedEntry) { |
| 217 | 217 | Stopwatch::stop('Model->User->getRecentEntries()'); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | ] |
| 262 | 262 | ); |
| 263 | 263 | if ($entry == false) { |
| 264 | - throw new UnexpectedValueException('Posting not found. Posting-Id: ' . $id); |
|
| 264 | + throw new UnexpectedValueException('Posting not found. Posting-Id: '.$id); |
|
| 265 | 265 | } |
| 266 | 266 | return $entry['Entry']['tid']; |
| 267 | 267 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public function get($id) { |
| 273 | 273 | return $this->find('entry', |
| 274 | - ['conditions' => [$this->alias . '.id' => $id]]); |
|
| 274 | + ['conditions' => [$this->alias.'.id' => $id]]); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | ] |
| 291 | 291 | ); |
| 292 | 292 | if ($entry == false) { |
| 293 | - throw new UnexpectedValueException('Posting not found. Posting-Id: ' . $id); |
|
| 293 | + throw new UnexpectedValueException('Posting not found. Posting-Id: '.$id); |
|
| 294 | 294 | } |
| 295 | 295 | return $entry['Entry']['pid']; |
| 296 | 296 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $tree = $this->treesForThreads([$tid], null, $fields); |
| 510 | 510 | |
| 511 | - if ((int)$tid !== (int)$id) { |
|
| 511 | + if ((int) $tid !== (int) $id) { |
|
| 512 | 512 | $tree = $this->treeGetSubtree($tree, $id); |
| 513 | 513 | } |
| 514 | 514 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $threads = []; |
| 552 | 552 | $entries = $this->treeBuild($entries); |
| 553 | 553 | foreach ($entries as $thread) { |
| 554 | - $id = (int)$thread['Entry']['tid']; |
|
| 554 | + $id = (int) $thread['Entry']['tid']; |
|
| 555 | 555 | $threads[$id] = $thread; |
| 556 | 556 | } |
| 557 | 557 | } |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | $root = $this->get($entry['Entry']['tid']); |
| 610 | - if ((int)$root['User']['id'] !== $this->CurrentUser->getId()) { |
|
| 610 | + if ((int) $root['User']['id'] !== $this->CurrentUser->getId()) { |
|
| 611 | 611 | throw new ForbiddenException; |
| 612 | 612 | } |
| 613 | 613 | |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $_idsToDelete = $this->getIdsForNode($id); |
| 693 | 693 | $success = $this->deleteAll( |
| 694 | - [$this->alias . '.id' => $_idsToDelete], |
|
| 694 | + [$this->alias.'.id' => $_idsToDelete], |
|
| 695 | 695 | true, |
| 696 | 696 | true |
| 697 | 697 | ); |
@@ -723,8 +723,8 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function getIdsForNode($id) { |
| 725 | 725 | $subthread = $this->treeForNode($id); |
| 726 | - $func = function (&$tree, &$entry) { |
|
| 727 | - $tree['ids'][] = (int)$entry['Entry']['id']; |
|
| 726 | + $func = function(&$tree, &$entry) { |
|
| 727 | + $tree['ids'][] = (int) $entry['Entry']['id']; |
|
| 728 | 728 | }; |
| 729 | 729 | Entry::mapTreeElements($subthread, $func); |
| 730 | 730 | sort($subthread['ids']); |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | // propagate pinned property from target to source |
| 844 | - $isTargetPinned = (bool)$targetEntry[$this->alias]['locked']; |
|
| 844 | + $isTargetPinned = (bool) $targetEntry[$this->alias]['locked']; |
|
| 845 | 845 | if ($sourceEntry[$this->alias]['locked'] !== $isTargetPinned) { |
| 846 | 846 | $this->id = $targetEntry[$this->alias]['tid']; |
| 847 | 847 | $this->_threadLock($isTargetPinned); |
@@ -1036,8 +1036,8 @@ discard block |
||
| 1036 | 1036 | $oldEntry = $this->find('first', |
| 1037 | 1037 | ['contain' => false, 'conditions' => ['Entry.id' => $this->id]]); |
| 1038 | 1038 | |
| 1039 | - if ($oldEntry && (int)$oldEntry[$this->alias]['pid'] === 0) { |
|
| 1040 | - $categoryChanged = (int)$this->data[$this->alias]['category_id'] !== (int)$oldEntry[$this->alias]['category_id']; |
|
| 1039 | + if ($oldEntry && (int) $oldEntry[$this->alias]['pid'] === 0) { |
|
| 1040 | + $categoryChanged = (int) $this->data[$this->alias]['category_id'] !== (int) $oldEntry[$this->alias]['category_id']; |
|
| 1041 | 1041 | if ($categoryChanged) { |
| 1042 | 1042 | $success = $success && $this->_threadChangeCategory( |
| 1043 | 1043 | $oldEntry[$this->alias]['tid'], |