mscherer 2 年之前
父节点
当前提交
af6b458398
共有 5 个文件被更改,包括 13 次插入6 次删除
  1. 1 2
      composer.json
  2. 4 0
      src/Mailer/Message.php
  3. 4 2
      src/Utility/Mime.php
  4. 2 2
      src/View/Helper/TreeHelper.php
  5. 2 0
      src/View/Icon/IconCollection.php

+ 1 - 2
composer.json

@@ -24,7 +24,7 @@
 	"require": {
 		"php": ">=8.1",
 		"cakephp/cakephp": "^5.0.0",
-		"dereuromark/cakephp-shim": "dev-cake5"
+		"dereuromark/cakephp-shim": "^3.0.0"
 	},
 	"require-dev": {
 		"mobiledetect/mobiledetectlib": "^3.74",
@@ -64,7 +64,6 @@
 		"cs-fix": "phpcbf --extensions=php"
 	},
 	"prefer-stable": true,
-	"minimum-stability": "dev",
 	"config": {
 		"process-timeout": 600,
 		"allow-plugins": {

+ 4 - 0
src/Mailer/Message.php

@@ -356,7 +356,11 @@ class Message extends CakeMessage {
 		// Some environments falsely return the default too fast, better fallback to extension here
 		if (!$mime || $mime === $default) {
 			$ext = pathinfo($filename, PATHINFO_EXTENSION);
+			/** @var string|null $mime */
 			$mime = $this->_Mime->getMimeTypeByAlias($ext);
+			if ($mime === null) {
+				$mime = (string)$mime;
+			}
 		}
 
 		return $mime;

+ 4 - 2
src/Utility/Mime.php

@@ -720,9 +720,9 @@ class Mime extends Response {
 	 *
 	 * @param string|null $file File Name (relative location such as "image_test.jpg" or full "http://site.com/path/to/image_test.jpg")
 	 *
-	 * @return array|string MIMEType - The type of the file passed in the argument
+	 * @return string MIMEType - The type of the file passed in the argument
 	 */
-	public function detectMimeType(?string $file = null): array|string {
+	public function detectMimeType(?string $file = null): string {
 		// Attempts to retrieve file info from FINFO
 		// If FINFO functions are not available then try to retrieve MIME type from pre-defined MIMEs
 		// If MIME type doesn't exist, then try (as a last resort) to use the (deprecated) mime_content_type function
@@ -735,6 +735,7 @@ class Mime extends Response {
 				}
 			}
 			$extension = $this->_getExtension($file);
+			/** @var string|null $mimeType */
 			$mimeType = $this->getMimeTypeByAlias($extension);
 			if ($mimeType) {
 				return $mimeType;
@@ -789,6 +790,7 @@ class Mime extends Response {
 			return $mimetype;
 		}
 		$extension = static::_getExtension($file);
+		/** @var string|null $mimeType */
 		$mimeType = static::getMimeTypeByAlias($extension);
 		if ($mimeType) {
 			return $mimeType;

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

@@ -135,7 +135,7 @@ class TreeHelper extends Helper {
 	protected function _generate($data, array $config, $parent = null) {
 		$dataArray = $data;
 		if (is_object($dataArray)) {
-			$dataArray = $data->toArray();
+			$dataArray = $dataArray->toArray();
 		}
 		if (!$dataArray) {
 			return '';
@@ -538,7 +538,7 @@ class TreeHelper extends Helper {
 		extract($this->_config);
 		$siblingIsActive = false;
 		foreach ($tree as $key => &$subTree) {
-			if (is_object($subTree)) {
+			if (is_object($subTree) && method_exists($subTree, 'toArray')) {
 				$subTree = $subTree->toArray();
 			}
 			if (!isset($subTree['children'])) {

+ 2 - 0
src/View/Icon/IconCollection.php

@@ -58,6 +58,7 @@ class IconCollection {
 			$this->iconSets[$set] = new $className($setConfig);
 		}
 
+		/** @var string|null $key */
 		$key = array_key_first($sets);
 		if (!$key) {
 			throw new RuntimeException('No set defined for icon collection, at least one is required.');
@@ -119,6 +120,7 @@ class IconCollection {
 
 		$options += $this->_config;
 		if (!isset($options['title']) || $options['title'] !== false) {
+			/** @var string $titleField */
 			$titleField = !isset($options['title']) || $options['title'] === true ? 'title' : $options['title'];
 			if (!isset($attributes[$titleField])) {
 				$attributes[$titleField] = ucwords(Inflector::humanize(Inflector::underscore($iconName ?? $icon)));