Skip to content

Commit

Permalink
Coding standards and namespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 5, 2013
1 parent 6c50ad8 commit d1c2d5f
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 99 deletions.
8 changes: 0 additions & 8 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -549,14 +549,6 @@ public function generateUses($type, $realType, $fullClassName) {
return $uses;
}

/**
* Make the filename for the test case. resolve the suffixes for controllers
* and get the plugin path if needed.
}
$uses[] = $fullClassName;
return $uses;
}
/**
* Make the filename for the test case. resolve the suffixes for controllers
* and get the plugin path if needed.
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Shell.php
Expand Up @@ -277,7 +277,7 @@ public function __isset($name) {
* @param string $modelClass Name of model class to load
* @param mixed $id Initial ID the instanced model class should have
* @return mixed true when single model found and instance created, error returned if model not found.
* @throws MissingModelException if the model class cannot be found.
* @throws Cake\Error\MissingModelException if the model class cannot be found.
*/
public function loadModel($modelClass = null, $id = null) {
if ($modelClass === null) {
Expand All @@ -300,7 +300,7 @@ public function loadModel($modelClass = null, $id = null) {
'id' => $id
));
if (!$this->{$modelClass}) {
throw new MissingModelException($modelClass);
throw new Error\MissingModelException($modelClass);
}
return true;
}
Expand Down
17 changes: 9 additions & 8 deletions lib/Cake/Database/Connection.php
Expand Up @@ -19,10 +19,11 @@
use Cake\Database\Exception\MissingConnectionException;
use Cake\Database\Exception\MissingDriverException;
use Cake\Database\Exception\MissingExtensionException;
use Cake\Database\Query;
use Cake\Database\Log\LoggedQuery;
use Cake\Database\Log\LoggingStatement;
use Cake\Database\Log\QueryLogger;
use Cake\Database\Log\LoggedQuery;
use Cake\Database\Query;
use Cake\Error;

