Browse Source

Use shim 0.3

Mark Scherer 10 years ago
parent
commit
886e06b5a4
2 changed files with 7 additions and 5 deletions
  1. 6 4
      Console/Command/IndentShell.php
  2. 1 1
      composer.json

+ 6 - 4
Console/Command/IndentShell.php

@@ -201,7 +201,7 @@ class IndentShell extends AppShell {
 		}
 
 		$newPiece = rtrim($newPiece) . $debug;
-		if ($newPiece != $piece || strlen($newPiece) !== strlen($piece)) {
+		if ($newPiece !== $piece || strlen($newPiece) !== strlen($piece)) {
 			$this->_changes = true;
 		}
 		return $newPiece;
@@ -216,14 +216,16 @@ class IndentShell extends AppShell {
 	protected function _processSpaceErrors($piece, $space = 1) {
 		$newPiece = $piece;
 		$spaceChar = str_repeat(' ', $space);
-
+		// At the beginning of the line
 		if (mb_substr($newPiece, 0, $space) === $spaceChar && mb_substr($newPiece, $space, 1) === TB) {
 			$newPiece = mb_substr($newPiece, $space);
 		}
-		if (($pos = mb_strpos($newPiece, $space)) > 0 && mb_substr($newPiece, $pos - 1, 1) === TB) {
+		// In the middle
+		if (($pos = mb_strpos($newPiece, $space)) > 0 && mb_substr($newPiece, $pos - 1, 1) === TB
+			&& mb_substr($newPiece, $pos + 1, 1) === TB) {
 			$newPiece = mb_substr($newPiece, $pos) . mb_substr($newPiece, $pos + 2);
 		}
-		$newPiece = str_replace($spaceChar . TB, TB, $newPiece);
+		$newPiece = str_replace(TB . $spaceChar . TB, TB . TB, $newPiece);
 		if ($newPiece !== $piece) {
 			$this->_changes = true;
 		}

+ 1 - 1
composer.json

@@ -15,7 +15,7 @@
 	"require": {
 		"php": ">=5.3",
 		"composer/installers": "*",
-		"dereuromark/cakephp-shim": "0.2.*"
+		"dereuromark/cakephp-shim": "0.3.*"
 	},
 	"support": {
 		"source": "https://github.com/dereuromark/cakephp-tools"