mscherer 4 years ago
parent
commit
95671347dc

+ 6 - 4
config/bootstrap.php

@@ -125,8 +125,8 @@ if (!function_exists('ent')) {
 	/**
 	 * Returns htmlentities - string
 	 *
-	 * ENT_COMPAT	= Will convert double-quotes and leave single-quotes alone.
-	 * ENT_QUOTES	= Will convert both double and single quotes. !!!
+	 * ENT_COMPAT = Will convert double-quotes and leave single-quotes alone.
+	 * ENT_QUOTES = Will convert both double and single quotes. !!!
 	 * ENT_NOQUOTES = Will leave both double and single quotes unconverted.
 	 *
 	 * @param string $text
@@ -247,10 +247,12 @@ if (!function_exists('extractPathInfo')) {
 		}
 		$result = pathinfo($filename, $infoType);
 		if ($fromUrl) {
-			if (($pos = strpos($result, '#')) !== false) {
+			$pos = strpos($result, '#');
+			if ($pos !== false) {
 				$result = substr($result, 0, $pos);
 			}
-			if (($pos = strpos($result, '?')) !== false) {
+			$pos = strpos($result, '?');
+			if ($pos !== false) {
 				$result = substr($result, 0, $pos);
 			}
 		}

+ 7 - 3
src/Mailer/Message.php

@@ -261,8 +261,11 @@ class Message extends CakeMessage {
 		}
 
 		$filename = pathinfo($filename, PATHINFO_FILENAME) . '_' . md5($content) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
-		if ($contentId === null && ($cid = $this->_isEmbeddedBlobAttachment($content, $filename))) {
-			return $cid;
+		if ($contentId === null) {
+			$cid = $this->_isEmbeddedBlobAttachment($content, $filename);
+			if ($cid) {
+				return $cid;
+			}
 		}
 
 		$options['data'] = $content;
@@ -370,7 +373,8 @@ class Message extends CakeMessage {
 	 */
 	protected function _readFile($path) {
 		$context = stream_context_create(
-			['http' => ['header' => 'Connection: close']]);
+            ['http' => ['header' => 'Connection: close']],
+        );
 		$content = file_get_contents($path, false, $context);
 		if (!$content) {
 			trigger_error('No content found for ' . $path);

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

@@ -239,7 +239,7 @@ class BitmaskedBehavior extends Behavior {
 		}
 		if ($res === 0) {
 			return $defaultValue; // Make sure notEmpty validation rule triggers
-}
+		}
 
 		return $res;
 	}

+ 8 - 10
src/Model/Behavior/ConfirmableBehavior.php

@@ -25,7 +25,6 @@ class ConfirmableBehavior extends Behavior {
 	protected $_defaultConfig = [
 		'message' => null,
 		'field' => 'confirm',
-		//'table' => null,
 		'validator' => 'default',
 	];
 
@@ -64,15 +63,14 @@ class ConfirmableBehavior extends Behavior {
 		$field = $this->_config['field'];
 		$message = $this->_config['message'];
 		$validator->add($field, 'notBlank', [
-				'rule' => function ($value, $context) {
-					return !empty($value);
-				},
-				'message' => $message,
-				//'provider' => 'table',
-				'requirePresence' => true,
-				'allowEmpty' => false,
-				'last' => true],
-		);
+			'rule' => function ($value, $context) {
+				return !empty($value);
+			},
+			'message' => $message,
+			'requirePresence' => true,
+			'allowEmpty' => false,
+			'last' => true,
+		]);
 		$validator->requirePresence($field);
 	}
 

+ 4 - 3
src/Utility/FrozenTime.php

