euromark 13 年 前
コミット
d7f77fbd75

+ 26 - 26
Console/Command/CodeShell.php

@@ -6,10 +6,10 @@ if (!defined('LF')) {
 
 
 /**
 /**
  * Misc Code Fix Tools
  * Misc Code Fix Tools
- * 
+ *
  * cake Tools.Code dependencies [-p PluginName] [-c /custom/path]
  * cake Tools.Code dependencies [-p PluginName] [-c /custom/path]
  * - Fix missing App::uses() statements
  * - Fix missing App::uses() statements
- * 
+ *
  * @author Mark Scherer
  * @author Mark Scherer
  * @license MIT
  * @license MIT
  * 2012-07-19 ms
  * 2012-07-19 ms
@@ -17,7 +17,7 @@ if (!defined('LF')) {
 class CodeShell extends AppShell {
 class CodeShell extends AppShell {
 
 
 	protected $_files;
 	protected $_files;
-	
+
 	protected $_paths;
 	protected $_paths;
 
 
 	/**
 	/**
@@ -36,9 +36,9 @@ class CodeShell extends AppShell {
  		$this->_findFiles('php');
  		$this->_findFiles('php');
 		foreach ($this->_files as $file) {
 		foreach ($this->_files as $file) {
 			$this->out(__d('cake_console', 'Updating %s...', $file), 1, Shell::VERBOSE);
 			$this->out(__d('cake_console', 'Updating %s...', $file), 1, Shell::VERBOSE);
-			
+
 			$this->_correctFile($file);
 			$this->_correctFile($file);
-			
+
 			$this->out(__d('cake_console', 'Done updating %s', $file), 1, Shell::VERBOSE);
 			$this->out(__d('cake_console', 'Done updating %s', $file), 1, Shell::VERBOSE);
 		}
 		}
 	}
 	}
@@ -50,22 +50,22 @@ class CodeShell extends AppShell {
 		if (empty($matches)) {
 		if (empty($matches)) {
 			continue;
 			continue;
 		}
 		}
-		
+
 		$excludes = array('Fixture', 'Exception', 'TestSuite', 'CakeTestModel');
 		$excludes = array('Fixture', 'Exception', 'TestSuite', 'CakeTestModel');
 		$missingClasses = array();
 		$missingClasses = array();
-		
+
 		foreach ($matches[1] as $match) {
 		foreach ($matches[1] as $match) {
 			$match = trim($match);
 			$match = trim($match);
 			preg_match('/\bApp\:\:uses\(\''.$match.'\'/', $fileContent, $usesMatches);
 			preg_match('/\bApp\:\:uses\(\''.$match.'\'/', $fileContent, $usesMatches);
 			if (!empty($usesMatches)) {
 			if (!empty($usesMatches)) {
 				continue;
 				continue;
 			}
 			}
-			
+
 			preg_match('/class '.$match.'\s*(w+)?{/', $fileContent, $existingMatches);
 			preg_match('/class '.$match.'\s*(w+)?{/', $fileContent, $existingMatches);
 			if (!empty($existingMatches)) {
 			if (!empty($existingMatches)) {
 				continue;
 				continue;
 			}
 			}
-			
+
 			if (in_array($match, $missingClasses)) {
 			if (in_array($match, $missingClasses)) {
 				continue;
 				continue;
 			}
 			}
@@ -79,19 +79,19 @@ class CodeShell extends AppShell {
 			if ($break) {
 			if ($break) {
 				continue;
 				continue;
 			}
 			}
-			
-			
+
+
 			$missingClasses[] = $match;
 			$missingClasses[] = $match;
 		}
 		}
-		
+
 		if (empty($missingClasses)) {
 		if (empty($missingClasses)) {
 			return;
 			return;
 		}
 		}
-			
+
 		$fileContent = explode(LF, $fileContent);
 		$fileContent = explode(LF, $fileContent);
 		$inserted = array();
 		$inserted = array();
 		$pos = 1;
 		$pos = 1;
-		
+
 		if (!empty($fileContent[1]) && $fileContent[1] == '/**') {
 		if (!empty($fileContent[1]) && $fileContent[1] == '/**') {
 			for ($i = $pos; $i < count($fileContent)-1; $i++) {
 			for ($i = $pos; $i < count($fileContent)-1; $i++) {
 				if (strpos($fileContent[$i], '*/') !== false) {
 				if (strpos($fileContent[$i], '*/') !== false) {
@@ -102,7 +102,7 @@ class CodeShell extends AppShell {
 				}
 				}
 			}
 			}
 		}
 		}
