ソースを参照

Fix phpstan errors.

dereuromark 8 年 前
コミット
ab0ba34ab8

+ 4 - 7
src/Controller/Component/MobileComponent.php

@@ -6,6 +6,7 @@ use Cake\Controller\Controller;
 use Cake\Core\Configure;
 use Cake\Event\Event;
 use Cake\Routing\Router;
+use RuntimeException;
 use Shim\Controller\Component\Component;
 
 /**
@@ -59,8 +60,6 @@ class MobileComponent extends Component {
 	];
 
 	/**
-	 * MobileComponent::initialize()
-	 *
 	 * @param array $config
 	 * @return void
 	 */
@@ -74,8 +73,6 @@ class MobileComponent extends Component {
 	}
 
 	/**
-	 * MobileComponent::startup()
-	 *
 	 * @param \Cake\Event\Event $event
 	 * @return void
 	 */
@@ -102,11 +99,11 @@ class MobileComponent extends Component {
 
 		if ($mobileOverwrite !== null) {
 			if ($mobileOverwrite === '-1') {
-				$noMobile = null;
+				$this->request->session()->delete('User.mobile');
 			} else {
 				$wantsMobile = (bool)$mobileOverwrite;
+				$this->request->session()->write('User.mobile', (int)$wantsMobile);
 			}
-			$this->request->session()->write('User.mobile', (int)$wantsMobile);
 		}
 		$this->isMobile();
 
@@ -209,7 +206,7 @@ class MobileComponent extends Component {
 		if (is_callable($this->_config['engine'])) {
 			return call_user_func($this->_config['engine']);
 		}
-		throw new CakeException(sprintf('Engine %s not available', $this->_config['engine']));
+		throw new RuntimeException(sprintf('Engine %s not available', $this->_config['engine']));
 	}
 
 }

+ 2 - 0
src/Controller/ShuntRequestController.php

@@ -17,6 +17,8 @@ use RuntimeException;
  * Mapping
  *
  * de => ['locale' => 'de_DE', 'name' => 'Deutsch'], ...
