dereuromark 9 years ago
parent
commit
a0aa22278d

+ 3 - 1
src/Controller/Controller.php

@@ -6,7 +6,9 @@ use Cake\Core\Configure;
 use Shim\Controller\Controller as ShimController;
 
 /**
- * DRY Controller stuff
+ * @property \Tools\Controller\Component\FlashComponent $Flash
+ * @property \Tools\Controller\Component\CommonComponent $Common
+ * @property \Tools\Controller\Component\AuthUserComponent $AuthUser
  */
 class Controller extends ShimController {
 

+ 2 - 2
src/Mailer/Email.php

@@ -158,7 +158,7 @@ class Email extends CakeEmail {
 	 * Overwrite to allow mimetype detection
 	 *
 	 * @param mixed|null $attachments
-	 * @return $this
+	 * @return array|$this
 	 */
 	public function attachments($attachments = null) {
 		if ($attachments === null) {
@@ -246,7 +246,7 @@ class Email extends CakeEmail {
 	 * @param string|null $name (optional)
 	 * @param string|null $contentId (optional)
 	 * @param array $options Options
-	 * @return string|$this $contentId or $this
+	 * @return string|$this CID or $this
 	 */
 	public function addEmbeddedAttachment($file, $name = null, $contentId = null, array $options = []) {
 		if (empty($name)) {

+ 4 - 4
src/Model/Entity/Entity.php

@@ -11,10 +11,10 @@ class Entity extends CakeEntity {
 	 * Now also supports reordering/filtering
 	 *
 	 * @link http://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/
-	 * @param string $value or array $keys or NULL for complete array result
-	 * @param array $options (actual data)
-	 * @param string|null $default
-	 * @return mixed string/array
+	 * @param string|array|null $value Integer or array of keys or NULL for complete array result
+	 * @param array $options Options
+	 * @param string|null $default Default value
+	 * @return string|array
 	 */
 	public static function enum($value, array $options, $default = null) {
 		if ($value !== null && !is_array($value)) {

+ 11 - 7
src/Model/Table/Table.php

@@ -99,7 +99,7 @@ class Table extends ShimTable {
 	 * @param string|null $groupField Field to group by
 	 * @param string $type Find type
 	 * @param array $options
-	 * @return array
+	 * @return \Cake\ORM\Query
 	 */
 	public function getRelatedInUse($tableName, $groupField = null, $type = 'all', $options = []) {
 		if ($groupField === null) {
@@ -123,7 +123,7 @@ class Table extends ShimTable {
 	 * @param string $groupField Field to group by
 	 * @param string $type Find type
 	 * @param array $options
-	 * @return array
+	 * @return \Cake\ORM\Query
 	 */
 	public function getFieldInUse($groupField, $type = 'all', array $options = []) {
 		$defaults = [
@@ -146,7 +146,7 @@ class Table extends ShimTable {
 	 * - cast: if casting should be applied to both values
 	 *
 	 * @param mixed $value
-	 * @param array $options
+	 * @param array|string $options
 	 * @param array $context
 	 * @return bool Success
 	 */
@@ -183,7 +183,7 @@ class Table extends ShimTable {
 	 * @return bool Success
 	 */
 	public function validateUrl($url, array $options = [], array $context = []) {
-		if (empty($url)) {
+		if (!$url) {
 			if (!empty($options['allowEmpty']) && empty($options['required'])) {
 				return true;
 			}
@@ -220,7 +220,7 @@ class Table extends ShimTable {
 	 * Prepend protocol if missing
 	 *
 	 * @param string $url
-	 * @return string Url
+	 * @return string URL
 	 */
 	protected function _autoCompleteUrl($url) {
 		if (mb_strpos($url, '/') === 0) {
@@ -375,13 +375,17 @@ class Table extends ShimTable {
 			$days = !empty($options['min']) ? $options['min'] : 0;
 			if (!empty($options['after']) && isset($context['data'][$options['after']])) {
 				$compare = $value->subDays($days);
-				if ($context['data'][$options['after']]->gt($compare)) {
+				/** @var \Cake\I18n\Time $after */
+				$after = $context['data'][$options['after']];
+				if ($after->gt($compare)) {
 					return false;
 				}
 			}
 			if (!empty($options['before']) && isset($context['data'][$options['before']])) {
 				$compare = $value->addDays($days);
-				if ($context['data'][$options['before']]->lt($compare)) {
+				/** @var \Cake\I18n\Time $before */
+				$before = $context['data'][$options['before']];
+				if ($before->lt($compare)) {
 					return false;
 				}
 			}

+ 9 - 10
src/Model/Table/TokensTable.php

@@ -76,11 +76,11 @@ class TokensTable extends Table {
 	 * @return string key on SUCCESS, boolean false otherwise
 	 */
 	public function newKey($type, $key = null, $uid = null, $content = null) {
-		if (empty($type)) {
+		if (!$type) {
 			return false;
 		}
 
-		if (empty($key)) {
+		if (!$key) {
 			$key = $this->generateKey($this->defaultLength);
 			$keyLength = $this->defaultLength;
 		} else {
@@ -118,21 +118,21 @@ class TokensTable extends Table {
 	 * @param string $key : necessary
 	 * @param mixed|null $uid : needs to be provided if this key has a user_id stored
 	 * @param bool $treatUsedAsInvalid
-	 * @return array Content - if successfully used or if already used (used=1), FALSE else
+	 * @return array|false Content - if successfully used or if already used (used=1), FALSE else
 	 */
 	public function useKey($type, $key, $uid = null, $treatUsedAsInvalid = false) {
-		if (empty($type) || empty($key)) {
+		if (!$type || !$key) {
 			return false;
 		}
 		$options = ['conditions' => [$this->alias() . '.key' => $key, $this->alias() . '.type' => $type]];
-		if (!empty($uid)) {
+		if ($uid) {
 			$options['conditions'][$this->alias() . '.user_id'] = $uid;
 		}
 		$res = $this->find('first', $options);
-		if (empty($res)) {
+		if (!$res) {
 			return false;
 		}
-		if (!empty($uid) && !empty($res['user_id']) && $res['user_id'] != $uid) {
+		if ($uid && !empty($res['user_id']) && $res['user_id'] != $uid) {
 			// return $res; # more secure to fail here if user_id is not provided, but was submitted prev.
 			return false;
 		}
@@ -152,7 +152,6 @@ class TokensTable extends Table {
 		if (!empty($res['unlimited'])) {
 			return $res;
 		}
-		//$this->log('VIOLATION in ' . $this->alias() . ' Model (method useKey)');
 		return false;
 	}
 
@@ -163,7 +162,7 @@ class TokensTable extends Table {
 	 * @return bool Success
 	 */
 	public function spendKey($id) {
-		if (empty($id)) {
+		if (!$id) {
 			return false;
 		}
 
@@ -218,7 +217,7 @@ class TokensTable extends Table {
 	 * @return string Key
 	 */
 	public function generateKey($length = null) {
-		if (empty($length)) {
+		if (!$length) {
 			$length = $this->defaultLength;
 		}