Commit: 8de98e982a08b0ae5437cafcd2e2ada504ec968f

Author: Nate Abele | Date: 2010-08-24 23:58:46 -0400
Fixing coding standards violations. Closes ticket #143.
diff --git a/libraries/lithium/data/Entity.php b/libraries/lithium/data/Entity.php index 4e6abd6..53f55d4 100644 --- a/libraries/lithium/data/Entity.php +++ b/libraries/lithium/data/Entity.php @@ -366,8 +366,9 @@ class Entity extends \lithium\core\Object { * default values and internal state. * * @param string $classType The type of class to create, either `'entity'` or `'set'`. - * @param array $data - * @param array $options + * @param string $key The key name to which the related object is assigned. + * @param array $data The internal data of the related object. + * @param array $options Any other options to pass when instantiating the related object. * @return object Returns a new `Entity` object instance. */ protected function _relation($classType, $key, $data, $options = array()) { diff --git a/libraries/lithium/data/Source.php b/libraries/lithium/data/Source.php index 50ecfca..c33821d 100644 --- a/libraries/lithium/data/Source.php +++ b/libraries/lithium/data/Source.php @@ -207,14 +207,14 @@ abstract class Source extends \lithium\core\Object { /** * A method which can be optionally implemented to configure a model class. * + * @see lithium\data\Model::$_meta + * @see lithium\data\Model::$_finders + * @see lithium\data\Model::$_classes * @param string $class The name of the model class to be configured. * @return array This method should return an array one or more of the following keys: `'meta'`, * `'classes'` or `'finders'`. These keys maps to the three corresponding properties in * `lithium\data\Model`, and are used to override the base-level default settings and * dependencies. - * @see lithium\data\Model::$_meta - * @see lithium\data\Model::$_finders - * @see lithium\data\Model::$_classes */ public function configureClass($class) { return array(); diff --git a/libraries/lithium/data/collection/DocumentSet.php b/libraries/lithium/data/collection/DocumentSet.php index 2aa4558..0965a14 100644 --- a/libraries/lithium/data/collection/DocumentSet.php +++ b/libraries/lithium/data/collection/DocumentSet.php @@ -229,8 +229,9 @@ class DocumentSet extends \lithium\data\Collection { * default values and internal state. * * @param string $classType The type of class to create, either `'entity'` or `'set'`. - * @param array $data - * @param array $options + * @param string $key The key name to which the related object is assigned. + * @param array $data The internal data of the related object. + * @param array $options Any other options to pass when instantiating the related object. * @return object Returns a new `Document` object instance. */ protected function _relation($classType, $key, $data, $options = array()) { diff --git a/libraries/lithium/data/entity/Document.php b/libraries/lithium/data/entity/Document.php index 9f247df..67a06ca 100644 --- a/libraries/lithium/data/entity/Document.php +++ b/libraries/lithium/data/entity/Document.php @@ -238,8 +238,9 @@ class Document extends \lithium\data\Entity { * default values and internal state. * * @param string $classType The type of class to create, either `'entity'` or `'set'`. - * @param array $data - * @param array $options + * @param string $key The key name to which the related object is assigned. + * @param array $data The internal data of the related object. + * @param array $options Any other options to pass when instantiating the related object. * @return object Returns a new `Document` object instance. */ protected function _relation($classType, $key, $data, $options = array()) { diff --git a/libraries/lithium/data/model/Query.php b/libraries/lithium/data/model/Query.php index 11ea015..7ed3899 100644 --- a/libraries/lithium/data/model/Query.php +++ b/libraries/lithium/data/model/Query.php @@ -131,10 +131,11 @@ class Query extends \lithium\core\Object { /** * Returns or sets the column mapping scheme for relational databases. * + * @param array $map Assigns the column map for this query. * @return void */ public function map($map = null) { - if ($map) { + if ($map !== null) { $this->_map = $map; } return $this->_map; @@ -346,10 +347,11 @@ class Query extends \lithium\core\Object { } /** - * Convert the query's properties to the data-sources' syntax and return it as an array. + * Convert the query's properties to the data sources' syntax and return it as an array. * - * @param object $dataSource Instance of the data-source to use for conversion. - * @return array Converted properties. + * @param object $dataSource Instance of the data source to use for conversion. + * @param array $options Options to use when exporting the data. + * @return array Returns an array containing a data source-specific representation of a query. */ public function export(Source $dataSource, array $options = array()) { $defaults = array('data' => array()); diff --git a/libraries/lithium/data/source/Database.php b/libraries/lithium/data/source/Database.php index 507d876..6d696ba 100644 --- a/libraries/lithium/data/source/Database.php +++ b/libraries/lithium/data/source/Database.php @@ -466,12 +466,12 @@ abstract class Database extends \lithium\data\Source { * * - If `$key` is numeric and `$value` is a string, `$value` is treated as a literal SQL * fragment and returned. - * - * * @param string|array $conditions The conditions for this query. - * @param object $context The current `\lithium\data\model\Query`. + * @param object $context The current `lithium\data\model\Query` instance. * @param array $options - * - `prepend` : added before WHERE clause + * - `prepend` _boolean_: Whether the return string should be prepended with the + * `WHERE` keyword. * @return string Returns the `WHERE` clause of an SQL query. */ public function conditions($conditions, $context, array $options = array()) { diff --git a/libraries/lithium/data/source/MongoDb.php b/libraries/lithium/data/source/MongoDb.php index 0725a0e..11d70d8 100644 --- a/libraries/lithium/data/source/MongoDb.php +++ b/libraries/lithium/data/source/MongoDb.php @@ -332,7 +332,7 @@ class MongoDb extends \lithium\data\Source { $result = $self->connection->{$params['source']}->insert($data, true); } - if (isset($result['ok']) && (bool) $result['ok'] === true) { + if (isset($result['ok']) && (boolean) $result['ok'] === true) { $query->entity()->update($data['_id']); return true; } diff --git a/libraries/lithium/data/source/database/adapter/MySql.php b/libraries/lithium/data/source/database/adapter/MySql.php index c5c0fa2..e88010f 100644 --- a/libraries/lithium/data/source/database/adapter/MySql.php +++ b/libraries/lithium/data/source/database/adapter/MySql.php @@ -229,7 +229,7 @@ class MySql extends \lithium\data\source\Database { * * @param string $type next|close The current step in the iteration. * @param mixed $resource The result resource returned from the database. - * @param \lithium\data\model\Query $context The given query. + * @param object $context The given query (an instance of `lithium\data\model\Query`). * @return mixed Result */ public function result($type, $resource, $context) { @@ -309,10 +309,9 @@ class MySql extends \lithium\data\source\Database { * @param string $sql The sql string to execute * @param array $options Available options: * - 'buffered': If set to `false` uses mysql_unbuffered_query which - * sends the SQL query query to MySQL without automatically - * fetching and buffering the result rows as mysql_query() does (for - * less memory usage). - * @return resource + * sends the SQL query query to MySQL without automatically fetching and buffering the + * result rows as `mysql_query()` does (for less memory usage). + * @return resource Returns the result resource handle if the query is successful. */ protected function _execute($sql, array $options = array()) { $defaults = array('buffered' => true); diff --git a/libraries/lithium/data/source/database/adapter/Sqlite3.php b/libraries/lithium/data/source/database/adapter/Sqlite3.php index c639d2e..2cc6500 100644 --- a/libraries/lithium/data/source/database/adapter/Sqlite3.php +++ b/libraries/lithium/data/source/database/adapter/Sqlite3.php @@ -32,7 +32,9 @@ class Sqlite3 extends \lithium\data\source\Database { 'integer' => array('name' => 'integer', 'limit' => 11, 'formatter' => 'intval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'), 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), + 'timestamp' => array( + 'name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date' + ), 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'), 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'), 'binary' => array('name' => 'blob'), @@ -42,6 +44,9 @@ class Sqlite3 extends \lithium\data\source\Database { /** * Constructs the Sqlite adapter * + * @see lithium\data\source\Database::__construct() + * @see lithium\data\Source::__construct() + * @see lithium\data\Connections::add() * @param array $config Configuration options for this class. For additional configuration, * see `lithium\data\source\Database` and `lithium\data\Source`. Available options * defined by this class: @@ -54,10 +59,6 @@ class Sqlite3 extends \lithium\data\source\Database { * Typically, these parameters are set in `Connections::add()`, when adding the adapter to the * list of active connections. * @return The adapter instance. - * - * @see lithium\data\source\Database::__construct() - * @see lithium\data\Source::__construct() - * @see lithium\data\Connections::add() */ public function __construct(array $config = array()) { $defaults = array( @@ -150,18 +151,18 @@ class Sqlite3 extends \lithium\data\source\Database { /** * Get the last insert id from the database. * - * @param \lithium\data\model\Query $context The given query. + * @param object $query The given query, usually an instance of `lithium\data\model\Query`. * @return void */ - protected function _insertId($query) { - } + protected function _insertId($query) {} /** * Gets or sets the encoding for the connection. * - * @param $encoding - * @return boolean|string If setting the encoding; returns true on success, else false. - * When getting, returns the encoding. + * @param string $encoding If setting the encoding, this is the name of the encoding to set, + * i.e. `'utf8'` or `'UTF-8'` (both formats are valid). + * @return boolean|string If setting the encoding; returns `true` on success, or `false` on + * failure. When getting, returns the encoding as a string. */ public function encoding($encoding = null) { $encodingMap = array('UTF-8' => 'utf8'); @@ -180,7 +181,7 @@ class Sqlite3 extends \lithium\data\source\Database { * * @param string $type next|close The current step in the iteration. * @param mixed $resource The result resource returned from the database. - * @param \lithium\data\model\Query $context The given query. + * @param object $context The given query (an instance of `lithium\data\model\Query`). * @return mixed Result */ public function result($type, $resource, $context) { diff --git a/libraries/lithium/net/http/Router.php b/libraries/lithium/net/http/Router.php index bc9d8d2..d08982d 100644 --- a/libraries/lithium/net/http/Router.php +++ b/libraries/lithium/net/http/Router.php @@ -176,8 +176,14 @@ class Router extends \lithium\core\StaticObject { * containing a manually generated URL. * @param object $context An instance of `lithium\action\Request`. This supplies the context for * any persistent parameters, as well as the base URL for the application. - * @param array $options Options for the generation of the matched URL. Currently accepted values - * are: `'absolute' => true|false`, `'host' => string` and `'scheme' => string`. + * @param array $options Options for the generation of the matched URL. Currently accepted + * values are: + * - `'absolute'` _boolean_: Indicates whether or not the returned URL should be an + * absolute path (i.e. including scheme and host name). + * - `'host'` _string_: If `'absolute'` is `true`, sets the host name to be used, + * or overrides the one provided in `$context`. + * - `'scheme'` _string_: If `'absolute'` is `true`, sets the URL scheme to be + * used, or overrides the one provided in `$context`. * @return string Returns a generated URL, based on the URL template of the matched route, and * prefixed with the base URL of the application. */ diff --git a/libraries/lithium/storage/session/adapter/Cookie.php b/libraries/lithium/storage/session/adapter/Cookie.php index 2f393d8..b0fbc6a 100644 --- a/libraries/lithium/storage/session/adapter/Cookie.php +++ b/libraries/lithium/storage/session/adapter/Cookie.php @@ -121,7 +121,9 @@ class Cookie extends \lithium\core\Object { } return ($result !== array()) ? $result : null; } - return (isset($_COOKIE[$config['name']][$key])) ? $_COOKIE[$config['name']][$key] : null; + if (isset($_COOKIE[$config['name']][$key])) { + return $_COOKIE[$config['name']][$key]; + } }; } diff --git a/libraries/lithium/storage/session/adapter/Memory.php b/libraries/lithium/storage/session/adapter/Memory.php index db6961c..af476e7 100644 --- a/libraries/lithium/storage/session/adapter/Memory.php +++ b/libraries/lithium/storage/session/adapter/Memory.php @@ -136,4 +136,4 @@ class Memory extends \lithium\core\Object { } } -?> +?> \ No newline at end of file diff --git a/libraries/lithium/storage/session/adapter/Php.php b/libraries/lithium/storage/session/adapter/Php.php index ffb6d10..99acb5a 100644 --- a/libraries/lithium/storage/session/adapter/Php.php +++ b/libraries/lithium/storage/session/adapter/Php.php @@ -236,4 +236,4 @@ class Php extends \lithium\core\Object { } } -?> +?> \ No newline at end of file diff --git a/libraries/lithium/test/filter/Coverage.php b/libraries/lithium/test/filter/Coverage.php index 12b8485..bbc8fee 100644 --- a/libraries/lithium/test/filter/Coverage.php +++ b/libraries/lithium/test/filter/Coverage.php @@ -58,16 +58,17 @@ class Coverage extends \lithium\test\Filter { * instances each line was called. */ public static function analyze($report, array $classes = array()) { - $filterResults = static::collect($report->results['filters'][__CLASS__]); - $classes = $classes ?: array_filter(get_declared_classes(), function($class) use ($filterResults) { - return (!(is_subclass_of($class, 'lithium\test\Unit')) || array_key_exists($class, $filterResults)); + $data = static::collect($report->results['filters'][__CLASS__]); + $classes = $classes ?: array_filter(get_declared_classes(), function($class) use ($data) { + $unit = 'lithium\test\Unit'; + return (!(is_subclass_of($class, $unit)) || array_key_exists($class, $data)); }); - $classes = array_values(array_intersect((array) $classes, array_keys($filterResults))); + $classes = array_values(array_intersect((array) $classes, array_keys($data))); $densities = $result = array(); foreach ($classes as $class) { $classMap = array($class => Libraries::path($class)); - $densities += static::_density($filterResults[$class], $classMap); + $densities += static::_density($data[$class], $classMap); } $executableLines = array(); @@ -146,10 +147,8 @@ class Coverage extends \lithium\test\Filter { ); } } - $result[$class]['output'][$file] = $out; } - return $result; } diff --git a/libraries/lithium/tests/cases/data/collection/RecordSetTest.php b/libraries/lithium/tests/cases/data/collection/RecordSetTest.php index 7a300f5..53561d6 100644 --- a/libraries/lithium/tests/cases/data/collection/RecordSetTest.php +++ b/libraries/lithium/tests/cases/data/collection/RecordSetTest.php @@ -201,7 +201,9 @@ class RecordSetTest extends \lithium\test\Unit { $items = $this->_recordSet->get('_data'); $this->assertEqual($expected, $items[1]->to('array')); - $this->_objectRecordSet[5] = $expected = new MockPostObject(array('id' => 5, 'data' => 'data5')); + $this->_objectRecordSet[5] = $expected = new MockPostObject(array( + 'id' => 5, 'data' => 'data5' + )); $items = $this->_recordSet->get('_data'); $this->assertEqual($expected->id, $items[0]->id); $this->assertEqual($expected->data, $items[0]->data); diff --git a/libraries/lithium/tests/cases/data/source/DatabaseTest.php b/libraries/lithium/tests/cases/data/source/DatabaseTest.php index bedef9f..5ab00a0 100644 --- a/libraries/lithium/tests/cases/data/source/DatabaseTest.php +++ b/libraries/lithium/tests/cases/data/source/DatabaseTest.php @@ -165,7 +165,8 @@ class DatabaseTest extends \lithium\test\Unit { 'fields' => array('id', 'title', 'created'), 'limit' => 1 ))); - $expected = 'SELECT id, title, created From {mock_database_posts} AS {MockDatabasePost} LIMIT 1;'; + $expected = 'SELECT id, title, created From {mock_database_posts} AS {MockDatabasePost} '; + $expected .= 'LIMIT 1;'; $this->assertEqual($expected, $result); $result = $this->db->renderCommand(new Query(array( @@ -175,8 +176,8 @@ class DatabaseTest extends \lithium\test\Unit { 'limit' => 1, 'conditions' => 'Post.id = 2' ))); - $expected = 'SELECT id, title, created From {mock_database_posts} AS {MockDatabasePost} WHERE Post.id = 2'; - $expected .= ' LIMIT 1;'; + $expected = 'SELECT id, title, created From {mock_database_posts} AS {MockDatabasePost} '; + $expected .= 'WHERE Post.id = 2 LIMIT 1;'; $this->assertEqual($expected, $result); } @@ -196,8 +197,8 @@ class DatabaseTest extends \lithium\test\Unit { $expected = "SELECT MockDatabasePost.title, MockDatabasePost.body From"; $expected .= " {mock_database_posts} AS {MockDatabasePost} WHERE Post.id IN"; - $expected .= " (SELECT post_id From {mock_database_taggings} AS {MockDatabaseTagging} WHERE "; - $expected .= "MockDatabaseTag.tag IN ('foo', 'bar', 'baz'));"; + $expected .= " (SELECT post_id From {mock_database_taggings} AS {MockDatabaseTagging} "; + $expected .= "WHERE MockDatabaseTag.tag IN ('foo', 'bar', 'baz'));"; $this->assertEqual($expected, $result); } @@ -418,7 +419,8 @@ class DatabaseTest extends \lithium\test\Unit { 'conditions' => array('score' => array('between' => array(90, 100))), 'model' => 'lithium\tests\mocks\data\model\MockDatabasePost' )); - $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE {score} BETWEEN 90 AND 100;"; + $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE {score} "; + $sql .= "BETWEEN 90 AND 100;"; $this->assertEqual($sql, $this->db->renderCommand($query)); $query = new Query(array( @@ -426,7 +428,8 @@ class DatabaseTest extends \lithium\test\Unit { 'conditions' => array('score' => array('>' => 90, '<' => 100)), 'model' => 'lithium\tests\mocks\data\model\MockDatabasePost' )); - $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE {score} > 90 AND {score} < 100;"; + $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE "; + $sql .= "{score} > 90 AND {score} < 100;"; $this->assertEqual($sql, $this->db->renderCommand($query)); $query = new Query(array( @@ -434,7 +437,8 @@ class DatabaseTest extends \lithium\test\Unit { 'conditions' => array('score' => array('!=' => array(98, 99, 100))), 'model' => 'lithium\tests\mocks\data\model\MockDatabasePost' )); - $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE {score} NOT IN (98, 99, 100);"; + $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} "; + $sql .= "WHERE {score} NOT IN (98, 99, 100);"; $this->assertEqual($sql, $this->db->renderCommand($query)); $query = new Query(array( @@ -442,7 +446,8 @@ class DatabaseTest extends \lithium\test\Unit { 'conditions' => "custom conditions string", 'model' => 'lithium\tests\mocks\data\model\MockDatabasePost' )); - $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE custom conditions string;"; + $sql = "SELECT * From {mock_database_posts} AS {MockDatabasePost} WHERE "; + $sql .= "custom conditions string;"; $this->assertEqual($sql, $this->db->renderCommand($query)); } diff --git a/libraries/lithium/tests/cases/template/helper/FormTest.php b/libraries/lithium/tests/cases/template/helper/FormTest.php index eec60c4..b2a3e59 100644 --- a/libraries/lithium/tests/cases/template/helper/FormTest.php +++ b/libraries/lithium/tests/cases/template/helper/FormTest.php @@ -616,4 +616,4 @@ class FormTest extends \lithium\test\Unit { } } -?> +?> \ No newline at end of file diff --git a/libraries/lithium/tests/cases/util/CollectionTest.php b/libraries/lithium/tests/cases/util/CollectionTest.php index 53716e3..536cf4c 100644 --- a/libraries/lithium/tests/cases/util/CollectionTest.php +++ b/libraries/lithium/tests/cases/util/CollectionTest.php @@ -46,7 +46,9 @@ class CollectionTest extends \lithium\test\Unit { $result = $collection->invoke('mapArray', array(), array('merge' => true)); $this->assertEqual($result, array_fill(0, 10, 'foo')); - $collection = new Collection(array('data' => array_fill(0, 10, new MockCollectionObject()))); + $collection = new Collection(array( + 'data' => array_fill(0, 10, new MockCollectionObject()) + )); $result = $collection->testFoo(); $this->assertEqual($result, array_fill(0, 10, 'testFoo')); @@ -56,17 +58,23 @@ class CollectionTest extends \lithium\test\Unit { } public function testObjectCasting() { - $collection = new Collection(array('data' => array_fill(0, 10, new MockCollectionObject()))); + $collection = new Collection(array( + 'data' => array_fill(0, 10, new MockCollectionObject()) + )); $result = $collection->to('array'); $expected = array_fill(0, 10, array(1 => 2, 2 => 3)); $this->assertEqual($expected, $result); - $collection = new Collection(array('data' => array_fill(0, 10, new MockCollectionMarker()))); + $collection = new Collection(array( + 'data' => array_fill(0, 10, new MockCollectionMarker()) + )); $result = $collection->to('array'); $expected = array_fill(0, 10, array('marker' => false, 'data' => 'foo')); $this->assertEqual($expected, $result); - $collection = new Collection(array('data' => array_fill(0, 10, new MockCollectionStringCast()))); + $collection = new Collection(array( + 'data' => array_fill(0, 10, new MockCollectionStringCast()) + )); $result = $collection->to('array'); $expected = array_fill(0, 10, json_encode(array(1 => 2, 2 => 3))); $this->assertEqual($expected, $result); diff --git a/libraries/lithium/tests/cases/util/SetTest.php b/libraries/lithium/tests/cases/util/SetTest.php index 92ad8bd..cdf2bb8 100644 --- a/libraries/lithium/tests/cases/util/SetTest.php +++ b/libraries/lithium/tests/cases/util/SetTest.php @@ -8,7 +8,8 @@ namespace lithium\tests\cases\util; -use \lithium\util\Set; +use stdClass; +use lithium\util\Set; class SetTest extends \lithium\test\Unit { @@ -691,7 +692,9 @@ class SetTest extends \lithium\test\Unit { $result = Set::extract($tree, '/Category[name=Category 2]'); $this->assertEqual($expected, $result); - $expected = array(array('Category' => $tree[1]['Category'], 'children' => $tree[1]['children'])); + $expected = array(array( + 'Category' => $tree[1]['Category'], 'children' => $tree[1]['children'] + )); $result = Set::extract($tree, '/Category[name=Category 2]/..'); $this->assertEqual($expected, $result); @@ -906,7 +909,9 @@ class SetTest extends \lithium\test\Unit { $a = array('users' => array('bob', 'jim')); $b = array('users' => array('lisa', 'tina')); - $this->assertIdentical(Set::merge($a, $b), array('users' => array('bob', 'jim', 'lisa', 'tina'))); + $this->assertIdentical( + Set::merge($a, $b), array('users' => array('bob', 'jim', 'lisa', 'tina')) + ); $a = array('users' => array('jim', 'bob')); $b = array('users' => 'none'); @@ -946,45 +951,52 @@ class SetTest extends \lithium\test\Unit { $result = Set::merge($a, Set::merge($b, $c)); $this->assertIdentical($expected, $result); - $a = array('Tree', 'CounterCache', - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id'))); - $b = array('Cacheable' => array('enabled' => false), - 'Limit', - 'Bindable', - 'Validator', - 'Transactional'); - - $expected = array('Tree', 'CounterCache', - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')), - 'Cacheable' => array('enabled' => false), - 'Limit', - 'Bindable', - 'Validator', - 'Transactional'); + $a = array('Tree', 'CounterCache', 'Upload' => array( + 'folder' => 'products', 'fields' => array( + 'image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id' + ) + )); + $b = array( + 'Cacheable' => array('enabled' => false), + 'Limit', 'Bindable', 'Validator', 'Transactional' + ); + $expected = array('Tree', 'CounterCache', 'Upload' => array( + 'folder' => 'products', 'fields' => array( + 'image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id' + )), + 'Cacheable' => array('enabled' => false), + 'Limit', + 'Bindable', + 'Validator', + 'Transactional' + ); $this->assertIdentical(Set::merge($a, $b), $expected); - $expected = array('Tree' => null, 'CounterCache' => null, - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')), - 'Cacheable' => array('enabled' => false), - 'Limit' => null, - 'Bindable' => null, - 'Validator' => null, - 'Transactional' => null); - + $expected = array('Tree' => null, 'CounterCache' => null, 'Upload' => array( + 'folder' => 'products', 'fields' => array( + 'image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id' + )), + 'Cacheable' => array('enabled' => false), + 'Limit' => null, + 'Bindable' => null, + 'Validator' => null, + 'Transactional' => null + ); $this->assertIdentical(Set::normalize(Set::merge($a, $b)), $expected); } public function testSort() { $a = array( array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - array('Person' => array('name' => 'Tracy'),'Friend' => array(array('name' => 'Lindsay'))) + array('Person' => array('name' => 'Tracy'), 'Friend' => array( + array('name' => 'Lindsay') + )) ); $b = array( - array('Person' => array('name' => 'Tracy'),'Friend' => array(array('name' => 'Lindsay'))), + array('Person' => array('name' => 'Tracy'),'Friend' => array( + array('name' => 'Lindsay') + )), array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))) ); $a = Set::sort($a, '/Friend/name', 'asc'); @@ -992,10 +1004,14 @@ class SetTest extends \lithium\test\Unit { $b = array( array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))) + array('Person' => array('name' => 'Tracy'), 'Friend' => array( + array('name' => 'Lindsay') + )) ); $a = array( - array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))), + array('Person' => array('name' => 'Tracy'), 'Friend' => array( + array('name' => 'Lindsay') + )), array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))) ); $a = Set::sort($a, '/Friend/name', 'desc'); @@ -1003,13 +1019,17 @@ class SetTest extends \lithium\test\Unit { $a = array( array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))), + array('Person' => array('name' => 'Tracy'), 'Friend' => array( + array('name' => 'Lindsay') + )), array('Person' => array('name' => 'Adam'), 'Friend' => array(array('name' => 'Bob'))) ); $b = array( array('Person' => array('name' => 'Adam'),'Friend' => array(array('name' => 'Bob'))), array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))) + array('Person' => array('name' => 'Tracy'), 'Friend' => array( + array('name' => 'Lindsay') + )) ); $a = Set::sort($a, '/Person/name', 'asc'); $this->assertIdentical($a, $b); @@ -1260,7 +1280,7 @@ class SetTest extends \lithium\test\Unit { ); $this->assertIdentical($expected, $result); - $b = new \stdClass(); + $b = new stdClass(); $b->users = array( array('User' => array( 'id' => 2, 'group_id' => 1, 'Data' => array( @@ -1379,10 +1399,10 @@ class SetTest extends \lithium\test\Unit { public function testToArrayFromObject() { $expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id' => 851))); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->psword = 'whatever'; - $class->User->Icon = new \stdClass; + $class->User->Icon = new stdClass(); $class->User->Icon->id = 851; $result = Set::to('array', $class); $this->assertIdentical($expected, $result); @@ -1393,12 +1413,12 @@ class SetTest extends \lithium\test\Unit { 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address') ) ); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->psword = 'whatever'; - $class->User->Icon = new \stdClass; + $class->User->Icon = new stdClass(); $class->User->Icon->id = 851; - $class->User->Profile = new \stdClass; + $class->User->Profile = new stdClass(); $class->User->Profile->name = 'Some Name'; $class->User->Profile->address = 'Some Address'; @@ -1423,16 +1443,16 @@ class SetTest extends \lithium\test\Unit { ) )); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->psword = 'whatever'; - $class->User->Icon = new \stdClass; + $class->User->Icon = new stdClass(); $class->User->Icon->id = 851; - $class->User->Profile = new \stdClass; + $class->User->Profile = new stdClass(); $class->User->Profile->name = 'Some Name'; $class->User->Profile->address = 'Some Address'; - $class->User->Comment = new \stdClass; - $class->User->Comment->{'0'} = new \stdClass; + $class->User->Comment = new stdClass(); + $class->User->Comment->{'0'} = new stdClass(); $class->User->Comment->{'0'}->id = 1; $class->User->Comment->{'0'}->article_id = 1; $class->User->Comment->{'0'}->user_id = 1; @@ -1440,7 +1460,7 @@ class SetTest extends \lithium\test\Unit { $class->User->Comment->{'0'}->published = 'Y'; $class->User->Comment->{'0'}->created = '2007-03-18 10:47:23'; $class->User->Comment->{'0'}->updated = '2007-03-18 10:49:31'; - $class->User->Comment->{'1'} = new \stdClass; + $class->User->Comment->{'1'} = new stdClass(); $class->User->Comment->{'1'}->id = 2; $class->User->Comment->{'1'}->article_id = 1; $class->User->Comment->{'1'}->user_id = 2; @@ -1470,16 +1490,16 @@ class SetTest extends \lithium\test\Unit { ) )); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->psword = 'whatever'; - $class->User->Icon = new \stdClass; + $class->User->Icon = new stdClass(); $class->User->Icon->id = 851; - $class->User->Profile = new \stdClass; + $class->User->Profile = new stdClass(); $class->User->Profile->name = 'Some Name'; $class->User->Profile->address = 'Some Address'; $class->User->Comment = array(); - $comment = new \stdClass; + $comment = new stdClass(); $comment->id = 1; $comment->article_id = 1; $comment->user_id = 1; @@ -1487,7 +1507,7 @@ class SetTest extends \lithium\test\Unit { $comment->published = 'Y'; $comment->created = '2007-03-18 10:47:23'; $comment->updated = '2007-03-18 10:49:31'; - $comment2 = new \stdClass; + $comment2 = new stdClass(); $comment2->id = 2; $comment2->article_id = 1; $comment2->user_id = 2; @@ -1499,11 +1519,11 @@ class SetTest extends \lithium\test\Unit { $result = Set::to('array', $class); $this->assertIdentical($expected, $result); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->id = 100; $class->someString = 'this is some string'; - $class->Profile = new \stdClass; + $class->Profile = new stdClass(); $class->Profile->name = 'Joe Mamma'; $result = Set::to('array', $class); @@ -1514,11 +1534,11 @@ class SetTest extends \lithium\test\Unit { ); $this->assertEqual($expected, $result); - $class = new \stdClass; - $class->User = new \stdClass; + $class = new stdClass(); + $class->User = new stdClass(); $class->User->id = 100; $class->User->_name_ = 'User'; - $class->Profile = new \stdClass; + $class->Profile = new stdClass(); $class->Profile->name = 'Joe Mamma'; $class->Profile->_name_ = 'Profile'; @@ -1531,7 +1551,7 @@ class SetTest extends \lithium\test\Unit { } public function testAssociativeArrayToObject() { - $data =array( + $data = array( 'Post' => array( 'id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', @@ -1546,7 +1566,7 @@ class SetTest extends \lithium\test\Unit { ), ); $result = Set::to('object', $data); - $expected = new \stdClass; + $expected = new stdClass(); $expected->_name_ = 'Post'; $expected->id = '1'; $expected->author_id = '1'; @@ -1556,7 +1576,7 @@ class SetTest extends \lithium\test\Unit { $expected->created = "2007-03-18 10:39:23"; $expected->updated = "2007-03-18 10:41:31"; - $expected->Author = new \stdClass; + $expected->Author = new stdClass(); $expected->Author->id = '1'; $expected->Author->user = 'mariano'; $expected->Author->password = '5f4dcc3b5aa765d61d8327deb882cf99'; @@ -1602,7 +1622,7 @@ class SetTest extends \lithium\test\Unit { ); $result = Set::to('object', $data); - $expected = new \stdClass; + $expected = new stdClass(); $expected->_name_ = 'Post'; $expected->id = '1'; $expected->author_id = '1'; @@ -1612,7 +1632,7 @@ class SetTest extends \lithium\test\Unit { $expected->created = "2007-03-18 10:39:23"; $expected->updated = "2007-03-18 10:41:31"; - $expected->Author = new \stdClass; + $expected->Author = new stdClass(); $expected->Author->id = '1'; $expected->Author->user = 'mariano'; $expected->Author->password = '5f4dcc3b5aa765d61d8327deb882cf99'; @@ -1621,7 +1641,7 @@ class SetTest extends \lithium\test\Unit { $expected->Author->test = "working"; $expected->Author->_name_ = 'Author'; - $expected2 = new \stdClass; + $expected2 = new stdClass(); $expected2->_name_ = 'Post'; $expected2->id = '2'; $expected2->author_id = '3'; @@ -1631,7 +1651,7 @@ class SetTest extends \lithium\test\Unit { $expected2->created = "2007-03-18 10:41:23"; $expected2->updated = "2007-03-18 10:43:31"; - $expected2->Author = new \stdClass; + $expected2->Author = new stdClass(); $expected2->Author->id = '3'; $expected2->Author->user = 'joel'; $expected2->Author->password = '5f4dcc3b5aa765d61d8327deb882cf99'; @@ -1685,19 +1705,19 @@ class SetTest extends \lithium\test\Unit { $result = Set::to('object', $data); - $expected = new \stdClass(); + $expected = new stdClass(); $expected->_name_ = 'User'; $expected->id = 1; $expected->email = 'user@example.com'; $expected->first_name = 'John'; $expected->last_name = 'Smith'; - $piece = new \stdClass(); + $piece = new stdClass(); $piece->id = 1; $piece->title = 'Moonlight Sonata'; $piece->composer = 'Ludwig van Beethoven'; - $piece->PiecesUser = new \stdClass(); + $piece->PiecesUser = new stdClass(); $piece->PiecesUser->id = 1; $piece->PiecesUser->created = '2008-01-01 00:00:00'; $piece->PiecesUser->modified = '2008-01-01 00:00:00'; @@ -1708,12 +1728,12 @@ class SetTest extends \lithium\test\Unit { $piece->_name_ = 'Piece'; - $piece2 = new \stdClass(); + $piece2 = new stdClass(); $piece2->id = 2; $piece2->title = 'Moonlight Sonata 2'; $piece2->composer = 'Ludwig van Beethoven'; - $piece2->PiecesUser = new \stdClass(); + $piece2->PiecesUser = new stdClass(); $piece2->PiecesUser->id = 2; $piece2->PiecesUser->created = '2008-01-01 00:00:00'; $piece2->PiecesUser->modified = '2008-01-01 00:00:00'; @@ -1722,7 +1742,6 @@ class SetTest extends \lithium\test\Unit { $piece2->PiecesUser->_name_ = 'PiecesUser'; $piece2->_name_ = 'Piece'; - $expected->Piece = array($piece, $piece2); $this->assertEqual($expected, $result); @@ -1802,19 +1821,19 @@ class SetTest extends \lithium\test\Unit { $result = Set::to('object', $data); - $expected = new \stdClass(); + $expected = new stdClass(); $expected->_name_ = 'FooUser'; $expected->id = 1; $expected->email = 'user@example.com'; $expected->first_name = 'John'; $expected->last_name = 'Smith'; - $piece = new \stdClass(); + $piece = new stdClass(); $piece->id = 1; $piece->title = 'Moonlight Sonata'; $piece->composer = 'Ludwig van Beethoven'; $piece->_name_ = 'FooPiece'; - $piece->PiecesUser = new \stdClass(); + $piece->PiecesUser = new stdClass(); $piece->PiecesUser->id = 1; $piece->PiecesUser->created = '2008-01-01 00:00:00'; $piece->PiecesUser->modified = '2008-01-01 00:00:00'; @@ -1822,12 +1841,12 @@ class SetTest extends \lithium\test\Unit { $piece->PiecesUser->user_id = 2; $piece->PiecesUser->_name_ = 'FooPiecesUser'; - $piece2 = new \stdClass(); + $piece2 = new stdClass(); $piece2->id = 2; $piece2->title = 'Moonlight Sonata 2'; $piece2->composer = 'Ludwig van Beethoven'; $piece2->_name_ = 'FooPiece'; - $piece2->PiecesUser = new \stdClass(); + $piece2->PiecesUser = new stdClass(); $piece2->PiecesUser->id = 2; $piece2->PiecesUser->created = '2008-01-01 00:00:00'; $piece2->PiecesUser->modified = '2008-01-01 00:00:00'; @@ -1939,7 +1958,7 @@ class SetTest extends \lithium\test\Unit { ); $mapped = Set::to('object', $data); - $expected = new \stdClass(); + $expected = new stdClass(); $expected->_name_ = 'IndexedPage'; $expected->id = 2; $expected->url = 'http://blah.com/'; diff --git a/libraries/lithium/tests/cases/util/ValidatorTest.php b/libraries/lithium/tests/cases/util/ValidatorTest.php index e5f60ec..a63b2c6 100644 --- a/libraries/lithium/tests/cases/util/ValidatorTest.php +++ b/libraries/lithium/tests/cases/util/ValidatorTest.php @@ -329,12 +329,12 @@ class ValidatorTest extends \lithium\test\Unit { */ $this->assertFalse( Validator::isEmail('abc@example'), - 'Invalid email address passed validation. Please update to PHP 5.3.3 '. + 'Invalid email address passed validation. Please update to PHP 5.3.3 ' . 'or higher to correct this.' ); $this->assertFalse( Validator::isEmail('abc.@example.com'), - 'Invalid email address passed validation. Please update to PHP 5.3.3 '. + 'Invalid email address passed validation. Please update to PHP 5.3.3 ' . 'or higher to correct this.' ); diff --git a/libraries/lithium/tests/mocks/data/MockPostObject.php b/libraries/lithium/tests/mocks/data/MockPostObject.php index 4dfaa0b..9a22ab3 100644 --- a/libraries/lithium/tests/mocks/data/MockPostObject.php +++ b/libraries/lithium/tests/mocks/data/MockPostObject.php @@ -21,4 +21,4 @@ class MockPostObject { } } -?> +?> \ No newline at end of file diff --git a/libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php b/libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php index 40d671b..ef83290 100644 --- a/libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php +++ b/libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php @@ -41,16 +41,23 @@ class MockDocumentMultipleKey extends \lithium\data\Model { public static function find($type = 'all', array $options = array()) { switch ($type) { case 'first': - return new Document(array('data' => - array('id' => 2, 'rev' => '1-1', 'name' => 'Two', 'content' => 'Lorem ipsum two') - )); + return new Document(array('data' => array( + 'id' => 2, 'rev' => '1-1', 'name' => 'Two', 'content' => 'Lorem ipsum two' + ))); break; case 'all': default : return new Document(array('data' => array( - array('id' => 1, 'rev' => '1-1','name' => 'One', 'content' => 'Lorem ipsum one'), - array('id' => 2, 'rev' => '1-1','name' => 'Two', 'content' => 'Lorem ipsum two'), - array('id' => 3, 'rev' => '1-1', 'name' => 'Three', 'content' => 'Lorem ipsum three') + array( + 'id' => 1, 'rev' => '1-1','name' => 'One', 'content' => 'Lorem ipsum one' + ), + array( + 'id' => 2, 'rev' => '1-1','name' => 'Two', 'content' => 'Lorem ipsum two' + ), + array( + 'id' => 3, 'rev' => '1-1', 'name' => 'Three', + 'content' => 'Lorem ipsum three' + ) ))); break; } diff --git a/libraries/lithium/util/Collection.php b/libraries/lithium/util/Collection.php index cbafb91..320566d 100644 --- a/libraries/lithium/util/Collection.php +++ b/libraries/lithium/util/Collection.php @@ -9,7 +9,7 @@ namespace lithium\util; /** - * The parent class for all collection objects. Contains methods for collection iteration, + * The parent class for all collection objects. Contains methods for collection iteration, * conversion, and filtering. Implements `ArrayAccess`, `Iterator`, and `Countable`. * * Collection objects can act very much like arrays. This is especially evident in creating new @@ -22,7 +22,7 @@ namespace lithium\util; * * $coll = new Collection(array('data' => array('foo'))); * // $coll[0] --> 'foo' - * + * * $array = $coll->to('array'); * }}} * @@ -299,12 +299,12 @@ class Collection extends \lithium\core\Object implements \ArrayAccess, \Iterator * Returns the first non-empty value in the collection after a filter is applied, or rewinds the * collection and returns the first value. * + * @see lithium\util\Collection::rewind() * @param callback $filter A closure through which collection values will be * passed. If the return value of this function is non-empty, * it will be returned as the result of the method call. If `null`, the * collection is rewound (see `rewind()`) and the first item is returned. * @return mixed Returns the first non-empty collection value returned from `$filter`. - * @see lithium\util\Collection::rewind() */ public function first($filter = null) { if (!$filter) { diff --git a/libraries/lithium/util/Inflector.php b/libraries/lithium/util/Inflector.php index 335d2c8..e475e07 100644 --- a/libraries/lithium/util/Inflector.php +++ b/libraries/lithium/util/Inflector.php @@ -26,9 +26,16 @@ class Inflector { * @var array */ protected static $_transliteration = array( - '/à|á|å|â/' => 'a', '/è|é|ê|ẽ|ë/' => 'e', '/ì|í|î/' => 'i', '/ò|ó|ô|ø/' => 'o', - '/ù|ú|ů|û/' => 'u', '/ç/' => 'c', '/ñ/' => 'n', '/ä|æ/' => 'ae', '/ö/' => 'oe', - '/ü/' => 'ue', '/Ä/' => 'Ae', '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/ß/' => 'ss' + '/à|á|å|â/' => 'a', + '/è|é|ê|ẽ|ë/' => 'e', + '/ì|í|î/' => 'i', + '/ò|ó|ô|ø/' => 'o', + '/ù|ú|ů|û/' => 'u', + '/ç/' => 'c', '/ñ/' => 'n', + '/ä|æ/' => 'ae', '/ö/' => 'oe', + '/ü/' => 'ue', '/Ä/' => 'Ae', + '/Ü/' => 'Ue', '/Ö/' => 'Oe', + '/ß/' => 'ss' ); /** @@ -334,9 +341,13 @@ class Inflector { static::$_plural['regexUninflected'] = static::$_singular['regexUninflected'] = null; static::$_plural['regexIrregular'] = static::$_singular['regexIrregular'] = null; static::$_transliteration = array( - '/à|á|å|â/' => 'a', '/è|é|ê|ẽ|ë/' => 'e', '/ì|í|î/' => 'i', '/ò|ó|ô|ø/' => 'o', - '/ù|ú|ů|û/' => 'u', '/ç/' => 'c', '/ñ/' => 'n', '/ä|æ/' => 'ae', '/ö/' => 'oe', - '/ü/' => 'ue', '/Ä/' => 'Ae', '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/ß/' => 'ss' + '/à|á|å|â/' => 'a', '/è|é|ê|ẽ|ë/' => 'e', + '/ì|í|î/' => 'i', '/ò|ó|ô|ø/' => 'o', + '/ù|ú|ů|û/' => 'u', '/ç/' => 'c', + '/ñ/' => 'n', '/ä|æ/' => 'ae', '/ö/' => 'oe', + '/ü/' => 'ue', '/Ä/' => 'Ae', + '/Ü/' => 'Ue', '/Ö/' => 'Oe', + '/ß/' => 'ss' ); } diff --git a/libraries/lithium/util/Set.php b/libraries/lithium/util/Set.php index 179ace5..6989a29 100644 --- a/libraries/lithium/util/Set.php +++ b/libraries/lithium/util/Set.php @@ -12,7 +12,7 @@ namespace lithium\util; /** * Used for complex manipulation, comparison, and access of array data. Some methods allow for * XPath-like data access, as follows: - * + * * - `'/User/id'`: Similar to the classic {n}.User.id. * - `'/User[2]/name'`: Selects the name of the second User. * - `'/User[id>2]'`: Selects all Users with an id > 2. @@ -351,7 +351,9 @@ class Set { 'item' => $item, ); } - } elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) { + } elseif ( + ($key === $token || (ctype_digit($token) && $key == $token) || $token === '.') + ) { $context['trace'][] = $key; $matches[] = array( 'trace' => $context['trace'], @@ -614,6 +616,8 @@ class Set { * with an unlimited amount of arguments and typecasts non-array parameters * into arrays. * + * @param array $arr1 The base array. + * @param array $arr2 The array to be merged on top of the base array. * @return array Merged array of all passed params. */ public static function merge($arr1, $arr2 = null) { diff --git a/libraries/lithium/util/String.php b/libraries/lithium/util/String.php index 6e115cc..915a235 100644 --- a/libraries/lithium/util/String.php +++ b/libraries/lithium/util/String.php @@ -98,8 +98,8 @@ class String { * @param string $options Available options are: * - `'after'`: The character or string after the name of the variable place-holder * (defaults to `null`). - * - `'before'`: The character or string in front of the name of the variable place-holder - * (defaults to `':'`). + * - `'before'`: The character or string in front of the name of the variable + * place-holder (defaults to `':'`). * - `'clean'`: A boolean or array with instructions for `String::clean()`. * - `'escape'`: The character or string used to escape the before character or string * (defaults to `'\'`). diff --git a/libraries/lithium/util/collection/Filters.php b/libraries/lithium/util/collection/Filters.php index 7265d7d..1989047 100644 --- a/libraries/lithium/util/collection/Filters.php +++ b/libraries/lithium/util/collection/Filters.php @@ -185,14 +185,13 @@ class Filters extends \lithium\util\Collection { /** * Provides short-hand convenience syntax for filter chaining. * + * @see lithium\core\Object::applyFilter() + * @see lithium\core\Object::_filter() * @param object $self The object instance that owns the filtered method. * @param array $params An associative array containing the parameters passed to the filtered * method. * @param array $chain The Filters object instance containing this chain of filters. * @return mixed Returns the return value of the next filter in the chain. - * @see lithium\core\Object::applyFilter() - * @see lithium\core\Object::_filter() - * @todo Implement checks allowing params to be null, to traverse filter chain */ public function next($self, $params, $chain) { if (empty($self) || empty($chain)) {