+ *
+ * @property \Cake\Controller\Component\FlashComponent $Flash
  */
 class ShuntRequestController extends AppController {
 

+ 1 - 1
src/Model/Behavior/JsonableBehavior.php

@@ -287,7 +287,7 @@ class JsonableBehavior extends Behavior {
 		$leftBound = $this->_config['leftBound'];
 		$rightBound = $this->_config['rightBound'];
 
-		return Text::tokenize($val, $separator, $leftBound, $rightBound);
+		return (array)Text::tokenize($val, $separator, $leftBound, $rightBound);
 	}
 
 	/**

+ 3 - 2
src/Model/Behavior/ResetBehavior.php

@@ -103,9 +103,10 @@ class ResetBehavior extends Behavior {
 				$defaults['fields'][] = $this->_table->alias() . '.' . $this->_table->displayField();
 			}
 		}
+
+		$updateFields = [];
 		if (!$this->_config['updateTimestamp']) {
 			$fields = ['modified', 'updated'];
-			$updateFields = [];
 			foreach ($fields as $field) {
 				if ($this->_table->schema()->column($field)) {
 					$defaults['fields'][] = $field;
@@ -150,7 +151,7 @@ class ResetBehavior extends Behavior {
 
 				$res = $this->_table->save($record, compact('validate', 'fieldList'));
 				if (!$res) {
-					throw new RuntimeException(print_r($this->_table->errors(), true));
+					throw new RuntimeException(print_r($record->errors(), true));
 				}
 				$modified++;
 			}

+ 4 - 3
src/Model/Behavior/SluggedBehavior.php

@@ -131,11 +131,11 @@ class SluggedBehavior extends Behavior {
 				if (strpos($field, '.')) {
 					list($alias, $field) = explode('.', $field);
 					if (!$this->_table->$alias->hasField($field)) {
-						throw new RuntimeException('(SluggedBehavior::setup) model ' . $this->_table->$alias->name . ' is missing the field ' . $field .
-							' (specified in the setup for model ' . $this->_table->name . ') ');
+						throw new RuntimeException('(SluggedBehavior::setup) model ' . $this->_table->$alias->alias() . ' is missing the field ' . $field .
+							' (specified in the setup for model ' . $this->_table->alias() . ') ');
 					}
 				} elseif (!$this->_table->hasField($field) && !method_exists($this->_table->entityClass(), '_get' . Inflector::classify($field))) {
-					throw new RuntimeException('(SluggedBehavior::setup) model ' . $this->_table->name . ' is missing the field ' . $field . ' specified in the setup.');
+					throw new RuntimeException('(SluggedBehavior::setup) model ' . $this->_table->alias() . ' is missing the field ' . $field . ' specified in the setup.');
 				}
 			}
 		}
@@ -397,6 +397,7 @@ class SluggedBehavior extends Behavior {
 
 		$locale = [];
 		foreach ($fields as $locale => $_) {
+			$res = null;
 			foreach ($label as $field) {
 				$res = $entity->get($field);
 				if (is_array($entity->get($field))) {

+ 1 - 1
src/Model/Table/TokensTable.php

@@ -190,7 +190,7 @@ class TokensTable extends Table {
 	 * Remove old/invalid keys
 	 * does not remove recently used ones (for proper feedback)!
 	 *
-	 * @return bool success
+	 * @return int Rows
 	 */
 	public function garbageCollector() {
 		$conditions = [

+ 2 - 2
src/Utility/Number.php

@@ -262,11 +262,11 @@ class Number extends CakeNumber {
 	 * Get the settings for a specific formatName
 	 *
 	 * @param string $formatName (EUR, ...)
-	 * @return array currencySettings or null on failure
+	 * @return array currencySettings
 	 */
 	public static function getFormat($formatName) {
 		if (!isset(static::$_currencies[$formatName])) {
-			return null;
+			return [];
 		}
 		return static::$_currencies[$formatName];
 	}

+ 2 - 2
src/Utility/Utility.php

@@ -651,9 +651,9 @@ class Utility {
 	}
 
 	/**
-	 * @var int
+	 * @var float
 	 */
-	protected static $_counterStartTime;
+	protected static $_counterStartTime = 0.0;
 
 	/**
 	 * Returns microtime as float value

+ 4 - 2
src/View/Helper/CommonHelper.php

@@ -10,6 +10,8 @@ use Cake\View\Helper;
  * Common helper
  *
  * @author Mark Scherer
+ * @property \Cake\View\Helper\HtmlHelper $Html
+ * @property \Cake\View\Helper\UrlHelper $Url
  */
 class CommonHelper extends Helper {
 
@@ -71,10 +73,10 @@ class CommonHelper extends Helper {
 		}
 		$content = [];
 		if ($type === 'public') {
-			$this->privatePage = false;
+			//$this->privatePage = false;
 			$content['robots'] = ['index', 'follow', 'noarchive'];
 		} else {
-			$this->privatePage = true;
+			//$this->privatePage = true;
 			$content['robots'] = ['noindex', 'nofollow', 'noarchive'];
 		}
 

+ 3 - 2
src/View/Helper/FormatHelper.php

@@ -15,6 +15,7 @@ use Cake\View\View;
  *
  * @author Mark Scherer
  * @license MIT
+ * @property \Cake\View\Helper\HtmlHelper $Html
  */
 class FormatHelper extends Helper {
 
@@ -634,8 +635,8 @@ class FormatHelper extends Helper {
 		$options += $defaults;
 
 		// Sanity check
-		if (empty($array) || !is_array($array)) {
-			return false;
+		if (empty($array)) {
+			return '';
 		}
 
 		if (!isset($array[0]) || !is_array($array[0])) {

+ 1 - 0
src/View/Helper/GravatarHelper.php

@@ -13,6 +13,7 @@ use Cake\View\Helper;
  * @copyright Copyright 2009-2010, Graham Weldon (http://grahamweldon.com)
  * @license http://opensource.org/licenses/mit-license.php MIT
  * @author Mark Scherer
+ * @property \Cake\View\Helper\HtmlHelper $Html
  */
 class GravatarHelper extends Helper {
 

+ 2 - 0
src/View/Helper/ObfuscateHelper.php

@@ -11,6 +11,7 @@ use Cake\View\Helper;
  *
  * @author Mark Scherer
  * @license MIT
+ * @property \Cake\View\Helper\HtmlHelper $Html
  */
 class ObfuscateHelper extends Helper {
 
@@ -86,6 +87,7 @@ class ObfuscateHelper extends Helper {
 
 		$len = mb_strlen($xmail1);
 		$i = 0;
+		$par = [];
 		while ($i < $len) {
 			$c = mt_rand(2, 6);
 			$par[] = (mb_substr($xmail1, $i, $c));

+ 3 - 0
src/View/Helper/QrCodeHelper.php

@@ -22,6 +22,9 @@ use Cake\View\View;
  * NOTE: urls have a 2k limit - for the total amount of 4296 chars (7089 for numeric values only) you will need to send it via post
  *
  * TODO: set size according to text length automatically
+ *
+ * @property \Cake\View\Helper\HtmlHelper $Html
+ * @property \Cake\View\Helper\UrlHelper $Url
  */
 class QrCodeHelper extends Helper {
 

+ 1 - 0
src/View/Helper/TimeHelper.php

@@ -11,6 +11,7 @@ use DateTime;
  * Wrapper for TimeHelper and TimeLib
  *
  * @mixin \Tools\Utility\Time
+ * @property \Cake\View\Helper\HtmlHelper $Html
  */
 class TimeHelper extends CakeTimeHelper {