Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion appengine/flexible/datastore/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Datastore\Query\Query;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use RKA\Middleware\IpAddress;
Expand Down Expand Up @@ -62,7 +63,7 @@
// Query recent visits.
$query = $datastore->query()
->kind('visit')
->order('timestamp', 'DESCENDING')
->order('timestamp', Query::ORDER_DESCENDING)
->limit(10);
$results = $datastore->runQuery($query);
$visits = [];
Expand Down
2 changes: 1 addition & 1 deletion appengine/flexible/datastore/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"google/cloud-datastore": "^1.0",
"google/cloud-datastore": "^2.0",
"slim/slim": "^4.0",
"slim/psr7": "^1.3",
"akrabat/ip-address-middleware": "^2.0"
Expand Down
4 changes: 2 additions & 2 deletions appengine/flexible/logging/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"google/cloud-logging": "^1.21.0",
"google/cloud-error-reporting": "^0.18.0",
"google/cloud-logging": "^2.0",
"google/cloud-error-reporting": "^0.28.0",
"slim/slim": "^4.0",
"slim/psr7": "^1.3",
"slim/twig-view": "^3.2"
Expand Down
2 changes: 1 addition & 1 deletion appengine/flexible/storage/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"require": {
"slim/slim": "^4.0",
"slim/psr7": "^1.3",
"google/cloud-storage": "^1.0",
"google/cloud-storage": "^2.0",
"php-di/slim-bridge": "^3.1"
}
}
2 changes: 1 addition & 1 deletion appengine/flexible/symfony/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"symfony/console": " ~2.6.0",
"symfony/process": "^3.0",
"symfony/yaml": "^3.0",
"google/cloud-logging": "^1.9",
"google/cloud-logging": "^2.0",
"paragonie/random_compat": " ^9.0"
}
}
2 changes: 1 addition & 1 deletion appengine/flexible/tasks/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"slim/slim": "^4.0",
"slim/psr7": "^1.3",
"google/apiclient": "^2.1",
"google/cloud-logging": "^1.5"
"google/cloud-logging": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/auth/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"google/apiclient": "^2.1",
"google/cloud-storage": "^1.3"
"google/cloud-storage": "^2.0"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/errorreporting/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"google/cloud-error-reporting": "^0.25.0"
"google/cloud-error-reporting": "^0.28.0"
},
"autoload": {
"files": [
Expand Down
24 changes: 14 additions & 10 deletions appengine/standard/errorreporting/test/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

use Google\Cloud\TestUtils\AppEngineDeploymentTrait;
use Google\Cloud\TestUtils\EventuallyConsistentTestTrait;
use Google\Cloud\ErrorReporting\V1beta1\ErrorStatsServiceClient;
use Google\Cloud\ErrorReporting\V1beta1\Client\ErrorStatsServiceClient;
use Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest;
use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsRequest;
use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange;
use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange_Period;
use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange\Period;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -101,7 +103,7 @@ private function verifyReportedError($message, $retryCount = 5)
$projectName = $errorStats->projectName(self::$projectId);

$timeRange = (new QueryTimeRange())
->setPeriod(QueryTimeRange_Period::PERIOD_1_HOUR);
->setPeriod(Period::PERIOD_1_HOUR);

// Iterate through all elements
$this->runEventuallyConsistentTest(function () use (
Expand All @@ -111,14 +113,16 @@ private function verifyReportedError($message, $retryCount = 5)
$message
) {
$messages = [];
$response = $errorStats->listGroupStats(
$projectName,
['timeRange' => $timeRange]
);
$request = (new ListGroupStatsRequest())
->setProjectName($projectName)
->setTimeRange($timeRange);
$response = $errorStats->listGroupStats($request);
foreach ($response->iterateAllElements() as $groupStat) {
$response = $errorStats->listEvents($projectName, $groupStat->getGroup()->getGroupId(), [
'timeRange' => $timeRange,
]);
$eventsRequest = (new ListEventsRequest())
->setProjectName($projectName)
->setGroupId($groupStat->getGroup()->getGroupId())
->setTimeRange($timeRange);
$response = $errorStats->listEvents($eventsRequest);
foreach ($response->iterateAllElements() as $event) {
$messages[] = $event->getMessage();
}
Comment on lines +116 to 128

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Reusing the $response variable name for both the outer listGroupStats response and the inner listEvents response is confusing and can lead to readability or maintenance issues. It is cleaner and more idiomatic to use distinct, descriptive variable names like $groupStatsResponse and $eventsResponse.

            $request = (new ListGroupStatsRequest())
                ->setProjectName($projectName)
                ->setTimeRange($timeRange);
            $groupStatsResponse = $errorStats->listGroupStats($request);
            foreach ($groupStatsResponse->iterateAllElements() as $groupStat) {
                $eventsRequest = (new ListEventsRequest())
                    ->setProjectName($projectName)
                    ->setGroupId($groupStat->getGroup()->getGroupId())
                    ->setTimeRange($timeRange);
                $eventsResponse = $errorStats->listEvents($eventsRequest);
                foreach ($eventsResponse->iterateAllElements() as $event) {
                    $messages[] = $event->getMessage();
                }

Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/getting-started/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"google/cloud-storage": "^1.6",
"google/cloud-storage": "^2.0",
"slim/slim": "^4.0",
"slim/psr7": "^1.0",
"slim/twig-view": "^3.0",
Expand Down
28 changes: 16 additions & 12 deletions appengine/standard/grpc/speech.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Speech\V1\SpeechClient;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\StreamingRecognitionConfig;
use Google\Cloud\Speech\V1\StreamingRecognizeRequest;
use Google\Cloud\Speech\V1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V2\Client\SpeechClient;
use Google\Cloud\Speech\V2\ExplicitDecodingConfig;
use Google\Cloud\Speech\V2\ExplicitDecodingConfig\AudioEncoding;
use Google\Cloud\Speech\V2\RecognitionConfig;
use Google\Cloud\Speech\V2\StreamingRecognitionConfig;
use Google\Cloud\Speech\V2\StreamingRecognizeRequest;

$audioFile = __DIR__ . '/audio32KHz.raw';
$languageCode = 'en-US';
$sampleRateHertz = '32000';
$sampleRateHertz = 32000;
$encoding = 'LINEAR16';

$speechClient = new SpeechClient();
$config = new RecognitionConfig();
$config->setLanguageCode($languageCode);
$config->setSampleRateHertz($sampleRateHertz);
// encoding must be an enum, convert from string
$encodingEnum = constant(RecognitionConfig_AudioEncoding::class . '::' . $encoding);
$config->setEncoding($encodingEnum);
$encodingEnum = constant(AudioEncoding::class . '::' . $encoding);
$decodingConfig = (new ExplicitDecodingConfig())
->setSampleRateHertz($sampleRateHertz)
->setEncoding($encodingEnum);

$config = (new RecognitionConfig())
->setLanguageCodes([$languageCode])
->setExplicitDecodingConfig($decodingConfig);

$strmConfig = new StreamingRecognitionConfig();
$strmConfig->setConfig($config);
Expand All @@ -50,7 +54,7 @@
$f = fopen($audioFile, 'rb');
$fsize = filesize($audioFile);
$bytes = fread($f, $fsize);
$strmReq->setAudioContent($bytes);
$strmReq->setAudio($bytes);
$strm->write($strmReq);

foreach ($strm->closeWriteAndReadAll() as $response) {
Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/laravel-framework/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require-dev": {
"monolog\/monolog": "^2.0",
"google/cloud-logging": "^1.14"
"google/cloud-logging": "^2.0"
}
}
2 changes: 1 addition & 1 deletion appengine/standard/logging/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/cloud-logging": "^1.12"
"google/cloud-logging": "^2.0"
}
}
2 changes: 1 addition & 1 deletion appengine/standard/symfony-framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"require-dev": {
"monolog/monolog": "^2.0",
"nikic/php-parser": "^5.0",
"google/cloud-logging": "^1.14"
"google/cloud-logging": "^2.0"
}
}
2 changes: 1 addition & 1 deletion appengine/standard/tasks/apps/handler/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/cloud-logging": "^1.14"
"google/cloud-logging": "^2.0"
}
}
8 changes: 6 additions & 2 deletions appengine/standard/tasks/snippets/src/create_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