@@ -551,7 +551,8 @@ class FrozenTime extends CakeFrozenTime {
 	 * @return string Time in format hh:mm
 	 */
 	public static function niceTime($time) {
-		if (($pos = strpos($time, ' ')) !== false) {
+		$pos = strpos($time, ' ');
+		if ($pos !== false) {
 			$time = substr($time, $pos + 1);
 		}
 
@@ -813,14 +814,14 @@ class FrozenTime extends CakeFrozenTime {
 			$p = $s;
 		} else {
 			$s = [
-		'm' => ' ' . __d('tools', 'Month'), # translated
+			'm' => ' ' . __d('tools', 'Month'), # translated
 				'd' => ' ' . __d('tools', 'Day'),
 				'h' => ' ' . __d('tools', 'Hour'),
 				'i' => ' ' . __d('tools', 'Minute'),
 				's' => ' ' . __d('tools', 'Second'),
 			];
 			$p = [
-		'm' => ' ' . __d('tools', 'Months'), # translated
+			'm' => ' ' . __d('tools', 'Months'), # translated
 				'd' => ' ' . __d('tools', 'Days'),
 				'h' => ' ' . __d('tools', 'Hours'),
 				'i' => ' ' . __d('tools', 'Minutes'),

+ 2 - 1
src/Utility/Mime.php

@@ -822,7 +822,8 @@ class Mime extends Response {
 
 		$finfo = finfo_open(FILEINFO_MIME);
 		$mimetype = finfo_file($finfo, $file);
-		if (($pos = strpos($mimetype, ';')) !== false) {
+		$pos = strpos($mimetype, ';');
+		if ($pos !== false) {
 			$mimetype = substr($mimetype, 0, $pos);
 		}
 		if ($mimetype) {

+ 5 - 2
src/Utility/Text.php

@@ -402,8 +402,11 @@ class Text extends CakeText {
 		}
 
 		if ($all) {
-			$str = str_replace(['&', '<', '>', '"', ''', '-'],
-				['&', '<', '>', '"', "'", '-'], $str);
+			$str = str_replace(
+                ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'],
+                ['&', '<', '>', '"', "'", '-'],
+                $str,
+            );
 		}
 
 		return $str;

+ 4 - 3
src/Utility/Time.php

@@ -554,7 +554,8 @@ class Time extends CakeTime {
 	 * @return string Time in format hh:mm
 	 */
 	public static function niceTime($time) {
-		if (($pos = strpos($time, ' ')) !== false) {
+		$pos = strpos($time, ' ');
+		if ($pos !== false) {
 			$time = substr($time, $pos + 1);
 		}
 
@@ -816,14 +817,14 @@ class Time extends CakeTime {
 			$p = $s;
 		} else {
 			$s = [
-		'm' => ' ' . __d('tools', 'Month'), # translated
+			'm' => ' ' . __d('tools', 'Month'), # translated
 				'd' => ' ' . __d('tools', 'Day'),
 				'h' => ' ' . __d('tools', 'Hour'),
 				'i' => ' ' . __d('tools', 'Minute'),
 				's' => ' ' . __d('tools', 'Second'),
 			];
 			$p = [
-		'm' => ' ' . __d('tools', 'Months'), # translated
+			'm' => ' ' . __d('tools', 'Months'), # translated
 				'd' => ' ' . __d('tools', 'Days'),
 				'h' => ' ' . __d('tools', 'Hours'),
 				'i' => ' ' . __d('tools', 'Minutes'),

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

@@ -71,14 +71,14 @@ class CommonHelper extends Helper {
 	 * @return string HTML
 	 */
 	public function metaRobots($type = null): string {
-		if ($type === null && ($meta = Configure::read('Config.robots')) !== null) {
+		$meta = Configure::read('Config.robots');
+		if ($type === null && $meta !== null) {
 			$type = $meta;
 		}
 		if ($type === null) {
 			$type = ['noindex', 'nofollow', 'noarchive'];
 		}
 
-		$robots = [];
 		if (is_array($type)) {
 			$robots = $type;
 		} elseif ($type === 'public') {

+ 4 - 2
tests/TestCase/Utility/FrozenTimeTest.php

@@ -445,14 +445,16 @@ class FrozenTimeTest extends TestCase {
 		$this->assertEquals((date('Y') - 1986) . '/' . (date('Y') - 1985), $is);
 
 		// with month
-		if (($month = date('n') + 1) <= 12) {
+		$month = date('n') + 1;
+		if ($month <= 12) {
 			$is = $this->Time->ageByYear(2000, $month);
 			//$this->out($is);
 			//$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);
 			$this->assertSame(date('Y') - 2001, $is); //null, '2000/'.$month
 		}
 
-		if (($month = date('n') - 1) >= 1) {
+		$month = date('n') - 1;
+		if ($month >= 1) {
 			$is = $this->Time->ageByYear(2000, $month);
 			//$this->out($is);
 			//$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);

+ 4 - 4
tests/TestCase/Utility/L10nTest.php

@@ -820,10 +820,10 @@ class L10nTest extends TestCase {
 		$result = $localize->catalog(['cy']);
 		$expected = [
 			'cy' => [
-'language' => 'Welsh',
-'locale' => 'cym',
-'localeFallback' => 'cym',
-'charset' => 'utf-8',
+			'language' => 'Welsh',
+			'locale' => 'cym',
+			'localeFallback' => 'cym',
+			'charset' => 'utf-8',
 			'direction' => 'ltr'],
 		];
 		$this->assertEquals($expected, $result);

+ 4 - 6
tests/TestCase/Utility/TimeTest.php

@@ -445,17 +445,15 @@ class TimeTest extends TestCase {
 		$this->assertEquals((date('Y') - 1986) . '/' . (date('Y') - 1985), $is);
 
 		// with month
-		if (($month = date('n') + 1) <= 12) {
+		$month = date('n') + 1;
+		if ($month <= 12) {
 			$is = $this->Time->ageByYear(2000, $month);
-			//$this->out($is);
-			//$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);
 			$this->assertSame(date('Y') - 2001, $is); //null, '2000/'.$month
 		}
 
-		if (($month = date('n') - 1) >= 1) {
+		$month = date('n') - 1;
+		if ($month >= 1) {
 			$is = $this->Time->ageByYear(2000, $month);
-			//$this->out($is);
-			//$this->assertEquals($is, (date('Y')-2001).'/'.(date('Y')-2000), null, '2000/'.$month);
 			$this->assertSame(date('Y') - 2000, $is); //null, '2000/'.$month)
 		}
 	}

+ 0 - 2
tests/TestCase/View/Helper/TextHelperTest.php

@@ -171,8 +171,6 @@ class TextHelperTest extends TestCase {
 		$this->assertEquals($expected, $result);
 	}
 
-/* from cake */
-
 	/**
 	 * Test invalid email addresses.
 	 *