浏览代码

Enable phpstan in travis.

mscherer 7 年之前
父节点
当前提交
59125677c6
共有 3 个文件被更改,包括 26 次插入35 次删除
  1. 12 11
      .travis.yml
  2. 13 23
      src/Mailer/Email.php
  3. 1 1
      tests/phpstan.neon

+ 12 - 11
.travis.yml

@@ -18,26 +18,26 @@ matrix:
   fast_finish: true
 
   include:
-    - php: 7.1
-      env: PHPCS=1 DEFAULT=0
-
-    - php: 7.1
-      env: CODECOVERAGE=1 DEFAULT=0
-
-    - php: 7.1
+    - php: 7.2
       env: DB=pgsql db_dsn='postgres://postgres@127.0.0.1/cakephp_test'
-      
-    - php: 7.1
+
+    - php: 7.2
       env: DB=sqlite db_dsn='sqlite:///:memory:'
 
     - php: 5.6
       env: PREFER_LOWEST=1
 
+    - php: 7.2
+      env: CHECKS=1 DEFAULT=0
+
+    - php: 7.2
+      env: CODECOVERAGE=1 DEFAULT=0
+
 before_script:
   - if [[ $PREFER_LOWEST != 1 ]]; then composer install --prefer-source --no-interaction ; fi
   - if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable ; fi
 
-  - if [[ $PHPCS != 1 ]]; then composer require phpunit/phpunit:"^5.7.14|^6.0"; fi
+  - if [[ $CHECKS != 1 ]]; then composer require phpunit/phpunit:"^5.7.14|^6.0"; fi
 
   - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
   - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi"
@@ -48,7 +48,8 @@ before_script:
 
 script:
   - if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi
-  - if [[ $PHPCS == 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --ignore=/tests/test_files/ src tests config ; fi
+  - if [[ $CHECKS == 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/fig-r/psr2r-sniffer/PSR2R/ruleset.xml --ignore=/tests/test_files/ src tests config ; fi
+  - if [[ $CHECKS == 1 ]]; then composer phpstan-setup && composer phpstan ; fi
 
   - if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml || true; fi
   - if [[ $CODECOVERAGE == 1 ]]; then wget -O codecov.sh https://codecov.io/bash; fi

+ 13 - 23
src/Mailer/Email.php

@@ -26,7 +26,7 @@ class Email extends CakeEmail {
 	protected $_error = null;
 
 	/**
-	 * @var bool|null
+	 * @var array|null
 	 */
 	protected $_debug = null;
 
@@ -36,6 +36,11 @@ class Email extends CakeEmail {
 	protected $_log = [];
 
 	/**
+	 * @var Mime|null
+	 */
+	protected $_Mime;
+
+	/**
 	 * @param string|null $config
 	 */
 	public function __construct($config = null) {
@@ -46,21 +51,6 @@ class Email extends CakeEmail {
 	}
 
 	/**
-	 * Change the layout
-	 *
-	 * @deprecated Since CakePHP 3.4.0-RC4 in core as getLayout()/setLayout()
-	 *
-	 * @param string|bool $layout Layout to use (or false to use none)
-	 * @return $this
-	 */
-	public function layout($layout = false) {
-		if ($layout !== false) {
-			$this->_layout = $layout;
-		}
-		return $this;
-	}
-
-	/**
 	 * Sets wrap length.
 	 *
 	 * @param int $length Must not be more than CakeEmail::LINE_LENGTH_MUST
@@ -181,7 +171,7 @@ class Email extends CakeEmail {
 	 */
 	public function profile($config = null) {
 		if ($config === null) {
-			return $this->_profile;
+			return $this->getProfile();
 		}
 
 		return $this->setProfile($config);
@@ -321,7 +311,7 @@ class Email extends CakeEmail {
 	 * @param string|null $name (optional)
 	 * @param array|string|null $options Options - string CID is deprecated
 	 * @param array $notUsed Former Options @deprecated 4th param is now 3rd since CakePHP 3.4.0 - Use addEmbeddedAttachmentByContentId() otherwise.
-	 * @return string CID ($this is deprecated!)
+	 * @return string|null CID (null is deprecated)
 	 */
 	public function addEmbeddedAttachment($file, $name = null, $options = null, array $notUsed = []) {
 		if (empty($name)) {
@@ -346,13 +336,13 @@ class Email extends CakeEmail {
 		}
 		$options['contentId'] = $contentId ?: str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
 		$file = [$name => $options];
-		$res = $this->addAttachments($file);
+		$this->addAttachments($file);
 		if ($contentId === null) {
 			return $options['contentId'];
 		}
 
 		// Deprecated
-		return $res;
+		return $contentId;
 	}
 
 	/**
@@ -397,7 +387,7 @@ class Email extends CakeEmail {
 	 * @param string|null $mimeType (leave it empty to get mimetype from $filename)
 	 * @param array|string|null $options Options - string CID is deprecated
 	 * @param array $notUsed
-	 * @return string CID CcontentId ($this is deprecated)
+	 * @return string|null CID CcontentId (null is deprecated)
 	 */
 	public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $options = null, array $notUsed = []) {
 		if ($mimeType === null) {
@@ -421,13 +411,13 @@ class Email extends CakeEmail {
 		$options['mimetype'] = $mimeType;
 		$options['contentId'] = $contentId ? $contentId : str_replace('-', '', Text::uuid()) . '@' . $this->_domain;
 		$file = [$filename => $options];
-		$res = $this->addAttachments($file);
+		$this->addAttachments($file);
 		if ($contentId === null) {
 			return $options['contentId'];
 		}
 
 		// Deprecated
-		return $res;
+		return $contentId;
 	}
 
 	/**

+ 1 - 1
tests/phpstan.neon

@@ -8,7 +8,7 @@ parameters:
 	ignoreErrors:
 		- '#Access to an undefined property .+Table::\$belongsTo#'
 		- '#Call to an undefined method .+TimeHelper::.+\(\)#'
-		- '#Tools\\Utility\\Mime::\_\_construct\(\) does not call parent constructor from Cake\\Http\\Response#'
+		- '#Access to protected property .+ServerRequest::\$.+#'
 
 services:
     -