Permalink
Browse files

Syntax fixes

  • Loading branch information...
1 parent b45d266 commit b60fa6765ddd6cc4b81b143a3b1421d989013aeb @mackstar mackstar committed with nateabele Jan 15, 2012
View
@@ -144,7 +144,7 @@ public function assignTo($parent, array $config = array()) {
public function model() {
return $this->_model;
}
-
+
/**
* Returns the object's parent `Document` object.
*
@@ -153,7 +153,7 @@ public function model() {
public function parent() {
return $this->_parent;
}
-
+
public function schema($field = null) {
$schema = array();
@@ -315,12 +315,12 @@ public function offsetSet($offset, $data) {
}
return $this->_data[] = $data;
}
-
+
/**
- * Return's the pointer or resource that is used to load entities from the backend
+ * Return's the pointer or resource that is used to load entities from the backend
* data source that originated this collection. This is useful in many cases for
* additional methods related to debugging queries.
- *
+ *
* @return object The pointer or resource from the data source
*/
public function result() {
View
@@ -11,7 +11,6 @@
use BadMethodCallException;
use UnexpectedValueException;
use lithium\data\Collection;
-use lithium\util\Set;
/**
* `Entity` is a smart data object which represents data such as a row or document in a
View
@@ -1131,4 +1131,4 @@ protected static function &_connection() {
}
}
-?>
+?>
@@ -226,7 +226,7 @@ public function to($format, array $options = array()) {
switch ($format) {
case 'array':
$result = array_map(function($r) { return $r->to('array'); }, $this->_data);
-
+
if (!(is_scalar(current($this->_index)) && $options['indexed'])) {
break;
}
@@ -152,7 +152,7 @@ public function export() {
*
* @param mixed $id
* @param array $data
- * @param array Options when calling this method:
+ * @param array $options Options when calling this method:
* - `'recursive'` _boolean_: If `true` attempts to sync nested objects as well.
* Otherwise, only syncs the current object. Defaults to `true`.
* @return void
@@ -397,8 +397,7 @@ public function join($name = null, $join = null) {
/**
* Convert the query's properties to the data sources' syntax and return it as an array.
*
- * @param \lithium\data\Source $dataSource Instance of the data source to use
- * for conversion.
+ * @param object $dataSource Instance of `lithium\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.
*/
@@ -937,6 +937,7 @@ function($v) use ($key, $op) { return "{$key} {$op} {$v}"; }, $values
* Returns a fully-qualified table name (i.e. with prefix), quoted.
*
* @param string $entity
+ * @param array $options
* @return string
*/
protected function _entityName($entity, array $options = array()) {
@@ -549,8 +549,9 @@ public function delete($query, array $options = array()) {
$defaults = array('justOne' => false, 'safe' => false, 'fsync' => false);
$options = array_intersect_key($options + $defaults, $defaults);
$_config = $this->_config;
+ $params = compact('query', 'options');
- return $this->_filter(__METHOD__, compact('query', 'options'), function($self, $params) use ($_config) {
+ return $this->_filter(__METHOD__, $params, function($self, $params) use ($_config) {
$query = $params['query'];
$options = $params['options'];
$args = $query->export($self, array('keys' => array('source', 'conditions')));
@@ -569,7 +570,7 @@ protected function _deleteFile($conditions, $options = array()) {
$options += $defaults;
$grid = $this->connection->getGridFS();
-
+
return $grid->remove($conditions, $options);
}
@@ -97,7 +97,7 @@ public function current() {
/**
* Returns the current key position on the result.
*
- * @return int The current iterator position.
+ * @return integer The current iterator position.
*/
public function key() {
return $this->_iterator;
@@ -109,7 +109,7 @@ public function key() {
* @return array The previous result (or `null` if there is none).
*/
public function prev() {
- if(!empty($this->_cache)) {
+ if (!empty($this->_cache)) {
if (isset($this->_cache[--$this->_iterator])) {
return $this->_current = $this->_cache[$this->_iterator];
}
View
@@ -432,10 +432,10 @@ public function compile() {
* `"/{:id:\d+}"`, then the value will be `"\d+"`.
* @param string $param The parameter name which the capture group is assigned to, i.e.
* `'controller'`, `'id'` or `'args'`.
- * @param string $prefix The prefix character that separates the parameter from the other
- * elements of the route. Usually `'.'` or `'/'`.
* @param string $token The full token representing a matched element in a route template, i.e.
* `'/{:action}'`, `'/{:path:js|css}'`, or `'.{:type}'`.
+ * @param string $prefix The prefix character that separates the parameter from the other
+ * elements of the route. Usually `'.'` or `'/'`.
* @return string Returns the full route template, with the value of `$token` replaced with a
* generated regex capture group.
*/
@@ -193,7 +193,9 @@ protected static function _genSaltBf($count = null) {
$output .= $base64[$c2 & 0x3f];
} while (1);
- return '$2a$' . chr(ord('0') + $count / static::BF) . chr(ord('0') + $count % static::BF) . '$' . $output;
+ $string = '$2a$' . chr(ord('0') + $count / static::BF);
+ $string .= chr(ord('0') + $count % static::BF) . '$' . $output;
+ return $string;
}
/**
@@ -87,7 +87,7 @@ public function testPathFiltering() {
$all = Libraries::find('lithium', array('recursive' => true));
$result = array_values(preg_grep('/^lithium\\\\tests\\\\cases\\\\/', $all));
$this->assertIdentical($tests, $result);
-
+
if ($this->hasApp) {
$tests = Libraries::find('app', array('recursive' => true, 'path' => '/tests/cases'));
$result = preg_grep('/^app\\\\tests\\\\cases\\\\/', $tests);
@@ -115,7 +115,8 @@ public function testLibraryConfigAccess() {
);
if (!$this->hasApp) {
- $expected['resources'] = str_replace('\\', '/', realpath(realpath(LITHIUM_LIBRARY_PATH) . '/lithium/resources'));
+ $path = realpath(realpath(LITHIUM_LIBRARY_PATH) . '/lithium/resources');
+ $expected['resources'] = str_replace('\\', '/', $path);
$expected['default'] = true;
}
@@ -125,7 +126,7 @@ public function testLibraryConfigAccess() {
$result = Libraries::get();
$this->assertTrue(isset($result['lithium']));
$this->assertEqual($expected, $result['lithium']);
-
+
if ($this->hasApp) {
$this->assertTrue(isset($result['app']));
}
@@ -8,30 +8,29 @@
namespace lithium\tests\cases\data;
-use \stdClass;
use lithium\data\collection\DocumentSet;
use lithium\data\Connections;
/**
* lithium\data\Connections Test.
*/
class CollectionTest extends \lithium\test\Unit {
-
+
/**
* Used model.
*
* @var string
*/
protected $_model = 'lithium\tests\mocks\data\MockPost';
-
+
/**
* Used for storing connections in CollectionTest::setUp,
* restored in Collection::tearDown.
*
* @var array
*/
protected $_backup = array();
-
+
/**
* Setup method run before every test method.
*/
@@ -43,7 +42,7 @@ public function setUp() {
}
Connections::reset();
}
-
+
/**
* Teardown method run after every test method.
*/
@@ -53,7 +52,7 @@ public function tearDown() {
Connections::add($name, $config);
}
}
-
+
/**
* Tests `Collection::stats`.
*/
@@ -63,15 +62,15 @@ public function testGetStats() {
$this->assertEqual('bar', $collection->stats('foo'));
$this->assertEqual(array('foo' => 'bar'), $collection->stats());
}
-
+
/**
* Tests Collection with invalid data.
*/
public function testInvalidData() {
$this->expectException('Error creating new Collection instance; data format invalid.');
$collection = new DocumentSet(array('data' => 'foo'));
}
-
+
/**
* Tests Collection accessors (getters/setters).
*/
@@ -85,7 +84,7 @@ public function testAccessorMethods() {
$this->assertEqual($model, $collection->model());
$this->assertEqual(compact('model'), $collection->meta());
}
-
+
/**
* Tests `Collection::offsetExists`.
*/
@@ -96,7 +95,7 @@ public function testOffsetExists() {
$this->assertEqual($collection->offsetExists(0), true);
$this->assertEqual($collection->offsetExists(1), true);
}
-
+
/**
* Tests `Collection::rewind` and `Collection::current`.
*/
@@ -113,7 +112,7 @@ public function testNextRewindCurrent() {
$this->assertEqual('Lorem Ipsum', $collection->rewind());
$this->assertEqual(42, $collection->next());
}
-
+
/**
* Tests `Collection::each`.
*/
@@ -134,7 +133,7 @@ public function testEach() {
);
$this->assertEqual($collection->to('array'), $expected);
}
-
+
/**
* Tests `Collection::map`.
*/
@@ -156,7 +155,7 @@ public function testMap() {
$this->assertEqual($results->to('array'), $expected);
$this->assertNotEqual($results->to('array'), $collection->to('array'));
}
-
+
/**
* Tests `Collection::data`.
*/
@@ -189,20 +188,20 @@ public function testSort() {
$idsSorted = $collection->map(function ($v) { return $v['id']; })->to('array');
$this->assertEqual($idsSorted, array(1,4,5,3,2));
}
-
+
/**
* Tests `Collection::closed` && `Collection::close`.
*/
public function testClosed() {
$collection = new DocumentSet();
$this->assertTrue($collection->closed());
-
+
$collection = new DocumentSet(array('result' => 'foo'));
$this->assertFalse($collection->closed());
$collection->close();
$this->assertTrue($collection->closed());
}
-
+
/**
* Tests `Collection::assignTo`.
*/
@@ -253,7 +253,6 @@ public function testDescribe() {
);
$this->assertEqual($expected, $result);
}
-
}
?>
@@ -42,8 +42,8 @@ public function setUp() {
$sql = file_get_contents($sqlFile);
$this->db->read($sql, array('return' => 'resource'));
- foreach($this->_mockData as $entry) {
- $sql = "INSERT INTO companies (name) VALUES ('".$entry[1]."')";
+ foreach ($this->_mockData as $entry) {
+ $sql = "INSERT INTO companies (name) VALUES ('" . $entry[1] . "')";
$this->db->read($sql, array('return' => 'resource'));
}
}
@@ -137,13 +137,13 @@ public function testResultForeach() {
));
$rows = array();
- foreach($result as $row) {
+ foreach ($result as $row) {
$rows[] = $row;
}
$expected = array(
- array('Foo Company', NULL),
- array('Bar Company', NULL),
+ array('Foo Company', null),
+ array('Bar Company', null)
);
$this->assertEqual($expected, $rows);
@@ -161,13 +161,14 @@ public function testEmptyResultForeach() {
));
$rows = array();
- foreach($result as $row) {
+ foreach ($result as $row) {
$rows[] = $row;
}
$expected = array();
$this->assertEqual($expected, $rows);
}
-
}
+
+?>
@@ -304,11 +304,11 @@ public function testRouteExporting() {
'template' => '/images/image_{:width}x{:height}.{:format}',
'params' => array('format' => 'png')
));
-
- $pattern = '@^/images/image_(?P<width>[^\\/]+)x(?P<height>[^\\/]+)\\.(?P<format>[^\\/]+)?$@';
+
+ $ptrn = '@^/images/image_(?P<width>[^\\/]+)x(?P<height>[^\\/]+)\\.(?P<format>[^\\/]+)?$@';
$expected = array(
'template' => '/images/image_{:width}x{:height}.{:format}',
- 'pattern' => $pattern,
+ 'pattern' => $ptrn,
'params' => array('format' => 'png', 'action' => 'index'),
'match' => array('action' => 'index'),
'meta' => array(),
Oops, something went wrong.

0 comments on commit b60fa67

Please sign in to comment.