Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo committed Oct 12, 2016
1 parent dac3b87 commit 4a271b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
30 changes: 16 additions & 14 deletions datastore/api/src/functions/concepts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

namespace Google\Cloud\Samples\Datastore;

// [START datastore_use ]
use Generator;
use Google;
// [START datastore_use]
use Google\Cloud\Datastore\DatastoreClient;
// [END datastore_use ]
// [END datastore_use]
use Google\Cloud\Datastore\Key;
use Google\Cloud\Datastore\Query\Query;

Expand All @@ -40,7 +42,7 @@ function initialize_client()
* Create a Datastore entity.
*
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
* @return Google\Cloud\Datastore\Entity
*/
function basic_entity(DatastoreClient $datastore)
{
Expand All @@ -59,7 +61,7 @@ function basic_entity(DatastoreClient $datastore)
* Create a Datastore entity and upsert it.
*
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
* @return Google\Cloud\Datastore\Entity
*/
function upsert(DatastoreClient $datastore)
{
Expand All @@ -82,7 +84,7 @@ function upsert(DatastoreClient $datastore)
* an entity with the same key.
*
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity
* @return Google\Cloud\Datastore\Entity
*/
function insert(DatastoreClient $datastore)
{
Expand All @@ -102,7 +104,7 @@ function insert(DatastoreClient $datastore)
* Look up a Datastore entity with the given key.
*
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity|null
* @return Google\Cloud\Datastore\Entity|null
*/
function lookup(DatastoreClient $datastore)
{
Expand All @@ -117,7 +119,7 @@ function lookup(DatastoreClient $datastore)
* Update a Datastore entity in a transaction.
*
* @param DatastoreClient $datastore
* @return \Google\Cloud\Datastore\Entity|null
* @return Google\Cloud\Datastore\Entity|null
*/
function update(DatastoreClient $datastore)
{
Expand Down Expand Up @@ -149,7 +151,7 @@ function delete(DatastoreClient $datastore, Key $taskKey)
* Upsert multiple Datastore entities.
*
* @param DatastoreClient $datastore
* @param array <\Google\Cloud\Datastore\Entity> $tasks
* @param array <Google\Cloud\Datastore\Entity> $tasks
*/
function batch_upsert(DatastoreClient $datastore, array $tasks)
{
Expand All @@ -163,7 +165,7 @@ function batch_upsert(DatastoreClient $datastore, array $tasks)
*
* @param DatastoreClient $datastore
* @param array <Key> $keys
* @return array <\Google\Cloud\Datastore\Entity>
* @return array <Google\Cloud\Datastore\Entity>
*/
function batch_lookup(DatastoreClient $datastore, array $keys)
{
Expand Down Expand Up @@ -255,7 +257,7 @@ function key_with_multilevel_parent(DatastoreClient $datastore)
*
* @param DatastoreClient $datastore
* @param Key $key
* @return \Google\Cloud\Datastore\Entity
* @return Google\Cloud\Datastore\Entity
*/
function properties(DatastoreClient $datastore, Key $key)
{
Expand All @@ -281,7 +283,7 @@ function properties(DatastoreClient $datastore, Key $key)
*
* @param DatastoreClient $datastore
* @param Key $key
* @return \Google\Cloud\Datastore\Entity
* @return Google\Cloud\Datastore\Entity
*/
function array_value(DatastoreClient $datastore, Key $key)
{
Expand Down Expand Up @@ -319,7 +321,7 @@ function basic_query(DatastoreClient $datastore)
* Run a given query.
*
* @param DatastoreClient $datastore
* @return \Generator <\Google\Cloud\Datastore\Entity>
* @return Generator <Google\Cloud\Datastore\Entity>
*/
function run_query(DatastoreClient $datastore, Query $query)
{
Expand Down Expand Up @@ -509,7 +511,7 @@ function run_projection_query(DatastoreClient $datastore, Query $query)
$priorities = array();
$percentCompletes = array();
$result = $datastore->runQuery($query);
/* @var \Google\Cloud\Datastore\Entity $task */
/* @var Google\Cloud\Datastore\Entity $task */
foreach ($result as $task) {
$priorities[] = $task['priority'];
$percentCompletes[] = $task['percent_complete'];
Expand Down Expand Up @@ -605,7 +607,7 @@ function cursor_paging(DatastoreClient $datastore, $pageSize, $pageCursor = '')
$result = $datastore->runQuery($query);
$nextPageCursor = '';
/* ignoreOnTheDocs */ $entities = [];
/* @var \Google\Cloud\Datastore\Entity $entity */
/* @var Google\Cloud\Datastore\Entity $entity */
foreach ($result as $entity) {
$nextPageCursor = $entity->cursor();
/* ignoreOnTheDocs */ $entities[] = $entity;
Expand Down
19 changes: 10 additions & 9 deletions datastore/api/test/ConceptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Google\Cloud\Samples\Datastore;

use Google;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Datastore\Entity;
use Google\Cloud\Datastore\Query\Query;
Expand Down Expand Up @@ -621,7 +622,7 @@ public function testInequalityRange()
$query = inequality_range(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand All @@ -633,14 +634,14 @@ public function testInequalityRange()
}

/**
* @expectedException \Google\Cloud\Exception\BadRequestException
* @expectedException Google\Cloud\Exception\BadRequestException
*/
public function testInequalityInvalid()
{
$query = inequality_invalid(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand All @@ -656,7 +657,7 @@ public function testEqualAndInequalityRange()
$query = equal_and_inequality_range(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand All @@ -672,7 +673,7 @@ public function testInequalitySort()
$query = inequality_sort(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand All @@ -684,14 +685,14 @@ public function testInequalitySort()
}

/**
* @expectedException \Google\Cloud\Exception\BadRequestException
* @expectedException Google\Cloud\Exception\BadRequestException
*/
public function testInequalitySortInvalidNotSame()
{
$query = inequality_sort_invalid_not_same(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand All @@ -703,14 +704,14 @@ public function testInequalitySortInvalidNotSame()
}

/**
* @expectedException \Google\Cloud\Exception\BadRequestException
* @expectedException Google\Cloud\Exception\BadRequestException
*/
public function testInequalitySortInvalidNotFirst()
{
$query = inequality_sort_invalid_not_first(self::$datastore);
$result = self::$datastore->runQuery($query);
$this->assertInstanceOf(\Generator::class, $result);
/* @var \Google\Cloud\Datastore\Entity $e */
/* @var Google\Cloud\Datastore\Entity $e */
foreach ($result as $e) {
$this->fail(
sprintf(
Expand Down

0 comments on commit 4a271b2

Please sign in to comment.