Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing coding standards violations. Closes ticket #143.

  • Loading branch information...
commit 8de98e982a08b0ae5437cafcd2e2ada504ec968f 1 parent eb6d8d7
@nateabele nateabele authored
Showing with 234 additions and 167 deletions.
  1. +3 −2 libraries/lithium/data/Entity.php
  2. +3 −3 libraries/lithium/data/Source.php
  3. +3 −2 libraries/lithium/data/collection/DocumentSet.php
  4. +3 −2 libraries/lithium/data/entity/Document.php
  5. +6 −4 libraries/lithium/data/model/Query.php
  6. +3 −3 libraries/lithium/data/source/Database.php
  7. +1 −1  libraries/lithium/data/source/MongoDb.php
  8. +4 −5 libraries/lithium/data/source/database/adapter/MySql.php
  9. +13 −12 libraries/lithium/data/source/database/adapter/Sqlite3.php
  10. +8 −2 libraries/lithium/net/http/Router.php
  11. +3 −1 libraries/lithium/storage/session/adapter/Cookie.php
  12. +1 −1  libraries/lithium/storage/session/adapter/Memory.php
  13. +1 −1  libraries/lithium/storage/session/adapter/Php.php
  14. +6 −7 libraries/lithium/test/filter/Coverage.php
  15. +3 −1 libraries/lithium/tests/cases/data/collection/RecordSetTest.php
  16. +14 −9 libraries/lithium/tests/cases/data/source/DatabaseTest.php
  17. +1 −1  libraries/lithium/tests/cases/template/helper/FormTest.php
  18. +12 −4 libraries/lithium/tests/cases/util/CollectionTest.php
  19. +100 −81 libraries/lithium/tests/cases/util/SetTest.php
  20. +2 −2 libraries/lithium/tests/cases/util/ValidatorTest.php
  21. +1 −1  libraries/lithium/tests/mocks/data/MockPostObject.php
  22. +13 −6 libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php
  23. +3 −3 libraries/lithium/util/Collection.php
  24. +17 −6 libraries/lithium/util/Inflector.php
  25. +6 −2 libraries/lithium/util/Set.php
  26. +2 −2 libraries/lithium/util/String.php
  27. +2 −3 libraries/lithium/util/collection/Filters.php