-		
+
 		# try to find the best position to insert app uses statements
 		# try to find the best position to insert app uses statements
 		foreach ($fileContent as $row => $rowValue) {
 		foreach ($fileContent as $row => $rowValue) {
 			preg_match('/^App\:\:uses\(/', $rowValue, $matches);
 			preg_match('/^App\:\:uses\(/', $rowValue, $matches);
@@ -111,7 +111,7 @@ class CodeShell extends AppShell {
 				break;
 				break;
 			}
 			}
 		}
 		}
-		
+
 		foreach ($missingClasses as $missingClass) {
 		foreach ($missingClasses as $missingClass) {
 			$classes = array(
 			$classes = array(
 				'Controller' => 'Controller',
 				'Controller' => 'Controller',
@@ -135,15 +135,15 @@ class CodeShell extends AppShell {
 				$this->err($missingClass.' ('.$file.') could not be matched');
 				$this->err($missingClass.' ('.$file.') could not be matched');
 				continue;
 				continue;
 			}
 			}
-			
-		
+
+
 			if ($class == 'Model') {
 			if ($class == 'Model') {
 				$missingClassName = $missingClass;
 				$missingClassName = $missingClass;
 			} else {
 			} else {
 				$missingClassName = substr($missingClass, 0, strlen($missingClass) - strlen($class));
 				$missingClassName = substr($missingClass, 0, strlen($missingClass) - strlen($class));
 			}
 			}
 			$objects = App::objects(($this->params['plugin'] ? $this->params['plugin'].'.' : '') . $class);
 			$objects = App::objects(($this->params['plugin'] ? $this->params['plugin'].'.' : '') . $class);
-			
+
 			//FIXME: correct result for plugin classes
 			//FIXME: correct result for plugin classes
 			if ($missingClass == 'Component') {
 			if ($missingClass == 'Component') {
 				$type = 'Controller';
 				$type = 'Controller';
@@ -153,29 +153,29 @@ class CodeShell extends AppShell {
 				$type = $location;
 				$type = $location;
 				echo(returns($type));
 				echo(returns($type));
 			} elseif (in_array($missingClass, $objects)) {
 			} elseif (in_array($missingClass, $objects)) {
-				$type = $this->params['plugin'] . '.' . $type;
+				$type = ($this->params['plugin'] ? $this->params['plugin'].'.' : '') . '.' . $type;
 			} else {
 			} else {
 				$type = $type;
 				$type = $type;
 			}
 			}
-			
-			
+
+
 			$inserted[] = 'App::uses(\''.$missingClass.'\', \''.$type.'\');';
 			$inserted[] = 'App::uses(\''.$missingClass.'\', \''.$type.'\');';
 		}
 		}
-		
+
 		if (!$inserted) {
 		if (!$inserted) {
 			return;
 			return;
 		}
 		}
 
 
 		array_splice($fileContent, $pos, 0, $inserted);
 		array_splice($fileContent, $pos, 0, $inserted);
 		$fileContent = implode(LF, $fileContent);
 		$fileContent = implode(LF, $fileContent);
-	
+
 		if (empty($this->params['dry-run'])) {
 		if (empty($this->params['dry-run'])) {
 			file_put_contents($file, $fileContent);
 			file_put_contents($file, $fileContent);
 			$this->out(__d('cake_console', 'Correcting %s', $file), 1, Shell::VERBOSE);
 			$this->out(__d('cake_console', 'Correcting %s', $file), 1, Shell::VERBOSE);
 		}
 		}
 	}
 	}
 
 
