浏览代码

Fix up for CakePHP 4.3

mscherer 4 年之前
父节点
当前提交
6bddc5f7e9

+ 1 - 1
composer.json

@@ -47,7 +47,7 @@
 	},
 	"scripts": {
 		"stan": "phpstan analyse",
-		"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.1 && mv composer.backup composer.json",
+		"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.0.0 && mv composer.backup composer.json",
 		"test": "phpunit",
 		"test-coverage": "phpunit --log-junit webroot/coverage/unitreport.xml --coverage-html webroot/coverage --coverage-clover webroot/coverage/coverage.xml",
 		"lowest": "validate-prefer-lowest",

+ 1 - 1
phpstan.neon

@@ -6,7 +6,7 @@ parameters:
 	checkGenericClassInNonGenericObjectType: false
 	bootstrapFiles:
 		- %rootDir%/../../../tests/bootstrap.php
-	excludes_analyse:
+	excludePaths:
 		- %rootDir%/../../../src/TestSuite/*
 		- %rootDir%/../../../src/Utility/Mime
 	reportUnmatchedIgnoredErrors: false

+ 1 - 1
src/Controller/Component/MobileComponent.php

@@ -49,7 +49,7 @@ class MobileComponent extends Component {
 	/**
 	 * Default values. Can also be set using Configure.
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'on' => 'beforeFilter', // initialize (prior to controller's beforeRender) or startup

+ 5 - 2
src/Controller/Component/RefererRedirectComponent.php

@@ -14,10 +14,13 @@ use Cake\Http\Response;
  */
 class RefererRedirectComponent extends Component {
 
+	/**
+	 * @var string
+	 */
 	public const QUERY_REFERER = 'ref';
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'actions' => [],
@@ -25,7 +28,7 @@ class RefererRedirectComponent extends Component {
 
 	/**
 	 * @param \Cake\Event\EventInterface $event
-	 * @param string|array $url A string or array containing the redirect location
+	 * @param array|string $url A string or array containing the redirect location
 	 * @param \Cake\Http\Response $response The response object.
 	 *
 	 * @return \Cake\Http\Response|null

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

@@ -25,7 +25,7 @@ class AfterSaveBehavior extends Behavior {
 	protected $_entity;
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 	];

+ 8 - 8
src/Model/Behavior/BitmaskedBehavior.php

@@ -35,7 +35,7 @@ class BitmaskedBehavior extends Behavior {
 	/**
 	 * Default config
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'field' => 'status',
@@ -209,7 +209,7 @@ class BitmaskedBehavior extends Behavior {
 
 	/**
 	 * @param int $value Bitmask.
-	 * @return int[] Bitmask array (from DB to APP).
+	 * @return array<int> Bitmask array (from DB to APP).
 	 */
 	public function decodeBitmask($value) {
 		$res = [];
@@ -225,7 +225,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int[] $value Bitmask array.
+	 * @param array<int> $value Bitmask array.
 	 * @param mixed|null $defaultValue Default bitmask value.
 	 * @return int|null Bitmask (from APP to DB).
 	 */
@@ -342,7 +342,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int|int[] $bits
+	 * @param array<int>|int $bits
 	 * @return array SQL snippet.
 	 */
 	public function isBit($bits) {
@@ -355,7 +355,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int|int[] $bits
+	 * @param array<int>|int $bits
 	 * @return array SQL snippet.
 	 */
 	public function isNotBit($bits) {
@@ -363,7 +363,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int|int[] $bits
+	 * @param array<int>|int $bits
 	 * @return array SQL snippet.
 	 */
 	public function containsBit($bits) {
@@ -371,7 +371,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int|int[] $bits
+	 * @param array<int>|int $bits
 	 * @return array SQL snippet.
 	 */
 	public function containsNotBit($bits) {
@@ -379,7 +379,7 @@ class BitmaskedBehavior extends Behavior {
 	}
 
 	/**
-	 * @param int|int[] $bits
+	 * @param array<int>|int $bits
 	 * @param bool $contain
 	 * @return array SQL snippet.
 	 */

+ 2 - 2
src/Model/Behavior/ConfirmableBehavior.php

@@ -20,7 +20,7 @@ use Cake\Validation\Validator;
 class ConfirmableBehavior extends Behavior {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'message' => null,
@@ -71,7 +71,7 @@ class ConfirmableBehavior extends Behavior {
 				//'provider' => 'table',
 				'requirePresence' => true,
 				'allowEmpty' => false,
-				'last' => true]
+				'last' => true],
 		);
 		$validator->requirePresence($field);
 	}

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

@@ -46,7 +46,7 @@ class JsonableBehavior extends Behavior {
 	/**
 	 * //TODO: json input/ouput directly, clean
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'fields' => [], // Fields to convert
@@ -214,7 +214,7 @@ class JsonableBehavior extends Behavior {
 	/**
 	 * Fields are absolutely necessary to function properly!
 	 *
-	 * @param string|array|null $val
+	 * @param array|string|null $val
 	 * @return array|false|null
 	 */
 	public function _decode($val) {
@@ -280,7 +280,7 @@ class JsonableBehavior extends Behavior {
 	/**
 	 * array() => value1|value2|value3|...
 	 *
-	 * @param string[] $val
+	 * @param array<string> $val
 	 * @return string
 	 */
 	public function _toList($val) {
@@ -290,7 +290,7 @@ class JsonableBehavior extends Behavior {
 	/**
 	 * @param string $val
 	 *
-	 * @return string[]
+	 * @return array<string>
 	 */
 	public function _fromList($val) {
 		$separator = $this->_config['separator'];

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

@@ -12,7 +12,7 @@ use InvalidArgumentException;
 class NeighborBehavior extends Behavior {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 	];

+ 2 - 2
src/Model/Behavior/PasswordableBehavior.php

@@ -38,7 +38,7 @@ if (!defined('PWD_MAX_LENGTH')) {
 class PasswordableBehavior extends Behavior {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'field' => 'password',
@@ -474,7 +474,7 @@ class PasswordableBehavior extends Behavior {
 	}
 
 	/**
-	 * @param string|array $hasher Name or options array.
+	 * @param array|string $hasher Name or options array.
 	 * @param array $options
 	 * @return \Cake\Auth\AbstractPasswordHasher
 	 */

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

@@ -45,7 +45,7 @@ use RuntimeException;
 class ResetBehavior extends Behavior {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'limit' => 100, // batch of records per loop

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

@@ -26,7 +26,14 @@ use Shim\Utility\Inflector as ShimInflector;
  */
 class SluggedBehavior extends Behavior {
 
+	/**
+	 * @var string
+	 */
 	public const MODE_URL = 'url';
+
+	/**
+	 * @var string
+	 */
 	public const MODE_ASCII = 'ascii';
 
 	/**
@@ -64,7 +71,7 @@ class SluggedBehavior extends Behavior {
 	 * - scope: certain conditions to use as scope
 	 * - tidy: If cleanup should be run on slugging
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'label' => null,
@@ -215,7 +222,7 @@ class SluggedBehavior extends Behavior {
 	 * @return void
 	 */
 	public function slug(EntityInterface $entity, array $options = []) {
-		$overwrite = isset($options['overwrite']) ? $options['overwrite'] : $this->_config['overwrite'];
+		$overwrite = $options['overwrite'] ?? $this->_config['overwrite'];
 		if (!$overwrite && $entity->get($this->_config['overwriteField'])) {
 			$overwrite = true;
 		}
@@ -455,8 +462,8 @@ class SluggedBehavior extends Behavior {
 	/**
 	 * Wrapper for preg replace taking care of encoding
 	 *
-	 * @param string|array $pattern
-	 * @param string|array $replace
+	 * @param array|string $pattern
+	 * @param array|string $replace
 	 * @param string $string
 	 * @return string
 	 */

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

@@ -29,7 +29,7 @@ class StringBehavior extends Behavior {
 	/**
 	 * //TODO: json input/ouput directly, clean
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'fields' => [], // Fields to convert

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

@@ -23,7 +23,7 @@ class ToggleBehavior extends Behavior {
 	/**
 	 * Default config
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'field' => 'primary',

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

@@ -16,7 +16,7 @@ use RuntimeException;
 class TypeMapBehavior extends Behavior {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'fields' => [], // Fields to change column type for

+ 8 - 1
src/Model/Behavior/TypographicBehavior.php

@@ -37,7 +37,14 @@ use Cake\ORM\Behavior;
  */
 class TypographicBehavior extends Behavior {
 
+	/**
+	 * @var string
+	 */
 	public const BEFORE_MARSHAL = 'marshal';
+
+	/**
+	 * @var string
+	 */
 	public const BEFORE_SAVE = 'save';
 
 	/**
@@ -81,7 +88,7 @@ class TypographicBehavior extends Behavior {
 	protected $_id;
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'before' => self::BEFORE_SAVE, // save or marshal

+ 2 - 2
src/Model/Table/Table.php

@@ -127,7 +127,7 @@ class Table extends ShimTable {
 		$defaults = [
 			'contain' => [$tableName],
 			'group' => $groupField,
-			'order' => isset($this->$tableName->order) ? $this->$tableName->order : [$tableName . '.' . $this->$tableName->getDisplayField() => 'ASC'],
+			'order' => $this->$tableName->order ?? [$tableName . '.' . $this->$tableName->getDisplayField() => 'ASC'],
 		];
 		if ($type === 'list') {
 			$propertyName = $this->getAssociation($tableName)->getProperty();
@@ -330,7 +330,7 @@ class Table extends ShimTable {
 
 		if (Validation::date($datePart, $format) && Validation::time($timePart)) {
 			// after/before?
-			$seconds = isset($options['min']) ? $options['min'] : 1;
+			$seconds = $options['min'] ?? 1;
 			if (!empty($options['after'])) {
 				if (!is_object($options['after']) && isset($context['data'][$options['after']])) {
 					$options['after'] = $context['data'][$options['after']];

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

@@ -14,10 +14,10 @@ use RuntimeException;
  * @license http://opensource.org/licenses/mit-license.php MIT
  * @method \Tools\Model\Entity\Token get($primaryKey, $options = [])
  * @method \Tools\Model\Entity\Token newEntity($data = null, array $options = [])
- * @method \Tools\Model\Entity\Token[] newEntities(array $data, array $options = [])
+ * @method array<\Tools\Model\Entity\Token> newEntities(array $data, array $options = [])
  * @method \Tools\Model\Entity\Token|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
  * @method \Tools\Model\Entity\Token patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
- * @method \Tools\Model\Entity\Token[] patchEntities($entities, array $data, array $options = [])
+ * @method array<\Tools\Model\Entity\Token> patchEntities($entities, array $data, array $options = [])
  * @method \Tools\Model\Entity\Token findOrCreate($search, callable $callback = null, $options = [])
  */
 class TokensTable extends Table {
@@ -28,7 +28,7 @@ class TokensTable extends Table {
 	public $displayField = 'token_key';
 
 	/**
-	 * @var array
+	 * @var array<mixed, mixed>|string|null
 	 */
 	public $order = ['created' => 'DESC'];
 
@@ -82,7 +82,7 @@ class TokensTable extends Table {
 	 * @param string $type Type: necessary
 	 * @param string|null $key Key: optional key, otherwise a key will be generated
 	 * @param mixed|null $uid Uid: optional (if used, only this user can use this key)
-	 * @param string|array|null $content Content: up to 255 characters of content may be added (optional)
+	 * @param array|string|null $content Content: up to 255 characters of content may be added (optional)
 	 *
 	 * @return string|null Key on success, null otherwise
 	 */
@@ -123,7 +123,7 @@ class TokensTable extends Table {
 	 *
 	 * @param string $type : necessary
 	 * @param string $key : necessary
-	 * @param int|string|null $uid : needs to be provided if this key has a user_id stored
+	 * @param string|int|null $uid : needs to be provided if this key has a user_id stored
 	 * @param bool $treatUsedAsInvalid
 	 * @return \Tools\Model\Entity\Token|null Content - if successfully used or if already used (used=1), NULL otherwise.
 	 */
@@ -172,7 +172,7 @@ class TokensTable extends Table {
 		//$expression = new \Cake\Database\Expression\QueryExpression(['used = used + 1', 'modified' => date(FORMAT_DB_DATETIME)]);
 		$result = $this->updateAll(
 			['used = used + 1', 'modified' => date(FORMAT_DB_DATETIME)],
-			['id' => $id]
+			['id' => $id],
 		);
 		if ($result) {
 			return true;

+ 31 - 31
src/Utility/Time.php

@@ -17,7 +17,7 @@ use DateTimeInterface;
 class Time extends CakeTime {
 
 	/**
-	 * @param string|int|\DateTimeInterface|array|null $time Fixed or relative time
+	 * @param \DateTimeInterface|array|string|int|null $time Fixed or relative time
 	 * @param \DateTimeZone|string|null $tz The timezone for the instance
 	 */
 	public function __construct($time = null, $tz = null) {
@@ -40,7 +40,7 @@ class Time extends CakeTime {
 				empty($format) ? '' : ' ',
 				$value['hour'],
 				$value['minute'],
-				$value['second']
+				$value['second'],
 			);
 
 			$time = $format;
@@ -52,7 +52,7 @@ class Time extends CakeTime {
 	/**
 	 * Detect if a timezone has a DST
 	 *
-	 * @param string|\DateTimeZone|null $timezone User's timezone string or DateTimeZone object
+	 * @param \DateTimeZone|string|null $timezone User's timezone string or DateTimeZone object
 	 * @return bool
 	 */
 	public function hasDaylightSavingTime($timezone = null) {
@@ -97,8 +97,8 @@ class Time extends CakeTime {
 	 * Both dates default to current date. Note that start needs
 	 * to be before end for a valid result.
 	 *
-	 * @param int|string|\DateTimeInterface $start Start date (if empty, use today)
-	 * @param int|string|\DateTimeInterface|null $end End date (if empty, use today)
+	 * @param \DateTimeInterface|string|int $start Start date (if empty, use today)
+	 * @param \DateTimeInterface|string|int|null $end End date (if empty, use today)
 	 * @return int Age (0 if both timestamps are equal or empty, -1 on invalid dates)
 	 */
 	public static function age($start, $end = null) {
@@ -138,7 +138,7 @@ class Time extends CakeTime {
 	 *
 	 * @param int $year
 	 * @param int|null $month (optional)
-	 * @return int|string Age
+	 * @return string|int Age
 	 */
 	public static function ageByYear($year, $month = null) {
 		if ($month === null) {
@@ -328,7 +328,7 @@ class Time extends CakeTime {
 	 * @param int $years Years to increment/decrement
 	 * @param int $months Months to increment/decrement
 	 * @param int $days Days
-	 * @param string|\DateTimeZone|int|null $timezone Timezone string or DateTimeZone object
+	 * @param \DateTimeZone|string|int|null $timezone Timezone string or DateTimeZone object
 	 * @return object DateTime with incremented/decremented month/year values.
 	 */
 	public function incrementDate($startDate, $years = 0, $months = 0, $days = 0, $timezone = null) {
@@ -371,7 +371,7 @@ class Time extends CakeTime {
 			$secondAge = $firstAge;
 		}
 		//TODO: other relative time then today should work as well
-		$date = new CakeTime($relativeTime !== null ? $relativeTime : 'now');
+		$date = new CakeTime($relativeTime ?? 'now');
 
 		$max = mktime(23, 23, 59, (int)$date->format('m'), (int)$date->format('d'), (int)$date->format('Y') - $firstAge);
 		$min = mktime(0, 0, 1, (int)$date->format('m'), (int)$date->format('d') + 1, (int)$date->format('Y') - $secondAge - 1);
@@ -486,7 +486,7 @@ class Time extends CakeTime {
 	 * - default: Default string (defaults to "-----")
 	 * - oclock: Set to true to append oclock string
 	 *
-	 * @param string|\Cake\I18n\I18nDateTimeInterface|null $dateString
+	 * @param \Cake\I18n\I18nDateTimeInterface|string|null $dateString
 	 * @param string|null $format Format (YYYY-MM-DD, DD.MM.YYYY)
 	 * @param array $options Options
 	 * @return string
@@ -664,16 +664,16 @@ class Time extends CakeTime {
 	 * Options:
 	 * - abbr
 	 *
-	 * @param int[] $monthKeys
+	 * @param array<int> $monthKeys
 	 * @param array $options
-	 * @return string[]
+	 * @return array<string>
 	 */
 	public static function monthNames(array $monthKeys = [], array $options = []) {
 		if (!$monthKeys) {
 			$monthKeys = range(1, 12);
 		}
 		$res = [];
-		$abbr = isset($options['abbr']) ? $options['abbr'] : false;
+		$abbr = $options['abbr'] ?? false;
 		foreach ($monthKeys as $key) {
 			$res[static::pad((string)$key)] = static::monthName($key, $abbr, $options);
 		}
@@ -684,17 +684,17 @@ class Time extends CakeTime {
 	/**
 	 * Weekdays
 	 *
-	 * @param int[] $dayKeys
+	 * @param array<int> $dayKeys
 	 * @param array $options
-	 * @return string[]
+	 * @return array<string>
 	 */
 	public static function dayNames(array $dayKeys = [], array $options = []) {
 		if (!$dayKeys) {
 			$dayKeys = range(0, 6);
 		}
 		$res = [];
-		$abbr = isset($options['abbr']) ? $options['abbr'] : false;
-		$offset = isset($options['offset']) ? $options['offset'] : 0;
+		$abbr = $options['abbr'] ?? false;
+		$offset = $options['offset'] ?? 0;
 		foreach ($dayKeys as $key) {
 			$res[$key] = static::dayName($key, $abbr, $offset);
 		}
@@ -723,7 +723,7 @@ class Time extends CakeTime {
 
 	/**
 	 * @param int $offset in seconds
-	 * @param bool|string|null $past (defaults to null: return plain text)
+	 * @param string|bool|null $past (defaults to null: return plain text)
 	 * - new: if not boolean but a string use this as translating text
 	 * @return string text (i18n!)
 	 */
@@ -916,7 +916,7 @@ class Time extends CakeTime {
 	 * - default, separator
 	 * - boolean zero: if false: 0 days 5 hours => 5 hours etc.
 	 * - verbose/past/future: string with %s or boolean true/false
-	 * @return string|array
+	 * @return array|string
 	 */
 	public static function relLengthOfTime($date, $format = null, array $options = []) {
 		$dateTime = $date;
@@ -986,7 +986,7 @@ class Time extends CakeTime {
 	 * Returns true if given datetime string is not today AND is in the future.
 	 *
 	 * @param string $dateString Datetime string or Unix timestamp
-	 * @param string|\DateTimeZone|null $timezone User's timezone
+	 * @param \DateTimeZone|string|null $timezone User's timezone
 	 * @return bool True if datetime is not today AND is in the future
 	 */
 	public static function isNotTodayAndInTheFuture($dateString, $timezone = null) {
@@ -999,8 +999,8 @@ class Time extends CakeTime {
 	/**
 	 * Returns true if given datetime string is not now AND is in the future.
 	 *
-	 * @param string|\DateTimeInterface $date Datetime string or Unix timestamp
-	 * @param string|\DateTimeZone|null $timezone User's timezone
+	 * @param \DateTimeInterface|string $date Datetime string or Unix timestamp
+	 * @param \DateTimeZone|string|null $timezone User's timezone
 	 * @return bool True if datetime is not today AND is in the future
 	 */
 	public static function isInTheFuture($date, $timezone = null) {
@@ -1117,10 +1117,10 @@ class Time extends CakeTime {
 	/**
 	 * Returns a partial SQL string to search for all records between two dates.
 	 *
-	 * @param int|string|\DateTimeInterface $begin UNIX timestamp, strtotime() valid string or DateTime object
-	 * @param int|string|\DateTimeInterface $end UNIX timestamp, strtotime() valid string or DateTime object
+	 * @param \DateTimeInterface|string|int $begin UNIX timestamp, strtotime() valid string or DateTime object
+	 * @param \DateTimeInterface|string|int $end UNIX timestamp, strtotime() valid string or DateTime object
 	 * @param string $fieldName Name of database field to compare with
-	 * @param string|\DateTimeZone|null $timezone Timezone string or DateTimeZone object
+	 * @param \DateTimeZone|string|null $timezone Timezone string or DateTimeZone object
 	 * @return string Partial SQL string.
 	 */
 	public static function daysAsSql($begin, $end, $fieldName, $timezone = null) {
@@ -1138,9 +1138,9 @@ class Time extends CakeTime {
 	 * Returns a partial SQL string to search for all records between two times
 	 * occurring on the same day.
 	 *
-	 * @param int|string|\DateTimeInterface $dateString UNIX timestamp, strtotime() valid string or DateTime object
+	 * @param \DateTimeInterface|string|int $dateString UNIX timestamp, strtotime() valid string or DateTime object
 	 * @param string $fieldName Name of database field to compare with
-	 * @param string|\DateTimeZone|null $timezone Timezone string or DateTimeZone object
+	 * @param \DateTimeZone|string|null $timezone Timezone string or DateTimeZone object
 	 * @return string Partial SQL string.
 	 */
 	public static function dayAsSql($dateString, $fieldName, $timezone = null) {
@@ -1171,7 +1171,7 @@ class Time extends CakeTime {
 	 * e.g. 9.5 => 9.3
 	 * with pad=2: 9.30
 	 *
-	 * @param int|float $value
+	 * @param float|int $value
 	 * @param int|null $pad
 	 * @param string $decPoint
 	 * @return string
@@ -1196,7 +1196,7 @@ class Time extends CakeTime {
 	 * now supports negative values like -2,5 -2,5 -2:30 -:30 or -4
 	 *
 	 * @param string $duration
-	 * @param string[] $allowed
+	 * @param array<string> $allowed
 	 * @return int Seconds
 	 */
 	public static function parseLocalTime($duration, array $allowed = [':', '.', ',']) {
@@ -1238,7 +1238,7 @@ class Time extends CakeTime {
 	 * Parse 2022-11-12 or 12.11.2022 or even 12.11.22
 	 *
 	 * @param string $date
-	 * @param string[] $allowed
+	 * @param array<string> $allowed
 	 * @return int Seconds
 	 */
 	public static function parseLocalDate($date, array $allowed = ['.', '-']) {
@@ -1273,7 +1273,7 @@ class Time extends CakeTime {
 	 *
 	 * E.g. for days and hours set format to: $d:$H
 	 *
-	 * @param int|\DateInterval $duration Duration in seconds or as DateInterval object
+	 * @param \DateInterval|int $duration Duration in seconds or as DateInterval object
 	 * @param string $format Defaults to hours, minutes and seconds
 	 * @return string Time
 	 */
@@ -1307,7 +1307,7 @@ class Time extends CakeTime {
 	 * as it approximates month as "30".
 	 *
 	 * @deprecated Use duration() instead?
-	 * @param int|\DateInterval $duration Duration in seconds or as DateInterval object
+	 * @param \DateInterval|int $duration Duration in seconds or as DateInterval object
 	 * @param string $format Defaults to hours and minutes
 	 * @return string Time
 	 */

+ 1 - 1
src/View/Helper/FormHelper.php

@@ -16,7 +16,7 @@ use Cake\View\View;
 class FormHelper extends CakeFormHelper {
 
 	/**
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfigExt = [
 		'novalidate' => false,

+ 15 - 8
src/View/Helper/FormatHelper.php

@@ -142,7 +142,7 @@ class FormatHelper extends Helper {
 			$ret .= $this->Html->link(
 				$this->icon('prev') . '&nbsp;' . __d('tools', 'prev' . $name),
 				$url,
-				['escape' => false, 'title' => $neighbors['prev'][$titleField]]
+				['escape' => false, 'title' => $neighbors['prev'][$titleField]],
 			);
 		} else {
 			$ret .= $this->icon('prev');
@@ -158,7 +158,7 @@ class FormatHelper extends Helper {
 			$ret .= $this->Html->link(
 				$this->icon('next') . '&nbsp;' . __d('tools', 'next' . $name),
 				$url,
-				['escape' => false, 'title' => $neighbors['next'][$titleField]]
+				['escape' => false, 'title' => $neighbors['next'][$titleField]],
 			);
 		} else {
 			$ret .= $this->icon('next') . '&nbsp;' . __d('tools', 'next' . $name);
@@ -169,13 +169,20 @@ class FormatHelper extends Helper {
 		return $ret;
 	}
 
+	/**
+	 * @var int
+	 */
 	public const GENDER_FEMALE = 2;
+
+	/**
+	 * @var int
+	 */
 	public const GENDER_MALE = 1;
 
 	/**
 	 * Displays gender icon
 	 *
-	 * @param int|string $value
+	 * @param string|int $value
 	 * @param array $options
 	 * @param array $attributes
 	 * @return string
@@ -205,7 +212,7 @@ class FormatHelper extends Helper {
 	 * - extra (array: muted, light, dark, border)
 	 * - pull (string: left, right)
 	 *
-	 * @param string|array $icon
+	 * @param array|string $icon
 	 * @param array $options
 	 * @param array $attributes
 	 * @return string
@@ -325,7 +332,7 @@ class FormatHelper extends Helper {
 	 * @return string
 	 */
 	protected function _customIcon($icon, array $options = [], array $attributes = []) {
-		$translate = isset($options['translate']) ? $options['translate'] : true;
+		$translate = $options['translate'] ?? true;
 
 		$type = pathinfo($icon, PATHINFO_FILENAME);
 		$title = ucfirst($type);
@@ -492,7 +499,7 @@ class FormatHelper extends Helper {
 	 * Generates a pagination count: #1 etc for each pagination record
 	 * respects order (ASC/DESC)
 	 *
-	 * @deprecated
+	 * @deprecated Not in use anymore.
 	 * @param array $paginator
 	 * @param int $count (current post count on this page)
 	 * @param string|null $dir (ASC/DESC)
@@ -507,7 +514,7 @@ class FormatHelper extends Helper {
 		$pageCount = $paginator['pageCount'];
 		$totalCount = $paginator['count'];
 		$limit = $paginator['perPage'];
-		$step = isset($paginator['step']) ? $paginator['step'] : 1;
+		$step = $paginator['step'] ?? 1;
 
 		if ($dir === 'DESC') {
 			$count = $limit - $count + 1;
@@ -715,7 +722,7 @@ class FormatHelper extends Helper {
 					$table .= "\n" . static::array2table($cell, $options) . "\n";
 				} else {
 					$table .= (!is_array($cell) && strlen($cell) > 0) ? ($options['escape'] ? h(
-						$cell
+						$cell,
 					) : $cell) : $options['null'];
 				}
 

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

@@ -47,7 +47,7 @@ class GravatarHelper extends Helper {
 	/**
 	 * Default settings
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'default' => null,

+ 7 - 8
src/View/Helper/HtmlTrait.php

@@ -12,7 +12,7 @@ trait HtmlTrait {
 	 * - type: png, gif, jpg, ...
 	 *
 	 * @param string $content Data in binary form
-	 * @param array $options Attributes
+	 * @param array<string, mixed> $options Attributes
 	 * @return string HTML image tag
 	 */
 	public function imageFromBlob($content, array $options = []) {
@@ -39,10 +39,10 @@ trait HtmlTrait {
 	 * - `confirm` JavaScript confirmation message.
 	 *
 	 * @param string $title The content to be wrapped by <a> tags.
-	 * @param string|array|null $url URL or array of URL parameters, or
+	 * @param array|string|null $url URL or array of URL parameters, or
 	 *   external URL (starts with http://)
-	 * @param array $options Array of options and HTML attributes.
-	 * @return string An `<a />` element.
+	 * @param array<string, mixed> $options Array of options and HTML attributes.
+	 * @return string An `a` HTML element.
 	 */
 	public function linkReset($title, $url = null, array $options = []) {
 		if (is_array($url)) {
@@ -64,11 +64,10 @@ trait HtmlTrait {
 	 * - `confirm` JavaScript confirmation message.
 	 *
 	 * @param string $title The content to be wrapped by <a> tags.
-	 * @param string|array|null $url URL or array of URL parameters, or
+	 * @param array|string|null $url URL or array of URL parameters, or
 	 *   external URL (starts with http://)
-	 * @param array $options Array of options and HTML attributes.
-	 * @return string An `<a />` element.
-	 * @return string Link
+	 * @param array<string, mixed> $options Array of options and HTML attributes.
+	 * @return string An `a` HTML element.
 	 */
 	public function linkComplete($title, $url = null, array $options = []) {
 		if (is_array($url)) {

+ 5 - 5
src/View/Helper/TimeHelper.php

@@ -24,7 +24,7 @@ class TimeHelper extends CakeTimeHelper {
 	/**
 	 * Default config for this class
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'engine' => 'Tools\Utility\Time',
@@ -78,8 +78,8 @@ class TimeHelper extends CakeTimeHelper {
 	/**
 	 * Returns a nicely formatted date string for given Datetime string.
 	 *
-	 * @param int|string|\DateTimeInterface|null $dateString UNIX timestamp, strtotime() valid string or DateTime object
-	 * @param string|\DateTimeZone|null $timezone User's timezone string or DateTimeZone object
+	 * @param \DateTimeInterface|string|int|null $dateString UNIX timestamp, strtotime() valid string or DateTime object
+	 * @param \DateTimeZone|string|null $timezone User's timezone string or DateTimeZone object
 	 * @param string|null $locale Locale string.
 	 * @param string|null $default Default string to use when no dateString is given. Use null to allow null as current date.
 	 * @return string Formatted date string
@@ -122,7 +122,7 @@ class TimeHelper extends CakeTimeHelper {
 	 */
 	public function localDateMarkup($dateString = null, $format = null, $options = []) {
 		$date = $this->localDate($dateString, $format, $options);
-		$date = '<span' . ($this->isToday($dateString, (isset($options['userOffset']) ? $options['userOffset'] : null)) ? ' class="today"' : '') . '>' . $date . '</span>';
+		$date = '<span' . ($this->isToday($dateString, ($options['userOffset'] ?? null)) ? ' class="today"' : '') . '>' . $date . '</span>';
 
 		return $date;
 	}
@@ -137,7 +137,7 @@ class TimeHelper extends CakeTimeHelper {
 	 */
 	public function niceDateMarkup($dateString = null, $format = null, $options = []) {
 		$date = $this->niceDate($dateString, $format, $options);
-		$date = '<span' . ($this->isToday($dateString, (isset($options['userOffset']) ? $options['userOffset'] : null)) ? ' class="today"' : '') . '>' . $date . '</span>';
+		$date = '<span' . ($this->isToday($dateString, ($options['userOffset'] ?? null)) ? ' class="today"' : '') . '>' . $date . '</span>';
 
 		return $date;
 	}

+ 1 - 1
src/View/Helper/TimelineHelper.php

@@ -45,7 +45,7 @@ class TimelineHelper extends Helper {
 	 *
 	 * @link http://almende.github.io/chap-links-library/js/timeline/doc/
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'id' => 'mytimeline',

+ 8 - 8
src/View/Helper/TreeHelper.php

@@ -26,7 +26,7 @@ class TreeHelper extends Helper {
 	/**
 	 * Default settings
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_defaultConfig = [
 		'model' => null,
@@ -57,7 +57,7 @@ class TreeHelper extends Helper {
 	/**
 	 * Config settings property
 	 *
-	 * @var array
+	 * @var array<string, mixed>
 	 */
 	protected $_config = [];
 
@@ -115,7 +115,7 @@ class TreeHelper extends Helper {
 	 *    'splitCount' => the number of "parallel" types. defaults to null (disabled) set the splitCount,
 	 *        and optionally set the splitDepth to get parallel lists
 	 *
-	 * @param array|\Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet $data Data to loop over
+	 * @param \Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet|array $data Data to loop over
 	 * @param array $config Config
 	 * @throws \Exception
 	 * @return string HTML representation of the passed data
@@ -125,9 +125,9 @@ class TreeHelper extends Helper {
 	}
 
 	/**
-	 * @param array|\Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet $data
+	 * @param \Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet|array $data
 	 * @param array $config
-	 * @param array|\Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet|null $parent
+	 * @param \Cake\Datasource\QueryInterface|\Cake\ORM\ResultSet|array|null $parent
 	 *
 	 * @throws \Exception
 	 * @return string
@@ -244,7 +244,7 @@ class TreeHelper extends Helper {
 				}
 			}
 
-			$depth = $depth ? $depth : count($stack);
+			$depth = $depth ?: count($stack);
 
 			$elementData = [
 				'data' => $result,
@@ -410,7 +410,7 @@ class TreeHelper extends Helper {
 	 */
 	public function addTypeAttribute($id = '', $key = '', $value = null, $previousOrNext = 'next') {
 		$var = '_typeAttributes';
-		$firstChild = isset($this->_config['firstChild']) ? $this->_config['firstChild'] : true;
+		$firstChild = $this->_config['firstChild'] ?? true;
 		if ($previousOrNext === 'next' && $firstChild) {
 			$var = '_typeAttributesNext';
 		}
@@ -446,7 +446,7 @@ class TreeHelper extends Helper {
 					$_splitCount = $rounded + 1;
 				}
 			} elseif ($depth == $splitDepth - 1) {
-				$total = $numberOfDirectChildren ? $numberOfDirectChildren : $numberOfTotalChildren;
+				$total = $numberOfDirectChildren ?: $numberOfTotalChildren;
 				if ($total) {
 					$_splitCounter = 0;
 					$_splitCount = $total / $splitCount;

+ 1 - 1
tests/TestCase/View/Helper/FormatHelperTest.php

@@ -15,7 +15,7 @@ use Tools\View\Helper\FormatHelper;
 class FormatHelperTest extends TestCase {
 
 	/**
-	 * @var string[]
+	 * @var array<string>
 	 */
 	protected $fixtures = [
 		'core.Sessions',