From d1c2d5f3b8a185d97443b55a5795f9e8d54b0e91 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 6 Apr 2013 01:50:00 +0530 Subject: [PATCH] Coding standards and namespace fixes --- lib/Cake/Console/Command/Task/TestTask.php | 8 ------- lib/Cake/Console/Shell.php | 4 ++-- lib/Cake/Database/Connection.php | 17 ++++++------- .../Database/Dialect/MysqlDialectTrait.php | 2 +- .../Database/Dialect/PostgresDialectTrait.php | 3 +-- .../Database/Dialect/SqliteDialectTrait.php | 2 ++ lib/Cake/Database/Driver.php | 2 -- lib/Cake/Database/Driver/Mysql.php | 3 +-- lib/Cake/Database/Driver/PDODriverTrait.php | 2 +- lib/Cake/Database/Driver/Postgres.php | 2 +- lib/Cake/Database/Driver/Sqlite.php | 4 ++-- .../Expression/FunctionExpression.php | 3 ++- .../Database/Expression/QueryExpression.php | 4 ++-- .../Database/Expression/ValuesExpression.php | 2 +- lib/Cake/Database/Query.php | 24 +++++++++---------- .../Database/Statement/BufferedStatement.php | 2 +- lib/Cake/Database/Type.php | 1 + lib/Cake/Database/Type/BinaryType.php | 2 +- lib/Cake/Model/Behavior/TreeBehavior.php | 2 +- lib/Cake/Routing/Router.php | 2 +- .../Component/Auth/BasicAuthenticateTest.php | 3 ++- .../Component/Auth/DigestAuthenticateTest.php | 3 ++- .../Test/TestCase/Database/ConnectionTest.php | 24 +++++++++---------- .../TestCase/Database/Driver/PostgresTest.php | 1 - .../Expression/FunctionExpressionTest.php | 2 +- .../TestCase/Database/Log/QueryLoggerTest.php | 9 ++++--- lib/Cake/Test/TestCase/Database/QueryTest.php | 23 +++++++++--------- lib/Cake/Test/TestCase/Database/TypeTest.php | 2 +- .../TestCase/View/Helper/TextHelperTest.php | 18 +++++++------- lib/Cake/TestSuite/Reporter/BaseReporter.php | 1 - lib/Cake/Utility/Validation.php | 3 +-- lib/Cake/Utility/Xml.php | 2 +- lib/Cake/View/Helper/TextHelper.php | 2 +- 33 files changed, 85 insertions(+), 99 deletions(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 204cd4f67d4..640b74dca78 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -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. diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 1567ee707c3..a1ff6ada41d 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -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) { @@ -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; } diff --git a/lib/Cake/Database/Connection.php b/lib/Cake/Database/Connection.php index 6b27962ddc6..d1b1ac441fc 100644 --- a/lib/Cake/Database/Connection.php +++ b/lib/Cake/Database/Connection.php @@ -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 @@ -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'])) { @@ -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() { @@ -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()]); } } diff --git a/lib/Cake/Database/Dialect/MysqlDialectTrait.php b/lib/Cake/Database/Dialect/MysqlDialectTrait.php index 5cb4daed339..fdb33c22b8a 100644 --- a/lib/Cake/Database/Dialect/MysqlDialectTrait.php +++ b/lib/Cake/Database/Dialect/MysqlDialectTrait.php @@ -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, diff --git a/lib/Cake/Database/Dialect/PostgresDialectTrait.php b/lib/Cake/Database/Dialect/PostgresDialectTrait.php index ee606aedf99..a479fa6d50a 100644 --- a/lib/Cake/Database/Dialect/PostgresDialectTrait.php +++ b/lib/Cake/Database/Dialect/PostgresDialectTrait.php @@ -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; @@ -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 diff --git a/lib/Cake/Database/Dialect/SqliteDialectTrait.php b/lib/Cake/Database/Dialect/SqliteDialectTrait.php index a317ab53c98..736fb25aff0 100644 --- a/lib/Cake/Database/Dialect/SqliteDialectTrait.php +++ b/lib/Cake/Database/Dialect/SqliteDialectTrait.php @@ -21,6 +21,7 @@ use Cake\Database\Expression\FunctionExpression; use Cake\Database\Query; use Cake\Database\SqlDialectTrait; +use Cake\Error; trait SqliteDialectTrait { @@ -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) { diff --git a/lib/Cake/Database/Driver.php b/lib/Cake/Database/Driver.php index d785c18b058..23dab48bc2d 100644 --- a/lib/Cake/Database/Driver.php +++ b/lib/Cake/Database/Driver.php @@ -85,7 +85,6 @@ public abstract function commitTransaction(); **/ public abstract function rollbackTransaction(); - /** * Returns whether this driver supports save points for nested transactions * @@ -95,7 +94,6 @@ public function supportsSavePoints() { return true; } - /** * Returns a value in a safe representation to be used in a query string * diff --git a/lib/Cake/Database/Driver/Mysql.php b/lib/Cake/Database/Driver/Mysql.php index 16db63d07ef..35941f27fe1 100644 --- a/lib/Cake/Database/Driver/Mysql.php +++ b/lib/Cake/Database/Driver/Mysql.php @@ -21,8 +21,8 @@ class Mysql extends \Cake\Database\Driver { - use PDODriverTrait; use MysqlDialectTrait; + use PDODriverTrait; /** * Base configuration settings for MySQL driver @@ -84,5 +84,4 @@ public function enabled() { return in_array('mysql', PDO::getAvailableDrivers()); } - } diff --git a/lib/Cake/Database/Driver/PDODriverTrait.php b/lib/Cake/Database/Driver/PDODriverTrait.php index 19a3bdbfe95..368f05f434e 100644 --- a/lib/Cake/Database/Driver/PDODriverTrait.php +++ b/lib/Cake/Database/Driver/PDODriverTrait.php @@ -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); } diff --git a/lib/Cake/Database/Driver/Postgres.php b/lib/Cake/Database/Driver/Postgres.php index 4c557336061..200977faddb 100644 --- a/lib/Cake/Database/Driver/Postgres.php +++ b/lib/Cake/Database/Driver/Postgres.php @@ -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 { diff --git a/lib/Cake/Database/Driver/Sqlite.php b/lib/Cake/Database/Driver/Sqlite.php index 723fe11367d..e7ea8addf9e 100644 --- a/lib/Cake/Database/Driver/Sqlite.php +++ b/lib/Cake/Database/Driver/Sqlite.php @@ -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 { @@ -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); } diff --git a/lib/Cake/Database/Expression/FunctionExpression.php b/lib/Cake/Database/Expression/FunctionExpression.php index 72983502a88..7275cbcc8e4 100644 --- a/lib/Cake/Database/Expression/FunctionExpression.php +++ b/lib/Cake/Database/Expression/FunctionExpression.php @@ -16,6 +16,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ namespace Cake\Database\Expression; + use Cake\Database\ExpressionInterface; /** @@ -110,7 +111,7 @@ public function add($params, $types = []) { */ public function sql() { return $this->_name . sprintf('(%s)', implode( - $this->_conjunction. ' ', + $this->_conjunction . ' ', $this->_conditions )); } diff --git a/lib/Cake/Database/Expression/QueryExpression.php b/lib/Cake/Database/Expression/QueryExpression.php index 9e804f6c477..73f007cc6b9 100644 --- a/lib/Cake/Database/Expression/QueryExpression.php +++ b/lib/Cake/Database/Expression/QueryExpression.php @@ -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; @@ -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); } /** diff --git a/lib/Cake/Database/Expression/ValuesExpression.php b/lib/Cake/Database/Expression/ValuesExpression.php index 2bf47082884..c4b2c51a72e 100644 --- a/lib/Cake/Database/Expression/ValuesExpression.php +++ b/lib/Cake/Database/Expression/ValuesExpression.php @@ -17,9 +17,9 @@ */ namespace Cake\Database\Expression; -use Cake\Error; use Cake\Database\ExpressionInterface; use Cake\Database\Query; +use Cake\Error; use \Countable; /** diff --git a/lib/Cake/Database/Query.php b/lib/Cake/Database/Query.php index 31c78bb1925..59ac6fe9f17 100644 --- a/lib/Cake/Database/Query.php +++ b/lib/Cake/Database/Query.php @@ -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 @@ -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. @@ -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. * @@ -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; @@ -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) { @@ -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) @@ -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' => [ @@ -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. * * {{{ @@ -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); @@ -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 diff --git a/lib/Cake/Database/Statement/BufferedStatement.php b/lib/Cake/Database/Statement/BufferedStatement.php index 561b2a12185..87f4ce2e50b 100644 --- a/lib/Cake/Database/Statement/BufferedStatement.php +++ b/lib/Cake/Database/Statement/BufferedStatement.php @@ -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; } diff --git a/lib/Cake/Database/Type.php b/lib/Cake/Database/Type.php index 8e906df90e4..0beaa89b9d4 100644 --- a/lib/Cake/Database/Type.php +++ b/lib/Cake/Database/Type.php @@ -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) { diff --git a/lib/Cake/Database/Type/BinaryType.php b/lib/Cake/Database/Type/BinaryType.php index 72c5db7503c..684e8e03aea 100644 --- a/lib/Cake/Database/Type/BinaryType.php +++ b/lib/Cake/Database/Type/BinaryType.php @@ -16,8 +16,8 @@ */ namespace Cake\Database\Type; -use Cake\Error; use Cake\Database\Driver; +use Cake\Error; use \PDO; /** diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index d6b0efeacf8..e0e4822faa6 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -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) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 853806abdcc..3612be6890c 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -46,7 +46,7 @@ class Router { * * @var Cake\Routing\RouteCollection */ - public static $_routes; + protected static $_routes; /** * Have routes been loaded diff --git a/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php index 005b8975e87..3505781fae6 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php @@ -140,7 +140,8 @@ public function testAuthenticateChallenge() { try { $this->auth->unauthenticated($request, $this->response); - } catch (Error\UnauthorizedException $e) {} + } catch (Error\UnauthorizedException $e) { + } $this->assertNotEmpty($e); diff --git a/lib/Cake/Test/TestCase/Controller/Component/Auth/DigestAuthenticateTest.php b/lib/Cake/Test/TestCase/Controller/Component/Auth/DigestAuthenticateTest.php index d27e7512b3b..b5ce021c95f 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/Auth/DigestAuthenticateTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/Auth/DigestAuthenticateTest.php @@ -139,7 +139,8 @@ public function testAuthenticateChallenge() { try { $this->auth->unauthenticated($request, $this->response); - } catch (Error\UnauthorizedException $e) {} + } catch (Error\UnauthorizedException $e) { + } $this->assertNotEmpty($e); diff --git a/lib/Cake/Test/TestCase/Database/ConnectionTest.php b/lib/Cake/Test/TestCase/Database/ConnectionTest.php index 64b3f1d17ff..85c595458d4 100644 --- a/lib/Cake/Test/TestCase/Database/ConnectionTest.php +++ b/lib/Cake/Test/TestCase/Database/ConnectionTest.php @@ -25,7 +25,6 @@ **/ class ConnectionTest extends \Cake\TestSuite\TestCase { - public function setUp() { $this->connection = new Connection(Configure::read('Datasource.test')); } @@ -53,7 +52,7 @@ public function testConnect() { * @return void **/ public function testMissingDriver() { - $connection = new Connection(['datasource' => '\Foo\InvalidDriver']); + $connection = new Connection(['datasource' => '\Foo\InvalidDriver']); } /** @@ -117,13 +116,13 @@ public function testExecuteWithArguments() { $this->assertEquals([2], $result); $sql = 'SELECT 1 + ? + ? AS total'; - $statement = $this->connection->execute($sql, [2, 3], array('integer', 'integer')); + $statement = $this->connection->execute($sql, [2, 3], array('integer', 'integer')); $this->assertCount(1, $statement); $result = $statement->fetch('assoc'); $this->assertEquals(['total' => 6], $result); $sql = 'SELECT 1 + :one + :two AS total'; - $statement = $this->connection->execute($sql, ['one' => 2, 'two' => 3], array('one' => 'integer', 'two' => 'integer')); + $statement = $this->connection->execute($sql, ['one' => 2, 'two' => 3], array('one' => 'integer', 'two' => 'integer')); $this->assertCount(1, $statement); $result = $statement->fetch('assoc'); $this->assertEquals(['total' => 6], $result); @@ -179,7 +178,7 @@ public function testExecuteWithNoParams() { public function testInsertWithMatchingTypes() { $table = 'CREATE TEMPORARY TABLE things(id int, title varchar(20), body varchar(50))'; $this->connection->execute($table); - $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; + $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; $result = $this->connection->insert( 'things', $data, @@ -200,7 +199,7 @@ public function testInsertWithMatchingTypes() { public function testInsertWithPositionalTypes() { $table = 'CREATE TEMPORARY TABLE things(id int, title varchar(20), body varchar(50))'; $this->connection->execute($table); - $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; + $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; $result = $this->connection->insert( 'things', $data, @@ -221,7 +220,7 @@ public function testInsertWithPositionalTypes() { protected function _insertTwoRecords() { $table = 'CREATE TEMPORARY TABLE things(id int, title varchar(20), body varchar(50))'; $this->connection->execute($table); - $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; + $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body']; $result = $this->connection->insert( 'things', $data, @@ -246,7 +245,7 @@ public function testStatementReusing() { $total = $total->fetch('assoc'); $this->assertEquals(2, $total['total']); - $result = $this->connection->execute('SELECT title, body FROM things'); + $result = $this->connection->execute('SELECT title, body FROM things'); $row = $result->fetch('assoc'); $this->assertEquals('a title', $row['title']); $this->assertEquals('a body', $row['body']); @@ -308,7 +307,7 @@ public function testUpdateWithTypes() { $title = 'changed the title!'; $body = new \DateTime('2012-01-01'); $values = compact('title', 'body'); - $this->connection->update('things', $values, [], ['body' => 'date']); + $this->connection->update('things', $values, [], ['body' => 'date']); $result = $this->connection->execute('SELECT * FROM things WHERE title = :title AND body = :body', $values, ['body' => 'date']); $this->assertCount(2, $result); $row = $result->fetch('assoc'); @@ -346,7 +345,6 @@ public function testDeleteNoConditions() { $this->assertCount(0, $result); } - /** * Tests delete from table with conditions * @return void @@ -527,15 +525,15 @@ public function testSavePoints2() { public function testQuote() { $this->skipIf(!$this->connection->supportsQuoting()); $expected = "'2012-01-01'"; - $result =$this->connection->quote(new \DateTime('2012-01-01'), 'date'); + $result = $this->connection->quote(new \DateTime('2012-01-01'), 'date'); $this->assertEquals($expected, $result); $expected = "'1'"; - $result =$this->connection->quote(1, 'string'); + $result = $this->connection->quote(1, 'string'); $this->assertEquals($expected, $result); $expected = "'hello'"; - $result =$this->connection->quote('hello', 'string'); + $result = $this->connection->quote('hello', 'string'); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php b/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php index cd75ae2e8e6..af7dcaf7a12 100644 --- a/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php +++ b/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php @@ -267,7 +267,6 @@ public function testConvertColumnType($input, $expected) { $this->assertEquals($expected, $driver->convertColumn($input)); } - /** * Test listing tables with Postgres * diff --git a/lib/Cake/Test/TestCase/Database/Expression/FunctionExpressionTest.php b/lib/Cake/Test/TestCase/Database/Expression/FunctionExpressionTest.php index cdc44e2ac40..2b1c8830ef7 100644 --- a/lib/Cake/Test/TestCase/Database/Expression/FunctionExpressionTest.php +++ b/lib/Cake/Test/TestCase/Database/Expression/FunctionExpressionTest.php @@ -49,7 +49,7 @@ public function testArityMultiplePlainValues() { $this->assertEquals('foo', $f->bindings()[1]['value']); $this->assertEquals('bar', $f->bindings()[2]['value']); - + $f = new FunctionExpression('MyFunction', ['bar']); $bar = $f->id() . '0'; $this->assertEquals("MyFunction(:c$bar)", $f->sql()); diff --git a/lib/Cake/Test/TestCase/Database/Log/QueryLoggerTest.php b/lib/Cake/Test/TestCase/Database/Log/QueryLoggerTest.php index 6feaf7078c8..087e59e4c9b 100644 --- a/lib/Cake/Test/TestCase/Database/Log/QueryLoggerTest.php +++ b/lib/Cake/Test/TestCase/Database/Log/QueryLoggerTest.php @@ -16,9 +16,9 @@ */ namespace Cake\Test\TestCase\Model\Datasource\Database\Log; -use Cake\Log\Log; use Cake\Database\Log\LoggedQuery; use Cake\Database\Log\QueryLogger; +use Cake\Log\Log; /** * Tests QueryLogger class @@ -70,7 +70,7 @@ public function testStingInterpolation() { $logger = $this->getMock('\Cake\Database\Log\QueryLogger', ['_log']); $query = new LoggedQuery; $query->query = 'SELECT a FROM b where a = :p1 AND b = :p2 AND c = :p3'; - $query->params = ['p1' => 'string', 'p2' => 3, 'p3' => null]; + $query->params = ['p1' => 'string', 'p2' => 3, 'p3' => null]; $logger->expects($this->once())->method('_log')->with($query); $logger->log($query); @@ -87,7 +87,7 @@ public function testStingInterpolation2() { $logger = $this->getMock('\Cake\Database\Log\QueryLogger', ['_log']); $query = new LoggedQuery; $query->query = 'SELECT a FROM b where a = ? AND b = ? AND c = ?'; - $query->params = ['string', '3', null]; + $query->params = ['string', '3', null]; $logger->expects($this->once())->method('_log')->with($query); $logger->log($query); @@ -105,7 +105,7 @@ public function testLogFunction() { $logger = new QueryLogger; $query = new LoggedQuery; $query->query = 'SELECT a FROM b where a = ? AND b = ? AND c = ?'; - $query->params = ['string', '3', null]; + $query->params = ['string', '3', null]; $engine = $this->getMock('\Cake\Log\Engine\BaseLog', ['write'], ['scopes' => ['queriesLog']]); Log::engine('queryLoggerTest', $engine); $engine2 = $this->getMock('\Cake\Log\Engine\BaseLog', ['write'], ['scopes' => ['foo']]); @@ -114,5 +114,4 @@ public function testLogFunction() { $logger->log($query); } - } diff --git a/lib/Cake/Test/TestCase/Database/QueryTest.php b/lib/Cake/Test/TestCase/Database/QueryTest.php index 3a670819a84..4a501a6eb5d 100644 --- a/lib/Cake/Test/TestCase/Database/QueryTest.php +++ b/lib/Cake/Test/TestCase/Database/QueryTest.php @@ -55,14 +55,14 @@ protected function _createAuthorsAndArticles() { protected function _insertTwoRecords() { $this->_createAuthorsAndArticles(); - $data = ['id' => '1', 'name' => 'Chuck Norris']; + $data = ['id' => '1', 'name' => 'Chuck Norris']; $result = $this->connection->insert('authors', $data, ['id' => 'integer', 'name' => 'string']); $result->bindValue(1, '2', 'integer'); $result->bindValue(2, 'Bruce Lee'); $result->execute(); - $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body', 'author_id' => 1]; + $data = ['id' => '1', 'title' => 'a title', 'body' => 'a body', 'author_id' => 1]; $result = $this->connection->insert( 'articles', $data, @@ -88,7 +88,7 @@ protected function _insertDateRecords() { $this->connection->execute($table); $data = [ 'id' => '1', - 'name' => 'Chuck Norris', + 'name' => 'Chuck Norris', 'posted' => new \DateTime('2012-12-21 12:00'), 'visible' => 'Y' ]; @@ -665,7 +665,7 @@ public function testSelectWhereUsingClosure() { ->where(function($exp) { return $exp ->eq('id', 1) - ->eq('posted', new \DateTime('2012-12-21 12:00'), 'datetime'); + ->eq('posted', new \DateTime('2012-12-21 12:00'), 'datetime'); }) ->execute(); $this->assertCount(1, $result); @@ -678,7 +678,7 @@ public function testSelectWhereUsingClosure() { ->where(function($exp) { return $exp ->eq('id', 1) - ->eq('posted', new \DateTime('2021-12-30 15:00'), 'datetime'); + ->eq('posted', new \DateTime('2021-12-30 15:00'), 'datetime'); }) ->execute(); $this->assertCount(0, $result); @@ -698,7 +698,7 @@ public function testSelectAndWhereUsingClosure() { ->from('dates') ->where(['id' => '1']) ->andWhere(function($exp) { - return $exp->eq('posted', new \DateTime('2012-12-21 12:00'), 'datetime'); + return $exp->eq('posted', new \DateTime('2012-12-21 12:00'), 'datetime'); }) ->execute(); $this->assertCount(1, $result); @@ -710,7 +710,7 @@ public function testSelectAndWhereUsingClosure() { ->from('dates') ->where(['id' => '1']) ->andWhere(function($exp) { - return $exp->eq('posted', new \DateTime('2022-12-21 12:00'), 'datetime'); + return $exp->eq('posted', new \DateTime('2022-12-21 12:00'), 'datetime'); }) ->execute(); $this->assertCount(0, $result); @@ -730,7 +730,7 @@ public function testSelectOrWhereUsingClosure() { ->from('dates') ->where(['id' => '1']) ->orWhere(function($exp) { - return $exp->eq('posted', new \DateTime('2012-12-22 12:00'), 'datetime'); + return $exp->eq('posted', new \DateTime('2012-12-22 12:00'), 'datetime'); }) ->execute(); $this->assertCount(2, $result); @@ -744,8 +744,8 @@ public function testSelectOrWhereUsingClosure() { ->where(['id' => '1']) ->orWhere(function($exp) { return $exp - ->eq('posted', new \DateTime('2012-12-22 12:00'), 'datetime') - ->eq('id', 3); + ->eq('posted', new \DateTime('2012-12-22 12:00'), 'datetime') + ->eq('id', 3); }) ->execute(); $this->assertCount(1, $result); @@ -1593,7 +1593,7 @@ public function testDecorateResults() { } $results = $query->decorateResults(null, true)->execute(); - while($row = $result->fetch('assoc')) { + while ($row = $result->fetch('assoc')) { $this->assertArrayNotHasKey('foo', $row); $this->assertArrayNotHasKey('modified_id', $row); } @@ -1999,7 +1999,6 @@ public function testSQLFunctions() { ); } - /** * Assertion for comparing a table's contents with what is in it. * diff --git a/lib/Cake/Test/TestCase/Database/TypeTest.php b/lib/Cake/Test/TestCase/Database/TypeTest.php index 3bad3c095d0..f608f664677 100644 --- a/lib/Cake/Test/TestCase/Database/TypeTest.php +++ b/lib/Cake/Test/TestCase/Database/TypeTest.php @@ -117,7 +117,7 @@ public function testMapAndBuild() { $this->assertNotEmpty($map); $this->assertFalse(isset($map['foo'])); - $fooType = __NAMESPACE__ . '\FooType'; + $fooType = __NAMESPACE__ . '\FooType'; Type::map('foo', $fooType); $map = Type::map(); $this->assertEquals($fooType, $map['foo']); diff --git a/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php index 8725245587b..d8cd90bc34c 100644 --- a/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/TextHelperTest.php @@ -354,24 +354,22 @@ public function testAutoParagraph() {

This is a test text

TEXT; - $result = $this->Text->autoParagraph($text); - $text = 'This is a

test text'; - $expected = <<Text->autoParagraph($text); + $text = 'This is a

test text'; + $expected = <<This is a

test text

TEXT; - $result = $this->Text->autoParagraph($text); - $this->assertEquals($expected, $result); - $result = $this->Text->autoParagraph($text); - $text = 'This is a

test text'; - $expected = <<Text->autoParagraph($text); + $this->assertEquals($expected, $result); + $result = $this->Text->autoParagraph($text); + $text = 'This is a

test text'; + $expected = <<This is a

test text

TEXT; - $result = $this->Text->autoParagraph($text); - $this->assertEquals($expected, $result); $text = <<paintFooter($result); } - /** * An error occurred. * diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 4272f8d5282..18a50a8619d 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -614,8 +614,7 @@ public static function phone($check, $regex = null, $country = 'all') { switch ($country) { case 'us': case 'ca': - // deprecated three-letter-code - case 'can': + case 'can': // deprecated three-letter-code case 'all': // includes all NANPA members. // see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 14f59571c5b..3997ac6e95e 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -115,7 +115,7 @@ public static function build($input, $options = array()) { } return static::_loadXml($response->body, $options); } catch (Error\SocketException $e) { - throw new XmlException(__d('cake_dev', 'XML cannot be read.')); + throw new Error\XmlException(__d('cake_dev', 'XML cannot be read.')); } } elseif (!is_string($input)) { throw new Error\XmlException(__d('cake_dev', 'Invalid input.')); diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 011cdf4d1a6..513b07cec20 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -253,7 +253,7 @@ public function autoParagraph($text) { } return $text; } - + /** * @see String::stripLinks() *