View
5 libraries/lithium/data/Entity.php
@@ -366,8 +366,9 @@ public function to($format, array $options = array()) {
* 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()) {
View
6 libraries/lithium/data/Source.php
@@ -207,14 +207,14 @@ public function methods() {
/**
* 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();
View
5 libraries/lithium/data/collection/DocumentSet.php
@@ -229,8 +229,9 @@ protected function _populate($data = null, $key = null) {
* 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()) {
View
5 libraries/lithium/data/entity/Document.php
@@ -238,8 +238,9 @@ public function update($id = null, array $data = array()) {
* 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()) {
View
10 libraries/lithium/data/model/Query.php
@@ -131,10 +131,11 @@ public function type() {
/**
* 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 @@ public function join($joins = null) {
}
/**
- * 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());
View
6 libraries/lithium/data/source/Database.php
@@ -466,12 +466,12 @@ public function schema($query, $resource = null, $context = null) {
*
* - 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()) {
View
2  libraries/lithium/data/source/MongoDb.php
@@ -332,7 +332,7 @@ public function create($query, array $options = array()) {
$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;
}
View
9 libraries/lithium/data/source/database/adapter/MySql.php
@@ -229,7 +229,7 @@ public function encoding($encoding = null) {
*
* @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 @@ public function error() {
* @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);
View
25 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 @@ public function describe($entity, array $meta = array()) {
/**
* 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 @@ public function encoding($encoding = null) {
*
* @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) {
View
10 libraries/lithium/net/http/Router.php
@@ -176,8 +176,14 @@ public static function parse($request) {
* 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.
*/
View
4 libraries/lithium/storage/session/adapter/Cookie.php
@@ -121,7 +121,9 @@ public function read($key = null, array $options = array()) {
}
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];
+ }
};
}
View
2  libraries/lithium/storage/session/adapter/Memory.php
@@ -136,4 +136,4 @@ public static function enabled() {
}
}
-?>
+?>
View
2  libraries/lithium/storage/session/adapter/Php.php
@@ -236,4 +236,4 @@ public static function overwrite(&$old, $new) {
}
}
-?>
+?>
View
13 libraries/lithium/test/filter/Coverage.php
@@ -58,16 +58,17 @@ public static function apply($report, $tests, array $options = array()) {
* 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 @@ protected static function collectLines($result) {
);
}
}
-
$result[$class]['output'][$file] = $out;
}
-
return $result;
}
View
4 libraries/lithium/tests/cases/data/collection/RecordSetTest.php
@@ -201,7 +201,9 @@ public function testOffsetSet() {
$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);
View
23 libraries/lithium/tests/cases/data/source/DatabaseTest.php
@@ -165,7 +165,8 @@ public function testSimpleQueryRender() {
'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 @@ public function testSimpleQueryRender() {
'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 @@ public function testNestedQueryConditions() {
$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 @@ public function testQueryOperators() {
'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 @@ public function testQueryOperators() {
'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 @@ public function testQueryOperators() {
'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 @@ public function testQueryOperators() {
'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));
}
View
2  libraries/lithium/tests/cases/template/helper/FormTest.php
@@ -616,4 +616,4 @@ public function testFieldTemplateOverride() {
}
}
-?>
+?>
View
16 libraries/lithium/tests/cases/util/CollectionTest.php
@@ -46,7 +46,9 @@ public function testObjectMethodDispatch() {
$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 @@ public function testObjectMethodDispatch() {
}
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);
View
181 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 @@ public function testExtractFromTree() {
$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 @@ public function testMerge() {
$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 @@ public function testMerge() {
$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 @@ public function testSort() {
$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 @@ 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')
+ )),
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 @@ public function testCombine() {
);
$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 @@ public function testToArrayNullAndFalse() {
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 @@ public function testToArrayFromObject() {
'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 @@ public function testToArrayFromObject() {
)
));
- $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 @@ public function testToArrayFromObject() {
$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 @@ public function testToArrayFromObject() {
)
));
- $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 @@ public function testToArrayFromObject() {
$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 @@ public function testToArrayFromObject() {
$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 @@ public function testToArrayFromObject() {
);
$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 @@ public function testToArrayFromObject() {
}
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 @@ public function testAssociativeArrayToObject() {
),
);
$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 @@ public function testAssociativeArrayToObject() {
$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 @@ public function testNestedArrayToObject() {
);
$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 @@ public function testNestedArrayToObject() {
$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 @@ public function testNestedArrayToObject() {
$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 @@ public function testNestedArrayToObject() {
$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 @@ public function testDeepNestedArrayToObject() {
$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 @@ public function testDeepNestedArrayToObject() {
$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 @@ public function testDeepNestedArrayToObject() {
$piece2->PiecesUser->_name_ = 'PiecesUser';
$piece2->_name_ = 'Piece';
-
$expected->Piece = array($piece, $piece2);
$this->assertEqual($expected, $result);
@@ -1802,19 +1821,19 @@ public function testToObjectWithPredifinedName() {
$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 @@ public function testToObjectWithPredifinedName() {
$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 @@ public function testComplexArrayToObjectBackToArray() {
);
$mapped = Set::to('object', $data);
- $expected = new \stdClass();
+ $expected = new stdClass();
$expected->_name_ = 'IndexedPage';
$expected->id = 2;
$expected->url = 'http://blah.com/';
View
4 libraries/lithium/tests/cases/util/ValidatorTest.php
@@ -329,12 +329,12 @@ public function testEmailValidation() {
*/
$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.'
);
View
2  libraries/lithium/tests/mocks/data/MockPostObject.php
@@ -21,4 +21,4 @@ public function __construct($values) {
}
}
-?>
+?>
View
19 libraries/lithium/tests/mocks/data/model/MockDocumentMultipleKey.php
@@ -41,16 +41,23 @@ public function ret($record, $param1 = null, $param2 = null) {
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;
}
View
6 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 @@
*
* $coll = new Collection(array('data' => array('foo')));
* // $coll[0] --> 'foo'
- *
+ *
* $array = $coll->to('array');
* }}}
*
@@ -299,12 +299,12 @@ public function find($filter, array $options = array()) {
* 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) {
View
23 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 @@ public static function reset() {
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'
);
}
View
8 libraries/lithium/util/Set.php
@@ -12,7 +12,7 @@
/**
* 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 @@ public static function extract($data, $path = null, array $options = array()) {
'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 @@ public static function matches($conditions, $data = array(), $i = null, $length
* 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) {
View
4 libraries/lithium/util/String.php
@@ -98,8 +98,8 @@ public static function hash($string, $type = 'sha1', $salt = null) {
* @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 `'\'`).
View
5 libraries/lithium/util/collection/Filters.php
@@ -185,14 +185,13 @@ public static function run($class, $params, array $options = array()) {
/**
* 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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.