Passed
Pull Request — master (#779)
by Kiran
13:06
created
includes/libraries/class-emogrifier.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		if ($nodesWithStyleAttributes !== false) {
239 239
 			/** @var $nodeWithStyleAttribute DOMNode */
240 240
 			foreach ($nodesWithStyleAttributes as $node) {
241
-				$normalizedOriginalStyle = preg_replace_callback( '/[A-z\\-]+(?=\\:)/S', array( $this, 'strtolower' ), $node->getAttribute('style') );
241
+				$normalizedOriginalStyle = preg_replace_callback('/[A-z\\-]+(?=\\:)/S', array($this, 'strtolower'), $node->getAttribute('style'));
242 242
 
243 243
 				// in order to not overwrite existing style attributes in the HTML, we have to save the original HTML styles
244 244
 				$nodePath = $node->getNodePath();
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			}
290 290
 
291 291
 			// now sort the selectors by precedence
292
-			usort($allSelectors, array($this,'sortBySelectorPrecedence'));
292
+			usort($allSelectors, array($this, 'sortBySelectorPrecedence'));
293 293
 
294 294
 			$this->caches[self::CACHE_KEY_CSS][$cssKey] = $allSelectors;
295 295
 		}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		if ($nodesWithStyleDisplayNone->length > 0) {
330 330
 			/** @var $node \DOMNode */
331 331
 			foreach ($nodesWithStyleDisplayNone as $node) {
332
-				if ($node->parentNode && is_callable(array($node->parentNode,'removeChild'))) {
332
+				if ($node->parentNode && is_callable(array($node->parentNode, 'removeChild'))) {
333 333
 					$node->parentNode->removeChild($node);
334 334
 				}
335 335
 			}
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 
340 340
 		if ($this->preserveEncoding) {
341 341
 			// Deprecated since PHP 8.2
342
-			if ( version_compare( PHP_VERSION, '8.2', '<' ) && function_exists( 'mb_convert_encoding' ) ) {
343
-				return mb_convert_encoding( $xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES' );
342
+			if (version_compare(PHP_VERSION, '8.2', '<') && function_exists('mb_convert_encoding')) {
343
+				return mb_convert_encoding($xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES');
344 344
 			} else {
345
-				return mb_encode_numericentity( $xmlDocument->saveHTML(), [0x80, 0x10FFFF, 0, ~0], self::ENCODING );
345
+				return mb_encode_numericentity($xmlDocument->saveHTML(), [0x80, 0x10FFFF, 0, ~0], self::ENCODING);
346 346
 				//return htmlspecialchars_decode( utf8_encode( html_entity_decode( $xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING ) ) );
347 347
 			}
348 348
 		} else {
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @return array
473 473
 	 */
474 474
 	private function splitCssAndMediaQuery($css) {
475
-		$css = preg_replace_callback( '#@media\\s+(?:only\\s)?(?:[\\s{\(]|screen|all)\\s?[^{]+{.*}\\s*}\\s*#misU', array( $this, '_media_concat' ), $css );
475
+		$css = preg_replace_callback('#@media\\s+(?:only\\s)?(?:[\\s{\(]|screen|all)\\s?[^{]+{.*}\\s*}\\s*#misU', array($this, '_media_concat'), $css);
476 476
 
477 477
 		// filter the CSS
478 478
 		$search = array(
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      *
504 504
      * @param array $matches Matches result array.
505 505
      */
506
-	private function _media_concat( $matches ) {
506
+	private function _media_concat($matches) {
507 507
 		self::$_media .= $matches[0];
508 508
 	}
509 509
 
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 		}
544 544
 
545 545
 		// Deprecated since PHP 8.2
546
-		if ( version_compare( PHP_VERSION, '8.2', '<' ) && function_exists( 'mb_convert_encoding' ) ) {
547
-			return mb_convert_encoding( $bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING );
546
+		if (version_compare(PHP_VERSION, '8.2', '<') && function_exists('mb_convert_encoding')) {
547
+			return mb_convert_encoding($bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING);
548 548
 		} else {
549
-			return mb_encode_numericentity( $bodyWithoutUnprocessableTags, [0x80, 0x10FFFF, 0, ~0], self::ENCODING );
549
+			return mb_encode_numericentity($bodyWithoutUnprocessableTags, [0x80, 0x10FFFF, 0, ~0], self::ENCODING);
550 550
 			//return htmlspecialchars_decode( utf8_decode( htmlentities( $bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false ) ) );
551 551
 		}
552 552
 	}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			$precedence = 0;
583 583
 			$value = 100;
584 584
 			// ids: worth 100, classes: worth 10, elements: worth 1
585
-			$search = array('\\#','\\.','');
585
+			$search = array('\\#', '\\.', '');
586 586
 
587 587
 			foreach ($search as $s) {
588 588
 				if (trim($selector == '')) {
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 */
611 611
 	private function translateCssToXpath($paramCssSelector) {
612 612
 		$cssSelector = ' ' . $paramCssSelector . ' ';
613
-		$cssSelector = preg_replace_callback( '/\s+\w+\s+/', array( $this, 'strtolower' ), $cssSelector );
613
+		$cssSelector = preg_replace_callback('/\s+\w+\s+/', array($this, 'strtolower'), $cssSelector);
614 614
 		$cssSelector = trim($cssSelector);
615 615
 		$xpathKey = md5($cssSelector);
616 616
 		if (!isset($this->caches[self::CACHE_KEY_XPATH][$xpathKey])) {
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 	 * @return array
734 734
 	 */
735 735
 	private function parseNth(array $match) {
736
-		if (in_array(strtolower($match[2]), array('even','odd'))) {
736
+		if (in_array(strtolower($match[2]), array('even', 'odd'))) {
737 737
 			$index = strtolower($match[2]) == 'even' ? 0 : 1;
738 738
 			return array(self::MULTIPLIER => 2, self::INDEX => $index);
739 739
 		} elseif (stripos($match[2], 'n') === false) {
Please login to merge, or discard this patch.