# [START cloud_tasks_appengine_create_task]
use Google\Cloud\Tasks\V2\AppEngineHttpRequest;
use Google\Cloud\Tasks\V2\CloudTasksClient;
use Google\Cloud\Tasks\V2\Client\CloudTasksClient;
use Google\Cloud\Tasks\V2\CreateTaskRequest;
use Google\Cloud\Tasks\V2\HttpMethod;
use Google\Cloud\Tasks\V2\Task;

Expand Down Expand Up @@ -61,7 +62,10 @@
$task->setAppEngineHttpRequest($httpRequest);

// Send request and print the task name.
$response = $client->createTask($queueName, $task);
$request = (new CreateTaskRequest())
->setParent($queueName)
->setTask($task);
$response = $client->createTask($request);
printf('Created task %s' . PHP_EOL, $response->getName());

# [END cloud_tasks_appengine_create_task]
2 changes: 1 addition & 1 deletion error_reporting/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"google/cloud-error-reporting": "^0.25.0"
"google/cloud-error-reporting": "^0.28.0"
}
}
23 changes: 14 additions & 9 deletions error_reporting/test/VerifyReportedErrorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

use Google\ApiCore\ApiException;
use Google\Cloud\Core\ExponentialBackoff;
use Google\Cloud\ErrorReporting\V1beta1\ErrorStatsServiceClient;
use Google\Cloud\ErrorReporting\V1beta1\Client\ErrorStatsServiceClient;
use Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest;
use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsRequest;
use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange;
use Google\Cloud\ErrorReporting\V1beta1\QueryTimeRange\Period;
use Google\Cloud\TestUtils\TestTrait;
Expand Down Expand Up @@ -56,15 +58,18 @@ private function verifyReportedError($projectId, $message)
// Iterate through all elements
$testFunc = function () use ($errorStats, $projectName, $timeRange, $message) {
$messages = [];
$response = $errorStats->listGroupStats($projectName, [
'timeRange' => $timeRange,
'pageSize' => 100,
]);
$request = (new ListGroupStatsRequest())
->setProjectName($projectName)
->setTimeRange($timeRange)
->setPageSize(100);
$response = $errorStats->listGroupStats($request);
foreach ($response->iterateAllElements() as $groupStat) {
$response = $errorStats->listEvents($projectName, $groupStat->getGroup()->getGroupId(), [
'timeRange' => $timeRange,
'pageSize' => 100,
]);
$eventsRequest = (new ListEventsRequest())
->setProjectName($projectName)
->setGroupId($groupStat->getGroup()->getGroupId())
->setTimeRange($timeRange)
->setPageSize(100);
$response = $errorStats->listEvents($eventsRequest);
foreach ($response->iterateAllElements() as $event) {
$messages[] = $event->getMessage();
}
Comment on lines +61 to 75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Reusing the $response variable name for both the outer listGroupStats response and the inner listEvents response is confusing and can lead to readability or maintenance issues. It is cleaner and more idiomatic to use distinct, descriptive variable names like $groupStatsResponse and $eventsResponse.

            $request = (new ListGroupStatsRequest())
                ->setProjectName($projectName)
                ->setTimeRange($timeRange)
                ->setPageSize(100);
            $groupStatsResponse = $errorStats->listGroupStats($request);
            foreach ($groupStatsResponse->iterateAllElements() as $groupStat) {
                $eventsRequest = (new ListEventsRequest())
                    ->setProjectName($projectName)
                    ->setGroupId($groupStat->getGroup()->getGroupId())
                    ->setTimeRange($timeRange)
                    ->setPageSize(100);
                $eventsResponse = $errorStats->listEvents($eventsRequest);
                foreach ($eventsResponse->iterateAllElements() as $event) {
                    $messages[] = $event->getMessage();
                }

Expand Down
Loading