-	
+
 
 
 	/**
 	/**
 	 * make sure all files are properly encoded (ü instead of &uuml; etc)
 	 * make sure all files are properly encoded (ü instead of &uuml; etc)
@@ -366,7 +366,7 @@ class CodeShell extends AppShell {
 function strposReverse($str, $search) {
 function strposReverse($str, $search) {
 	$str = strrev($str);
 	$str = strrev($str);
 	$search = strrev($search);
 	$search = strrev($search);
-	
+
 	$posRev = strpos($str, $search);
 	$posRev = strpos($str, $search);
 	return $posRev;
 	return $posRev;
 }
 }

+ 1 - 1
Controller/Component/AuthExtComponent.php

@@ -59,7 +59,7 @@ class AuthExtComponent extends AuthComponent {
 	public function __construct(ComponentCollection $Collection, $settings = array()) {
 	public function __construct(ComponentCollection $Collection, $settings = array()) {
 		$settings = array_merge($this->settings, (array)Configure::read('Auth'), (array)$settings);
 		$settings = array_merge($this->settings, (array)Configure::read('Auth'), (array)$settings);
 		//$this->Controller = $Collection->getController();
 		//$this->Controller = $Collection->getController();
-		
+
 		parent::__construct($Collection, $settings);
 		parent::__construct($Collection, $settings);
 	}
 	}
 
 

+ 3 - 3
Lib/Error/MyExceptionRenderer.php

@@ -20,10 +20,10 @@ class MyExceptionRenderer extends ExceptionRenderer {
 
 
 		$this->controller->render($template);
 		$this->controller->render($template);
 		$this->controller->response->type('html');
 		$this->controller->response->type('html');
-		
+
 		$x = $this->controller->response->body(); $this->controller->response->body(h($x));
 		$x = $this->controller->response->body(); $this->controller->response->body(h($x));
-		
+
 		$this->controller->response->send();
 		$this->controller->response->send();
 	}
 	}
-	
+
 }
 }

+ 1 - 1
Model/Behavior/JsonableBehavior.php

@@ -55,7 +55,7 @@ class JsonableBehavior extends ModelBehavior {
 	);
 	);
 
 
 	public function setup(Model $Model, $config = array()) {
 	public function setup(Model $Model, $config = array()) {
-  $this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
+		$this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
 		//extract ($this->settings[$Model->alias]);
 		//extract ($this->settings[$Model->alias]);
 		if (!is_array($this->settings[$Model->alias]['fields'])) {
 		if (!is_array($this->settings[$Model->alias]['fields'])) {
 			$this->settings[$Model->alias]['fields'] = (array)$this->settings[$Model->alias]['fields'];
 			$this->settings[$Model->alias]['fields'] = (array)$this->settings[$Model->alias]['fields'];

+ 1 - 1
Test/Case/Model/Behavior/DecimalInputBehaviorTest.php

@@ -93,7 +93,7 @@ class DecimalInputTestModel extends AppModel {
 	public $alias = 'TestModel';
 	public $alias = 'TestModel';
 
 
 	public $useTable = false;
 	public $useTable = false;
-	
+
 	public $displayField = 'title';
 	public $displayField = 'title';
 
 
 	public function find($type = null, $options = array(), $customData = null) {
 	public function find($type = null, $options = array(), $customData = null) {

+ 3 - 3
Test/Case/Model/Behavior/LinkableBehaviorTest.php

@@ -40,7 +40,7 @@ class LinkableBehaviorTest extends CakeTestCase {
 				'Profile'
 				'Profile'
 			)
 			)
 		));
 		));
-		
+
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Profile']), 'belongsTo association via Containable: %s');
 		$this->assertTrue(isset($arrayResult['Profile']), 'belongsTo association via Containable: %s');
@@ -156,7 +156,7 @@ class LinkableBehaviorTest extends CakeTestCase {
 			),
 			),
 			'order' => 'User.id ASC'
 			'order' => 'User.id ASC'
 		));
 		));
-		
+
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Comment']), 'hasMany association via Containable: %s');
 		$this->assertTrue(isset($arrayResult['Comment']), 'hasMany association via Containable: %s');
@@ -237,7 +237,7 @@ class LinkableBehaviorTest extends CakeTestCase {
 				)
 				)
 			)
 			)
 		));
 		));
-		
+
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp = $arrayExpected;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'Complex find: %s');
 		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'Complex find: %s');

+ 2 - 2
Test/Case/Model/Behavior/SluggedBehaviorTest.php

@@ -18128,7 +18128,7 @@ class SluggedTestCase extends CakeTestCase {
 		);
 		);
 		$this->assertEquals($expects, $result);
 		$this->assertEquals($expects, $result);
 	}
 	}
-		
+
 }
 }
 
 
 /**
 /**
@@ -18158,5 +18158,5 @@ class MessageSlugged extends CakeTestModel {
 		'mode' => 'id',
 		'mode' => 'id',
 		'replace' => false
 		'replace' => false
 	));
 	));
-	
+
 }
 }