/**
* Represents a connection with a database server
Expand Down Expand Up @@ -93,19 +94,19 @@ class Connection {
* Constructor
*
* @param array $config configuration for connecting to database
* @throws MissingDriverException if driver class can not be found
* @throws MissingExtensionException if driver cannot be used
* @throws Cake\Error\MissingDriverException if driver class can not be found
* @throws Cake\Error\MissingExtensionException if driver cannot be used
* @return self
*/
public function __construct($config) {
$this->_config = $config;
if (!class_exists($config['datasource'])) {
throw new MissingDriverException(['driver' => $config['datasource']]);
throw new Error\MissingDriverException(['driver' => $config['datasource']]);
}

$this->driver($config['datasource']);
if (!$this->_driver->enabled()) {
throw new MissingExtensionException(['driver' => get_class($this->_driver)]);
throw new Error\MissingExtensionException(['driver' => get_class($this->_driver)]);
}

if (!empty($config['log'])) {
Expand Down Expand Up @@ -135,7 +136,7 @@ public function driver($driver = null) {
/**
* Connects to the configured database
*
* @throws MissingConnectionException if credentials are invalid
* @throws Cake\Error\MissingConnectionException if credentials are invalid
* @return boolean true on success or false if already connected.
*/
public function connect() {
Expand All @@ -145,7 +146,7 @@ public function connect() {
try {
return $this->_connected = $this->_driver->connect($this->_config);
} catch(\Exception $e) {
throw new MissingConnectionException(['reason' => $e->getMessage()]);
throw new Error\MissingConnectionException(['reason' => $e->getMessage()]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Database/Dialect/MysqlDialectTrait.php
Expand Up @@ -17,8 +17,8 @@
*/
namespace Cake\Database\Dialect;

use Cake\Error;
use Cake\Database\SqlDialectTrait;
use Cake\Error;

/**
* Contains functions that encapsulates the SQL dialect used by MySQL,
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Database/Dialect/PostgresDialectTrait.php
Expand Up @@ -17,8 +17,8 @@
*/
namespace Cake\Database\Dialect;

use Cake\Database\Expression\UnaryExpression;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Expression\UnaryExpression;
use Cake\Database\Query;
use Cake\Database\SqlDialectTrait;

Expand Down Expand Up @@ -99,7 +99,6 @@ protected function _rowNumberRemover() {
};
}


/**
* Returns an dictionary of expressions to be transformed when compiling a Query
* to SQL. Array keys are method names to be called in this class
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Database/Dialect/SqliteDialectTrait.php
Expand Up @@ -21,6 +21,7 @@
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Query;
use Cake\Database\SqlDialectTrait;
use Cake\Error;

trait SqliteDialectTrait {

Expand Down Expand Up @@ -132,6 +133,7 @@ protected function _insertQueryTranslator($query) {
* Cake\Database\Type can handle.
*
* @param string $column The column type + length
* @throws Cake\Error\Exception
* @return array List of (type, length)
*/
public function convertColumn($column) {
Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/Database/Driver.php
Expand Up @@ -85,7 +85,6 @@ public abstract function commitTransaction();
**/
public abstract function rollbackTransaction();


/**
* Returns whether this driver supports save points for nested transactions
*
Expand All @@ -95,7 +94,6 @@ public function supportsSavePoints() {
return true;
}


/**
* Returns a value in a safe representation to be used in a query string
*
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Database/Driver/Mysql.php
Expand Up @@ -21,8 +21,8 @@

class Mysql extends \Cake\Database\Driver {

use PDODriverTrait;
use MysqlDialectTrait;
use PDODriverTrait;

/**
* Base configuration settings for MySQL driver
Expand Down Expand Up @@ -84,5 +84,4 @@ public function enabled() {
return in_array('mysql', PDO::getAvailableDrivers());
}


}
2 changes: 1 addition & 1 deletion lib/Cake/Database/Driver/PDODriverTrait.php
Expand Up @@ -68,7 +68,7 @@ public function disconnect() {
* @param string $sql
* @return Cake\Database\Statement
*/
public function prepare($sql) {
public function prepare($sql) {
$statement = $this->connection()->prepare($sql);
return new PDOStatement($statement, $this);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Database/Driver/Postgres.php
Expand Up @@ -17,8 +17,8 @@
*/
namespace Cake\Database\Driver;

use Cake\Database\Statement;
use Cake\Database\Dialect\PostgresDialectTrait;
use Cake\Database\Statement;
use PDO;

class Postgres extends \Cake\Database\Driver {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Database/Driver/Sqlite.php
Expand Up @@ -16,9 +16,9 @@
*/
namespace Cake\Database\Driver;

use Cake\Database\Dialect\SqliteDialectTrait;
use Cake\Database\Statement\PDOStatement;
use Cake\Database\Statement\SqliteStatement;
use Cake\Database\Dialect\SqliteDialectTrait;
use PDO;

class Sqlite extends \Cake\Database\Driver {
Expand Down Expand Up @@ -84,7 +84,7 @@ public function enabled() {
* @param string $sql
* @return Cake\Database\Statement
*/
public function prepare($sql) {
public function prepare($sql) {
$statement = $this->connection()->prepare($sql);
return new SqliteStatement(new PDOStatement($statement, $this), $this);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Database/Expression/FunctionExpression.php
Expand Up @@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Database\Expression;

use Cake\Database\ExpressionInterface;

/**
Expand Down Expand Up @@ -110,7 +111,7 @@ public function add($params, $types = []) {
*/
public function sql() {
return $this->_name . sprintf('(%s)', implode(
$this->_conjunction. ' ',
$this->_conjunction . ' ',
$this->_conditions
));
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Database/Expression/QueryExpression.php
Expand Up @@ -62,7 +62,7 @@ class QueryExpression implements ExpressionInterface, Countable {
/**
* An unique string that identifies this object. It is used to create unique
* placeholders.
*
*
* @car string
*/
protected $_identifier;
Expand Down Expand Up @@ -562,7 +562,7 @@ protected function _parseCondition($field, $value, $types) {
}

$placeholder = $this->_bindValue($field, $value, $type);
return sprintf('%s %s (%s)', $expression, $operator, $placeholder);
return sprintf('%s %s (%s)', $expression, $operator, $placeholder);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Database/Expression/ValuesExpression.php
Expand Up @@ -17,9 +17,9 @@
*/
namespace Cake\Database\Expression;

use Cake\Error;
use Cake\Database\ExpressionInterface;
use Cake\Database\Query;
use Cake\Error;
use \Countable;

/**
Expand Down
24 changes: 12 additions & 12 deletions lib/Cake/Database/Query.php
Expand Up @@ -17,14 +17,14 @@
*/
namespace Cake\Database;

use IteratorAggregate;
use Cake\Error;
use Cake\Database\Expression\Comparison;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Expression\OrderByExpression;
use Cake\Database\Expression\QueryExpression;
use Cake\Database\Expression\ValuesExpression;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Statement\CallbackStatement;
use Cake\Error;
use IteratorAggregate;

/**
* This class represents a Relational database SQL Query. A query can be of
Expand Down Expand Up @@ -94,7 +94,7 @@ class Query implements ExpressionInterface, IteratorAggregate {

/**
* When compiling a query to its SQL representation, the connection being used
* for its execution has the ability to internally change it or even create a
* for its execution has the ability to internally change it or even create a
* completely different Query object to save any differences with its dialect.
* This property holds a reference to the Query object that resulted from
* transforming this instance.
Expand Down Expand Up @@ -224,7 +224,7 @@ public function sql($transform = true) {
* functions can aggregate results using variables in the closure or instance
* variables. This function is commonly used as a way for traversing all query parts that
* are going to be used for constructing a query.
*
*
* The callback will receive 2 parameters, the first one is the value of the query
* part that is being iterated and the second the name of such part.
*
Expand Down Expand Up @@ -463,7 +463,7 @@ public function from($tables = [], $overwrite = false) {
if ($overwrite) {
$this->_parts['from'] = $tables;
} else {
$this->_parts['from'] = array_merge($this->_parts['from'], $tables);
$this->_parts['from'] = array_merge($this->_parts['from'], $tables);
}

$this->_dirty = true;
Expand All @@ -478,7 +478,7 @@ public function from($tables = [], $overwrite = false) {
* @param array $parts list of tables to be transformed to string
* @return string
*/
public function _buildFromPart($parts) {
protected function _buildFromPart($parts) {
$select = ' FROM %s';
$normalized = [];
foreach ($parts as $k => $p) {
Expand All @@ -496,7 +496,7 @@ public function _buildFromPart($parts) {
* join parts, an array with multiple join descriptions, or a single string.
*
* By default this function will append any passed argument to the list of tables
* to be joined, unless the third argument is set to true.
* to be joined, unless the third argument is set to true.
*
* When no join type is specified an INNER JOIN is used by default:
* ``$query->join(['authors'])`` Will produce INNER JOIN authors ON (1 = 1)
Expand All @@ -505,7 +505,7 @@ public function _buildFromPart($parts) {
* ``$query->join(['a' => 'authors'])`` Will produce INNER JOIN authors a ON (1 = 1)
*
* A join can be fully described and aliased using the array notation:
*
*
* {{{
* $query->join([
* 'a' => [
Expand Down Expand Up @@ -537,7 +537,7 @@ public function _buildFromPart($parts) {
* possible to using conditions expressed in arrays or expression objects.
*
* When using arrays for expressing conditions, it is often desirable to convert
* the literal values to the correct database representation. This is achieved
* the literal values to the correct database representation. This is achieved
* using the second parameter of this function.
*
* {{{
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public function union($query, $all = false, $overwrite = false) {
*/
protected function _buildUnionPart($parts) {
$parts = array_map(function($p) {
$p['query'] =(string)$p['query'];
$p['query'] = (string)$p['query'];
$p['query'] = $p['query'][0] === '(' ? trim($p['query'], '()') : $p['query'];
return $p['all'] ? 'ALL ' . $p['query'] : $p['query'];
}, $parts);
Expand Down Expand Up @@ -1317,7 +1317,7 @@ public function getIterator() {
* Returns any data that was stored in the specified clause. This is useful for
* modifying any internal part of the query and it is used by the SQL dialects
* to transform the query accordingly before it is executed. The valid clauses that
* can be retrieved are: delete, update, set, insert, values, select, distinct,
* can be retrieved are: delete, update, set, insert, values, select, distinct,
* from, join, set, where, group, having, order, limit, offset and union.
*
* The return value for each of those parts may vary. Some clauses use QueryExpression
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Database/Statement/BufferedStatement.php
Expand Up @@ -35,7 +35,7 @@ public function execute($params = null) {

public function fetch($type = 'num') {
if ($this->_allFetched) {
$row = ($this->_counter <= $this->_count) ? $this->_records[$this->_counter++] : false;
$row = ($this->_counter <= $this->_count) ? $this->_records[$this->_counter++] : false;
$row = ($row && $type === 'num') ? array_values($row) : $row;
return $row;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Database/Type.php
Expand Up @@ -89,6 +89,7 @@ public function __construct($name = null) {
* Returns a Type object capable of converting a type identified by $name
*
* @param string $name type identifier
* @throws InvalidArgumentException If type identifier is unknown
* @return Type
*/
public static function build($name) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Database/Type/BinaryType.php
Expand Up @@ -16,8 +16,8 @@
*/
namespace Cake\Database\Type;

use Cake\Error;
use Cake\Database\Driver;
use Cake\Error;
use \PDO;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TreeBehavior.php
Expand Up @@ -678,7 +678,7 @@ protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = nu
$hasChildren = (bool)$children;

if (!is_null($parentId)) {
if($hasChildren) {
if ($hasChildren) {
$Model->updateAll(
array($this->settings[$Model->alias]['left'] => $counter),
array($Model->escapeField() => $parentId)
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -46,7 +46,7 @@ class Router {
*
* @var Cake\Routing\RouteCollection
*/
public static $_routes;
protected static $_routes;

/**
* Have routes been loaded
Expand Down

0 comments on commit d1c2d5f

Please sign in to comment.