diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 907e2b3a85..c561ba726e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,7 +6,8 @@ on: pull_request: jobs: - styles: + php_cs_fixer: + name: PHP CS Fixer runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -18,7 +19,26 @@ jobs: - name: Run Script run: testing/run_cs_check.sh - staticanalysis: + php_code_sniffer: + name: PHP Code Sniffer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + - name: Install Dependencies + uses: nick-invision/retry@v2 + with: + timeout_minutes: 10 + max_attempts: 3 + command: composer global require squizlabs/php_codesniffer + - name: Run PHPCS Code Style Checker + run: ~/.composer/vendor/bin/phpcs --standard=phpcs-ruleset.xml -p -s + + phpstan_static_analysis: + name: PHPStan Static Analysis runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -40,4 +60,4 @@ jobs: bash testing/run_staticanalysis_check.sh env: FILES_CHANGED: ${{ steps.changedFiles.outputs.all_changed_files }} - PULL_REQUEST_NUMBER: ${{ steps.findPr.outputs.pr }} \ No newline at end of file + PULL_REQUEST_NUMBER: ${{ steps.findPr.outputs.pr }} diff --git a/analyticsdata/src/run_report_with_dimension_and_metric_filters.php b/analyticsdata/src/run_report_with_dimension_and_metric_filters.php index 2c175a4760..fa8c7a00b9 100644 --- a/analyticsdata/src/run_report_with_dimension_and_metric_filters.php +++ b/analyticsdata/src/run_report_with_dimension_and_metric_filters.php @@ -97,7 +97,7 @@ function run_report_with_dimension_and_metric_filters(string $propertyId) 'value' => 'in_app_purchase', ]) ]) - ]), + ]), ], ]), ])); diff --git a/analyticsdata/test/quickstartTest.php b/analyticsdata/test/quickstartTest.php index 705701dca3..810a63ca0d 100644 --- a/analyticsdata/test/quickstartTest.php +++ b/analyticsdata/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\AnalyticsData\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/auth/src/auth_http_explicit.php b/auth/src/auth_http_explicit.php index e3b3667097..3e36831146 100644 --- a/auth/src/auth_http_explicit.php +++ b/auth/src/auth_http_explicit.php @@ -41,7 +41,8 @@ function auth_http_explicit($projectId, $serviceAccountPath) # and Google Auth library's ServiceAccountCredentials class. $serviceAccountCredentials = new ServiceAccountCredentials( 'https://www.googleapis.com/auth/cloud-platform', - $serviceAccountPath); + $serviceAccountPath + ); $middleware = new AuthTokenMiddleware($serviceAccountCredentials); $stack = HandlerStack::create(); $stack->push($middleware); diff --git a/auth/src/auth_http_implicit.php b/auth/src/auth_http_implicit.php index 749f3ab510..61f4530d32 100644 --- a/auth/src/auth_http_implicit.php +++ b/auth/src/auth_http_implicit.php @@ -38,7 +38,8 @@ function auth_http_implicit($projectId) # Get the credentials and project ID from the environment using Google Auth # library's ApplicationDefaultCredentials class. $middleware = ApplicationDefaultCredentials::getMiddleware( - 'https://www.googleapis.com/auth/cloud-platform'); + 'https://www.googleapis.com/auth/cloud-platform' + ); $stack = HandlerStack::create(); $stack->push($middleware); diff --git a/bigquery/api/src/dry_run_query.php b/bigquery/api/src/dry_run_query.php index fe681b2ef5..ee41759c0c 100644 --- a/bigquery/api/src/dry_run_query.php +++ b/bigquery/api/src/dry_run_query.php @@ -30,7 +30,8 @@ * Dry runs the given query * * @param string $projectId The project Id of your Google Cloud Project. - * @param string $query The query to be run. For eg: $query = 'SELECT id, view_count FROM `bigquery-public-data.stackoverflow.posts_questions`' + * @param string $query The query to be run. For eg: + * 'SELECT id, view_count FROM `bigquery-public-data.stackoverflow.posts_questions`' */ function dry_run_query(string $projectId, string $query): void { diff --git a/bigquery/api/src/import_from_storage_json_truncate.php b/bigquery/api/src/import_from_storage_json_truncate.php index 9d1aa825c8..e66813c63b 100644 --- a/bigquery/api/src/import_from_storage_json_truncate.php +++ b/bigquery/api/src/import_from_storage_json_truncate.php @@ -46,7 +46,9 @@ function import_from_storage_json_truncate( // create the import job $gcsUri = 'gs://cloud-samples-data/bigquery/us-states/us-states.json'; - $loadConfig = $table->loadFromStorage($gcsUri)->sourceFormat('NEWLINE_DELIMITED_JSON')->writeDisposition('WRITE_TRUNCATE'); + $loadConfig = $table->loadFromStorage($gcsUri) + ->sourceFormat('NEWLINE_DELIMITED_JSON') + ->writeDisposition('WRITE_TRUNCATE'); $job = $table->runJob($loadConfig); // check if the job is complete diff --git a/bigquery/stackoverflow/test/stackoverflowTest.php b/bigquery/stackoverflow/test/stackoverflowTest.php index 103f0f71da..80be7a4a77 100644 --- a/bigquery/stackoverflow/test/stackoverflowTest.php +++ b/bigquery/stackoverflow/test/stackoverflowTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\BigQuery\StackOverflow\Test; + use PHPUnit\Framework\TestCase; class stackoverflowTest extends TestCase diff --git a/bigquerydatatransfer/test/quickstartTest.php b/bigquerydatatransfer/test/quickstartTest.php index b1cd3058ea..15ede32def 100644 --- a/bigquerydatatransfer/test/quickstartTest.php +++ b/bigquerydatatransfer/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\BigQueryDataTransfer\Tests; + use PHPUnit\Framework\TestCase; class quickstartTest extends TestCase diff --git a/bigtable/src/create_app_profile.php b/bigtable/src/create_app_profile.php index 8c5d63a34c..b436e1a509 100644 --- a/bigtable/src/create_app_profile.php +++ b/bigtable/src/create_app_profile.php @@ -35,7 +35,8 @@ * * @param string $projectId The Google Cloud project ID * @param string $instanceId The ID of the Bigtable instance - * @param string $clusterId The ID of the cluster where the new App Profile will route it's requests(in case of single cluster routing) + * @param string $clusterId The ID of the cluster where the new App Profile will route it's requests + * (in case of single cluster routing) * @param string $appProfileId The ID of the App Profile to create */ function create_app_profile( @@ -53,7 +54,8 @@ function create_app_profile( ]); // create a new routing policy - // allow_transactional_writes refers to Single-Row-Transactions(https://cloud.google.com/bigtable/docs/app-profiles#single-row-transactions) + // allow_transactional_writes refers to Single-Row-Transactions + // (https://cloud.google.com/bigtable/docs/app-profiles#single-row-transactions) $routingPolicy = new SingleClusterRouting([ 'cluster_id' => $clusterId, 'allow_transactional_writes' => false diff --git a/bigtable/src/filter_composing_chain.php b/bigtable/src/filter_composing_chain.php index 55f921bc3a..e4ee5615ac 100644 --- a/bigtable/src/filter_composing_chain.php +++ b/bigtable/src/filter_composing_chain.php @@ -54,7 +54,8 @@ function filter_composing_chain( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_composing_condition.php b/bigtable/src/filter_composing_condition.php index 8ab84ce407..b1a459f437 100644 --- a/bigtable/src/filter_composing_condition.php +++ b/bigtable/src/filter_composing_condition.php @@ -58,7 +58,8 @@ function filter_composing_condition( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_composing_interleave.php b/bigtable/src/filter_composing_interleave.php index 6b86ce822c..ac379dae0c 100644 --- a/bigtable/src/filter_composing_interleave.php +++ b/bigtable/src/filter_composing_interleave.php @@ -54,7 +54,8 @@ function filter_composing_interleave( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_block_all.php b/bigtable/src/filter_limit_block_all.php index 543347b489..d3352e5942 100644 --- a/bigtable/src/filter_limit_block_all.php +++ b/bigtable/src/filter_limit_block_all.php @@ -52,7 +52,8 @@ function filter_limit_block_all( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_cells_per_col.php b/bigtable/src/filter_limit_cells_per_col.php index 47b2fb2ffa..e60c32a6a4 100644 --- a/bigtable/src/filter_limit_cells_per_col.php +++ b/bigtable/src/filter_limit_cells_per_col.php @@ -52,7 +52,8 @@ function filter_limit_cells_per_col( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_cells_per_row.php b/bigtable/src/filter_limit_cells_per_row.php index f33bab55f1..44ae35abd7 100644 --- a/bigtable/src/filter_limit_cells_per_row.php +++ b/bigtable/src/filter_limit_cells_per_row.php @@ -52,7 +52,8 @@ function filter_limit_cells_per_row( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_cells_per_row_offset.php b/bigtable/src/filter_limit_cells_per_row_offset.php index 6a2bb451b0..8e555ac6c4 100644 --- a/bigtable/src/filter_limit_cells_per_row_offset.php +++ b/bigtable/src/filter_limit_cells_per_row_offset.php @@ -52,7 +52,8 @@ function filter_limit_cells_per_row_offset( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_col_family_regex.php b/bigtable/src/filter_limit_col_family_regex.php index fff1c13a15..90a5e356b8 100644 --- a/bigtable/src/filter_limit_col_family_regex.php +++ b/bigtable/src/filter_limit_col_family_regex.php @@ -52,7 +52,8 @@ function filter_limit_col_family_regex( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_col_qualifier_regex.php b/bigtable/src/filter_limit_col_qualifier_regex.php index dc8cef4693..64bb9454a0 100644 --- a/bigtable/src/filter_limit_col_qualifier_regex.php +++ b/bigtable/src/filter_limit_col_qualifier_regex.php @@ -52,7 +52,8 @@ function filter_limit_col_qualifier_regex( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_col_range.php b/bigtable/src/filter_limit_col_range.php index f9604bcd53..64688a7ba9 100644 --- a/bigtable/src/filter_limit_col_range.php +++ b/bigtable/src/filter_limit_col_range.php @@ -55,7 +55,8 @@ function filter_limit_col_range( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_pass_all.php b/bigtable/src/filter_limit_pass_all.php index 06314eebcf..1d8fba93d7 100644 --- a/bigtable/src/filter_limit_pass_all.php +++ b/bigtable/src/filter_limit_pass_all.php @@ -52,7 +52,8 @@ function filter_limit_pass_all( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_row_regex.php b/bigtable/src/filter_limit_row_regex.php index 4a69f1d784..c340deca2c 100644 --- a/bigtable/src/filter_limit_row_regex.php +++ b/bigtable/src/filter_limit_row_regex.php @@ -52,7 +52,8 @@ function filter_limit_row_regex( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_row_sample.php b/bigtable/src/filter_limit_row_sample.php index ae10f34a88..e2cdeb96ec 100644 --- a/bigtable/src/filter_limit_row_sample.php +++ b/bigtable/src/filter_limit_row_sample.php @@ -52,7 +52,8 @@ function filter_limit_row_sample( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_timestamp_range.php b/bigtable/src/filter_limit_timestamp_range.php index b652886cae..fb33ca749d 100644 --- a/bigtable/src/filter_limit_timestamp_range.php +++ b/bigtable/src/filter_limit_timestamp_range.php @@ -59,7 +59,8 @@ function filter_limit_timestamp_range( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_value_range.php b/bigtable/src/filter_limit_value_range.php index e9176f0ea8..ccd0283005 100644 --- a/bigtable/src/filter_limit_value_range.php +++ b/bigtable/src/filter_limit_value_range.php @@ -55,7 +55,8 @@ function filter_limit_value_range( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_limit_value_regex.php b/bigtable/src/filter_limit_value_regex.php index 0b0602a5ba..beadf4857b 100644 --- a/bigtable/src/filter_limit_value_regex.php +++ b/bigtable/src/filter_limit_value_regex.php @@ -52,7 +52,8 @@ function filter_limit_value_regex( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_modify_apply_label.php b/bigtable/src/filter_modify_apply_label.php index a8b16f8c1d..9ffad7917c 100644 --- a/bigtable/src/filter_modify_apply_label.php +++ b/bigtable/src/filter_modify_apply_label.php @@ -52,7 +52,8 @@ function filter_modify_apply_label( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/filter_modify_strip_value.php b/bigtable/src/filter_modify_strip_value.php index d1fa692db7..528ac3d4d8 100644 --- a/bigtable/src/filter_modify_strip_value.php +++ b/bigtable/src/filter_modify_strip_value.php @@ -52,7 +52,8 @@ function filter_modify_strip_value( ]); foreach ($rows as $key => $row) { - // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print + // The "print_row" helper function is defined in + // https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print print_row($key, $row); } } diff --git a/bigtable/src/get_cluster.php b/bigtable/src/get_cluster.php index 5e14e1fe49..29deb484d2 100644 --- a/bigtable/src/get_cluster.php +++ b/bigtable/src/get_cluster.php @@ -61,12 +61,15 @@ function get_cluster( printf('Printing Details:' . PHP_EOL); // Fetch some commonly used metadata - printf('Name: ' . $cluster->getName() . PHP_EOL); - printf('Location: ' . $cluster->getLocation() . PHP_EOL); - printf('State: ' . State::name($cluster->getState()) . PHP_EOL); - printf('Default Storage Type: ' . StorageType::name($cluster->getDefaultStorageType()) . PHP_EOL); - printf('Nodes: ' . $cluster->getServeNodes() . PHP_EOL); - printf('Encryption Config: ' . ($cluster->hasEncryptionConfig() ? $cluster->getEncryptionConfig()->getKmsKeyName() : 'N/A') . PHP_EOL); + printf('Name: %s' . PHP_EOL, $cluster->getName()); + printf('Location: %s' . PHP_EOL, $cluster->getLocation()); + printf('State: %s' . PHP_EOL, State::name($cluster->getState())); + printf('Default Storage Type: %s' . PHP_EOL, StorageType::name($cluster->getDefaultStorageType())); + printf('Nodes: %s' . PHP_EOL, $cluster->getServeNodes()); + printf( + 'Encryption Config: %s' . PHP_EOL, + $cluster->hasEncryptionConfig() ? $cluster->getEncryptionConfig()->getKmsKeyName() : 'N/A' + ); } // [END bigtable_get_cluster] diff --git a/bigtable/src/get_instance.php b/bigtable/src/get_instance.php index fa9364c019..b80eb3ec60 100644 --- a/bigtable/src/get_instance.php +++ b/bigtable/src/get_instance.php @@ -70,7 +70,10 @@ function get_instance( // Labels are an object of the MapField class which implement the IteratorAggregate, Countable // and ArrayAccess interfaces so you can do the following: printf("\tNum of Labels: " . $labels->count() . PHP_EOL); - printf("\tLabel with a key(dev-label): " . ($labels['dev-label'] ?? 'N/A') . PHP_EOL); + printf( + "\tLabel with a key(dev-label): %s\n", + $labels->offsetExists('dev-label') ? $labels['dev-label'] : 'N/A' + ); // we can even loop over all the labels foreach ($labels as $key => $val) { diff --git a/bigtable/src/set_iam_policy.php b/bigtable/src/set_iam_policy.php index 93e1111bd5..bc7146ca41 100644 --- a/bigtable/src/set_iam_policy.php +++ b/bigtable/src/set_iam_policy.php @@ -36,7 +36,8 @@ * @param string $projectId The Google Cloud project ID * @param string $instanceId The ID of the Bigtable instance * @param string $email The email of the member to be assigned the role(Format: 'user:EMAIL_ID') - * @param string $role The role to be assigned. For a list of roles check out https://cloud.google.com/bigtable/docs/access-control + * @param string $role The role to be assigned. For a list of roles check out + * https://cloud.google.com/bigtable/docs/access-control */ function set_iam_policy( string $projectId, diff --git a/bigtable/src/update_app_profile.php b/bigtable/src/update_app_profile.php index 305ee8c85a..b9b4786c12 100644 --- a/bigtable/src/update_app_profile.php +++ b/bigtable/src/update_app_profile.php @@ -36,7 +36,8 @@ * * @param string $projectId The Google Cloud project ID * @param string $instanceId The ID of the Bigtable instance - * @param string $clusterId The ID of the new cluster where the new App Profile will route it's requests(in case of single cluster routing) + * @param string $clusterId The ID of the new cluster where the new App Profile will route it's + * requests (in case of single cluster routing). * @param string $appProfileId The ID of the App Profile to update */ function update_app_profile( @@ -54,7 +55,8 @@ function update_app_profile( ]); // create a new routing policy - // allow_transactional_writes refers to Single-Row-Transactions(https://cloud.google.com/bigtable/docs/app-profiles#single-row-transactions) + // allow_transactional_writes refers to Single-Row-Transactions + // (https://cloud.google.com/bigtable/docs/app-profiles#single-row-transactions) $routingPolicy = new SingleClusterRouting([ 'cluster_id' => $clusterId, 'allow_transactional_writes' => true diff --git a/cdn/signUrl.php b/cdn/signUrl.php index 883e1aa45a..1c778497b0 100644 --- a/cdn/signUrl.php +++ b/cdn/signUrl.php @@ -41,7 +41,7 @@ function base64url_decode($input) function base64url_encode($input, $padding = true) { $output = strtr(base64_encode($input), '+/', '-_'); - return ($padding) ? $output : str_replace('=', '', $output); + return ($padding) ? $output : str_replace('=', '', $output); } /** diff --git a/cdn/test/signUrlTest.php b/cdn/test/signUrlTest.php index 68988eb98c..008b1a3042 100644 --- a/cdn/test/signUrlTest.php +++ b/cdn/test/signUrlTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Cdn\Test; + use PHPUnit\Framework\TestCase; require_once __DIR__ . '/../signUrl.php'; @@ -28,7 +30,10 @@ public function testBase64UrlEncode() public function testBase64UrlEncodeWithoutPadding() { - $this->assertEquals(base64url_encode(hex2bin('9d9b51a2174d17d9b770a336e0870ae3'), false), 'nZtRohdNF9m3cKM24IcK4w'); + $this->assertEquals( + base64url_encode(hex2bin('9d9b51a2174d17d9b770a336e0870ae3'), false), + 'nZtRohdNF9m3cKM24IcK4w' + ); } public function testBase64UrlDecode() @@ -45,14 +50,27 @@ public function testSignUrl() { $encoded_key = 'nZtRohdNF9m3cKM24IcK4w=='; // base64url encoded key - $cases = array( - array('http://35.186.234.33/index.html', 'my-key', 1558131350, - 'http://35.186.234.33/index.html?Expires=1558131350&KeyName=my-key&Signature=fm6JZSmKNsB5sys8VGr-JE4LiiE='), - array('https://www.google.com/', 'my-key', 1549751401, - 'https://www.google.com/?Expires=1549751401&KeyName=my-key&Signature=M_QO7BGHi2sGqrJO-MDr0uhDFuc='), - array('https://www.example.com/some/path?some=query&another=param', 'my-key', 1549751461, - 'https://www.example.com/some/path?some=query&another=param&Expires=1549751461&KeyName=my-key&Signature=sTqqGX5hUJmlRJ84koAIhWW_c3M='), - ); + $cases = [ + [ 'http://35.186.234.33/index.html', + 'my-key', + 1558131350, + 'http://35.186.234.33/index.html?Expires=1558131350&KeyName=my-key' + . '&Signature=fm6JZSmKNsB5sys8VGr-JE4LiiE=' + ], + [ + 'https://www.google.com/', + 'my-key', + 1549751401, + 'https://www.google.com/?Expires=1549751401&KeyName=my-key&Signature=M_QO7BGHi2sGqrJO-MDr0uhDFuc=' + ], + [ + 'https://www.example.com/some/path?some=query&another=param', + 'my-key', + 1549751461, + 'https://www.example.com/some/path?some=query&another=param&Expires=1549751461&KeyName=my-key' + . '&Signature=sTqqGX5hUJmlRJ84koAIhWW_c3M=' + ], + ]; foreach ($cases as $c) { $this->assertEquals(sign_url($c[0], $c[1], $encoded_key, $c[2]), $c[3]); diff --git a/compute/firewall/src/list_firewall_rules.php b/compute/firewall/src/list_firewall_rules.php index 0a5f3258c9..f88c622e03 100644 --- a/compute/firewall/src/list_firewall_rules.php +++ b/compute/firewall/src/list_firewall_rules.php @@ -45,7 +45,12 @@ function list_firewall_rules(string $projectId) print('--- Firewall Rules ---' . PHP_EOL); foreach ($firewallList->iterateAllElements() as $firewall) { - printf(' - %s : %s : %s' . PHP_EOL, $firewall->getName(), $firewall->getDescription(), $firewall->getNetwork()); + printf( + ' - %s : %s : %s' . PHP_EOL, + $firewall->getName(), + $firewall->getDescription(), + $firewall->getNetwork() + ); } } # [END compute_firewall_list] diff --git a/compute/firewall/src/print_firewall_rule.php b/compute/firewall/src/print_firewall_rule.php index d91ab44cfd..bab5a7bc5e 100644 --- a/compute/firewall/src/print_firewall_rule.php +++ b/compute/firewall/src/print_firewall_rule.php @@ -56,12 +56,12 @@ function print_firewall_rule(string $projectId, string $firewallRuleName) print('--Allowed--' . PHP_EOL); foreach ($response->getAllowed() as $item) { printf('Protocol: %s' . PHP_EOL, $item->getIPProtocol()); - foreach ($item->getPorts()as $ports) { + foreach ($item->getPorts() as $ports) { printf(' - Ports: %s' . PHP_EOL, $ports); } } print('--Source Ranges--' . PHP_EOL); - foreach ($response->getSourceRanges()as $ranges) { + foreach ($response->getSourceRanges() as $ranges) { printf(' - Range: %s' . PHP_EOL, $ranges); } } diff --git a/compute/firewall/test/firewallTest.php b/compute/firewall/test/firewallTest.php index c5a0f25586..bb4acd8c19 100644 --- a/compute/firewall/test/firewallTest.php +++ b/compute/firewall/test/firewallTest.php @@ -129,7 +129,7 @@ public function testDeleteFirewallRule() 'projectId' => self::$projectId, 'firewallRuleName' => self::$firewallRuleName ]); - $this->assertStringContainsString('Rule ' . self::$firewallRuleName . ' deleted', $output); + $this->assertStringContainsString('Rule ' . self::$firewallRuleName . ' deleted', $output); } catch (ApiException $e) { if ($e->getCode() != 404) { throw new ApiException($e->getMessage(), $e->getCode(), $e->getStatus()); diff --git a/compute/logging/test/loggingTest.php b/compute/logging/test/loggingTest.php index af7f0fedb0..d2bd658f51 100644 --- a/compute/logging/test/loggingTest.php +++ b/compute/logging/test/loggingTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Compute\Logging\Test; + use PHPUnit\Framework\TestCase; require_once __DIR__ . '/mocks/FluentLogger.php'; diff --git a/datastore/api/test/ConceptsTest.php b/datastore/api/test/ConceptsTest.php index dede5540b7..f11752d7a0 100644 --- a/datastore/api/test/ConceptsTest.php +++ b/datastore/api/test/ConceptsTest.php @@ -56,7 +56,8 @@ public function setUp(): void getenv('DATASTORE_EMULATOR_HOST') === false) { $this->markTestSkipped( 'No application credentials were found, also not using the ' - . 'datastore emulator'); + . 'datastore emulator' + ); } self::$datastore = new DatastoreClient([ 'namespaceId' => self::$namespaceId = $this->generateRandomString() diff --git a/dialogflow/dialogflow.php b/dialogflow/dialogflow.php index e566aa5911..0930f21914 100644 --- a/dialogflow/dialogflow.php +++ b/dialogflow/dialogflow.php @@ -31,14 +31,29 @@ // detect text intent command $application->add((new Command('detect-intent-texts')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session. Defaults to random.') - ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, - 'Language code of the query. Defaults to "en-US".', 'en-US') - ->addArgument('texts', InputArgument::IS_ARRAY | InputArgument::REQUIRED, - 'Text inputs.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.' + ) + ->addOption( + 'language-code', + 'l', + InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', + 'en-US' + ) + ->addArgument( + 'texts', + InputArgument::IS_ARRAY | InputArgument::REQUIRED, + 'Text inputs.' + ) ->setDescription('Detect intent of text inputs using Dialogflow.') ->setHelp(<<%command.name% command detects the intent of provided text @@ -54,17 +69,28 @@ $languageCode = $input->getOption('language-code'); $texts = $input->getArgument('texts'); detect_intent_texts($projectId, $texts, $sessionId, $languageCode); - }) -); + })); // detect audio intent command $application->add((new Command('detect-intent-audio')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session. Defaults to random.') - ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, - 'Language code of the query. Defaults to "en-US".', 'en-US') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.' + ) + ->addOption( + 'language-code', + 'l', + InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', + 'en-US' + ) ->addArgument('path', InputArgument::REQUIRED, 'Path to audio file.') ->setDescription('Detect intent of audio file using Dialogflow.') ->setHelp(<<getOption('language-code'); $path = $input->getArgument('path'); detect_intent_audio($projectId, $path, $sessionId, $languageCode); - }) -); + })); // detect stream intent command $application->add((new Command('detect-intent-stream')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session. Defaults to random.') - ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, - 'Language code of the query. Defaults to "en-US".', 'en-US') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.' + ) + ->addOption( + 'language-code', + 'l', + InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', + 'en-US' + ) ->addArgument('path', InputArgument::REQUIRED, 'Path to audio file.') ->setDescription('Detect intent of audio stream using Dialogflow.') ->setHelp(<<getOption('language-code'); $path = $input->getArgument('path'); detect_intent_stream($projectId, $path, $sessionId, $languageCode); - }) -); + })); // list intent command $application->add((new Command('intent-list')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->setDescription('List intents.') ->setHelp(<<%command.name% command lists intents. @@ -125,20 +164,28 @@ ->setCode(function ($input, $output) { $projectId = $input->getArgument('project-id'); intent_list($projectId); - }) -); + })); // create intent command $application->add((new Command('intent-create')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addArgument('display-name', InputArgument::REQUIRED, - 'Display name of intent.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addArgument( + 'display-name', + InputArgument::REQUIRED, + 'Display name of intent.' + ) ->addOption('training-phrases-parts', 't', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Training phrases.') - ->addOption('message-texts', 'm', + ->addOption( + 'message-texts', + 'm', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, - 'Message texts for the agent\'s response when the intent is detected.') + 'Message texts for the agent\'s response when the intent is detected.' + ) ->setDescription('Create intent of provided display name.') ->setHelp(<<%command.name% command creates intent of provided display name. @@ -153,13 +200,15 @@ $traingPhrases = $input->getOption('training-phrases-parts'); $messageTexts = $input->getOption('message-texts'); intent_create($projectId, $displayName, $traingPhrases, $messageTexts); - }) -); + })); // delete intent command $application->add((new Command('intent-delete')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->addArgument('intent-id', InputArgument::REQUIRED, 'ID of intent.') ->setDescription('Delete intent of provided intent id.') ->setHelp(<<getArgument('project-id'); $intentId = $input->getArgument('intent-id'); intent_delete($projectId, $intentId); - }) -); + })); // list entity type command $application->add((new Command('entity-type-list')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->setDescription('List entity types.') ->setHelp(<<%command.name% command lists entity types. @@ -189,17 +240,27 @@ ->setCode(function ($input, $output) { $projectId = $input->getArgument('project-id'); entity_type_list($projectId); - }) -); + })); // create entity type command $application->add((new Command('entity-type-create')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addArgument('display-name', InputArgument::REQUIRED, - 'Display name of the entity.') - ->addOption('kind', 'k', InputOption::VALUE_REQUIRED, - 'Kind of entity. KIND_MAP (default) or KIND_LIST', Kind::KIND_MAP) + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addArgument( + 'display-name', + InputArgument::REQUIRED, + 'Display name of the entity.' + ) + ->addOption( + 'kind', + 'k', + InputOption::VALUE_REQUIRED, + 'Kind of entity. KIND_MAP (default) or KIND_LIST', + Kind::KIND_MAP + ) ->setDescription('Create entity types with provided display name.') ->setHelp(<<%command.name% command creates entity type with provided name. @@ -212,13 +273,15 @@ $displayName = $input->getArgument('display-name'); $kind = $input->getOption('kind'); entity_type_create($projectId, $displayName, $kind); - }) -); + })); // delete entity type command $application->add((new Command('entity-type-delete')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') ->setDescription('Delete entity types of provided entity type id.') ->setHelp(<<getArgument('project-id'); $entityTypeId = $input->getArgument('entity-type-id'); entity_type_delete($projectId, $entityTypeId); - }) -); + })); // list entity command $application->add((new Command('entity-list')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') ->setDescription('List entities of provided entity type id.') ->setHelp(<<getArgument('project-id'); $entityTypeId = $input->getArgument('entity-type-id'); entity_list($projectId, $entityTypeId); - }) -); + })); // create entity command $application->add((new Command('entity-create')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') ->addArgument('entity-value', InputArgument::REQUIRED, 'Value of the entity.') - ->addArgument('synonyms', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - 'Synonyms that will map to provided entity value.') + ->addArgument( + 'synonyms', + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + 'Synonyms that will map to provided entity value.' + ) ->setDescription('Create entity value for entity type id.') ->setHelp(<<%command.name% command creates entity value for entity type id. @@ -274,13 +344,15 @@ $entityValue = $input->getArgument('entity-value'); $synonyms = $input->getArgument('synonyms'); entity_create($projectId, $entityTypeId, $entityValue, $synonyms); - }) -); + })); // delete entity command $application->add((new Command('entity-delete')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') ->addArgument('entity-value', InputArgument::REQUIRED, 'Value of the entity.') ->setDescription('Delete entity value from entity type id.') @@ -295,15 +367,21 @@ $entityTypeId = $input->getArgument('entity-type-id'); $entityValue = $input->getArgument('entity-value'); entity_delete($projectId, $entityTypeId, $entityValue); - }) -); + })); // list context command $application->add((new Command('context-list')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) ->setDescription('List contexts.') ->setHelp(<<%command.name% command lists contexts. @@ -315,18 +393,29 @@ $projectId = $input->getArgument('project-id'); $sessionId = $input->getOption('session-id'); context_list($projectId, $sessionId); - }) -); + })); // create context command $application->add((new Command('context-create')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) ->addArgument('context-id', InputArgument::REQUIRED, 'ID of the context.') - ->addOption('lifespan-count', 'c', InputOption::VALUE_REQUIRED, - 'Lifespan count of the context. Defaults to 1.', 1) + ->addOption( + 'lifespan-count', + 'c', + InputOption::VALUE_REQUIRED, + 'Lifespan count of the context. Defaults to 1.', + 1 + ) ->setDescription('Create context of provided context id.') ->setHelp(<<%command.name% command creates context of provided context id. @@ -341,15 +430,21 @@ $contextId = $input->getArgument('context-id'); $lifespan = $input->getOption('lifespan-count'); context_create($projectId, $contextId, $sessionId, $lifespan); - }) -); + })); // delete context command $application->add((new Command('context-delete')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) ->addArgument('context-id', InputArgument::REQUIRED, 'ID of the context.') ->setDescription('Delete context of provided context id.') ->setHelp(<<getOption('session-id'); $contextId = $input->getArgument('context-id'); context_delete($projectId, $contextId, $sessionId); - }) -); + })); // list session entity type command $application->add((new Command('session-entity-type-list')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) ->setDescription('List session entity types.') ->setHelp(<<%command.name% command lists session entity types. @@ -383,22 +484,35 @@ $projectId = $input->getArgument('project-id'); $sessionId = $input->getOption('session-id'); session_entity_type_list($projectId, $sessionId); - }) -); + })); // create session entity type command $application->add((new Command('session-entity-type-create')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') - ->addArgument('entity-type-display-name', InputArgument::REQUIRED, - 'Display name of the entity type.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) + ->addArgument( + 'entity-type-display-name', + InputArgument::REQUIRED, + 'Display name of the entity type.' + ) ->addArgument('entity-values', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Entity values of the session entity type.') - ->addOption('entity-override-mode', 'o', InputOption::VALUE_REQUIRED, + ->addOption( + 'entity-override-mode', + 'o', + InputOption::VALUE_REQUIRED, 'ENTITY_OVERRIDE_MODE_OVERRIDE (default) or ENTITY_OVERRIDE_MODE_SUPPLEMENT', - EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE) + EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE + ) ->setDescription('Create session entity type.') ->setHelp(<<%command.name% command creates session entity type with @@ -415,19 +529,33 @@ $displayName = $input->getArgument('entity-type-display-name'); $values = $input->getArgument('entity-values'); $overrideMode = $input->getOption('entity-override-mode'); - session_entity_type_create($projectId, $displayName, $values, - $sessionId, $overrideMode); - }) -); + session_entity_type_create( + $projectId, + $displayName, + $values, + $sessionId, + $overrideMode + ); + })); // delete session entity type command $application->add((new Command('session-entity-type-delete')) - ->addArgument('project-id', InputArgument::REQUIRED, - 'Project/agent id. Required.') - ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, - 'Identifier of the DetectIntent session.') - ->addArgument('entity-type-display-name', InputArgument::REQUIRED, - 'Display name of the entity type.') + ->addArgument( + 'project-id', + InputArgument::REQUIRED, + 'Project/agent id. Required.' + ) + ->addOption( + 'session-id', + 's', + InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.' + ) + ->addArgument( + 'entity-type-display-name', + InputArgument::REQUIRED, + 'Display name of the entity type.' + ) ->setDescription('Delete session entity type of provided display name.') ->setHelp(<<%command.name% command deletes specified session entity type. @@ -441,8 +569,7 @@ $sessionId = $input->getOption('session-id'); $displayName = $input->getArgument('entity-type-display-name'); session_entity_type_delete($projectId, $displayName, $sessionId); - }) -); + })); if (getenv('PHPUNIT_TESTS') === '1') { return $application; diff --git a/dialogflow/src/detect_intent_audio.php b/dialogflow/src/detect_intent_audio.php index d100287ea7..65298c9592 100644 --- a/dialogflow/src/detect_intent_audio.php +++ b/dialogflow/src/detect_intent_audio.php @@ -65,8 +65,11 @@ function detect_intent_audio($projectId, $path, $sessionId, $languageCode = 'en- // output relevant info print(str_repeat('=', 20) . PHP_EOL); printf('Query text: %s' . PHP_EOL, $queryText); - printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, - $confidence); + printf( + 'Detected intent: %s (confidence: %f)' . PHP_EOL, + $displayName, + $confidence + ); print(PHP_EOL); printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); diff --git a/dialogflow/src/detect_intent_stream.php b/dialogflow/src/detect_intent_stream.php index 932f94b7e6..9ec9027d95 100644 --- a/dialogflow/src/detect_intent_stream.php +++ b/dialogflow/src/detect_intent_stream.php @@ -98,8 +98,11 @@ function detect_intent_stream($projectId, $path, $sessionId, $languageCode = 'en // output relevant info printf('Query text: %s' . PHP_EOL, $queryText); - printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, - $confidence); + printf( + 'Detected intent: %s (confidence: %f)' . PHP_EOL, + $displayName, + $confidence + ); print(PHP_EOL); printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); } diff --git a/dialogflow/src/detect_intent_texts.php b/dialogflow/src/detect_intent_texts.php index 35e0019e92..97244f04f1 100644 --- a/dialogflow/src/detect_intent_texts.php +++ b/dialogflow/src/detect_intent_texts.php @@ -61,8 +61,11 @@ function detect_intent_texts($projectId, $texts, $sessionId, $languageCode = 'en // output relevant info print(str_repeat('=', 20) . PHP_EOL); printf('Query text: %s' . PHP_EOL, $queryText); - printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, - $confidence); + printf( + 'Detected intent: %s (confidence: %f)' . PHP_EOL, + $displayName, + $confidence + ); print(PHP_EOL); printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); } diff --git a/dialogflow/src/entity_create.php b/dialogflow/src/entity_create.php index 8a7de9db7a..58ec9c18c5 100644 --- a/dialogflow/src/entity_create.php +++ b/dialogflow/src/entity_create.php @@ -34,8 +34,10 @@ function entity_create($projectId, $entityTypeId, $entityValue, $synonyms = []) } $entityTypesClient = new EntityTypesClient(); - $parent = $entityTypesClient->entityTypeName($projectId, - $entityTypeId); + $parent = $entityTypesClient->entityTypeName( + $projectId, + $entityTypeId + ); // prepare entity $entity = new Entity(); diff --git a/dialogflow/src/intent_create.php b/dialogflow/src/intent_create.php index 8afd07624b..70eb5e3413 100644 --- a/dialogflow/src/intent_create.php +++ b/dialogflow/src/intent_create.php @@ -29,9 +29,12 @@ /** * Create an intent of the given intent type. */ -function intent_create($projectId, $displayName, $trainingPhraseParts = [], - $messageTexts = []) -{ +function intent_create( + $projectId, + $displayName, + $trainingPhraseParts = [], + $messageTexts = [] +) { $intentsClient = new IntentsClient(); // prepare parent diff --git a/dialogflow/src/intent_list.php b/dialogflow/src/intent_list.php index c108743638..3696071f30 100644 --- a/dialogflow/src/intent_list.php +++ b/dialogflow/src/intent_list.php @@ -36,10 +36,14 @@ function intent_list($projectId) printf('Intent name: %s' . PHP_EOL, $intent->getName()); printf('Intent display name: %s' . PHP_EOL, $intent->getDisplayName()); printf('Action: %s' . PHP_EOL, $intent->getAction()); - printf('Root followup intent: %s' . PHP_EOL, - $intent->getRootFollowupIntentName()); - printf('Parent followup intent: %s' . PHP_EOL, - $intent->getParentFollowupIntentName()); + printf( + 'Root followup intent: %s' . PHP_EOL, + $intent->getRootFollowupIntentName() + ); + printf( + 'Parent followup intent: %s' . PHP_EOL, + $intent->getParentFollowupIntentName() + ); print(PHP_EOL); print('Input contexts: ' . PHP_EOL); diff --git a/dialogflow/src/session_entity_type_create.php b/dialogflow/src/session_entity_type_create.php index cde28497a2..f164b931a5 100644 --- a/dialogflow/src/session_entity_type_create.php +++ b/dialogflow/src/session_entity_type_create.php @@ -27,9 +27,13 @@ /** * Create a session entity type with the given display name. */ -function session_entity_type_create($projectId, $displayName, $values, - $sessionId, $overrideMode = EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE) -{ +function session_entity_type_create( + $projectId, + $displayName, + $values, + $sessionId, + $overrideMode = EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE +) { $sessionEntityTypesClient = new SessionEntityTypesClient(); $parent = $sessionEntityTypesClient->sessionName($projectId, $sessionId); diff --git a/dlp/src/create_trigger.php b/dlp/src/create_trigger.php index 6ae2173d50..8a8cf15af5 100644 --- a/dlp/src/create_trigger.php +++ b/dlp/src/create_trigger.php @@ -51,7 +51,8 @@ * @param string $description (Optional) A description for the trigger to be created * @param int $scanPeriod (Optional) How often to wait between scans, in days (minimum = 1 day) * @param bool $autoPopulateTimespan (Optional) Automatically limit scan to new content only - * @param int $maxFindings (Optional) The maximum number of findings to report per request (0 = server maximum) + * @param int $maxFindings (Optional) The maximum number of findings to report per request + * (0 = server maximum) */ function create_trigger( string $callingProjectId, diff --git a/dlp/src/deidentify_fpe.php b/dlp/src/deidentify_fpe.php index f68ac64c4a..b286877a7f 100644 --- a/dlp/src/deidentify_fpe.php +++ b/dlp/src/deidentify_fpe.php @@ -68,7 +68,8 @@ function deidentify_fpe( ->setCryptoKeyName($keyName); // The set of characters to replace sensitive ones with - // For more information, see https://cloud.google.com/dlp/docs/reference/rest/V2/organizations.deidentifyTemplates#ffxcommonnativealphabet + // For more information, see + // https://cloud.google.com/dlp/docs/reference/rest/V2/organizations.deidentifyTemplates#ffxcommonnativealphabet $commonAlphabet = FfxCommonNativeAlphabet::NUMERIC; // Create the crypto key configuration object diff --git a/dlp/src/inspect_datastore.php b/dlp/src/inspect_datastore.php index bbadd53397..9d85e949f5 100644 --- a/dlp/src/inspect_datastore.php +++ b/dlp/src/inspect_datastore.php @@ -159,7 +159,11 @@ function inspect_datastore( print('No findings.' . PHP_EOL); } else { foreach ($infoTypeStats as $infoTypeStat) { - printf(' Found %s instance(s) of infoType %s' . PHP_EOL, $infoTypeStat->getCount(), $infoTypeStat->getInfoType()->getName()); + printf( + ' Found %s instance(s) of infoType %s' . PHP_EOL, + $infoTypeStat->getCount(), + $infoTypeStat->getInfoType()->getName() + ); } } break; diff --git a/dlp/src/inspect_gcs.php b/dlp/src/inspect_gcs.php index 00d7a9a5b5..3985d8ac94 100644 --- a/dlp/src/inspect_gcs.php +++ b/dlp/src/inspect_gcs.php @@ -47,7 +47,8 @@ * @param string $topicId The name of the Pub/Sub topic to notify once the job completes * @param string $subscriptionId The name of the Pub/Sub subscription to use when listening for job * @param string $bucketId The name of the bucket where the file resides - * @param string $file The path to the file within the bucket to inspect. Can contain wildcards e.g. "my-image.*" + * @param string $file The path to the file within the bucket to inspect. Can contain wildcards + * e.g. "my-image.*" * @param int $maxFindings (Optional) The maximum number of findings to report per request (0 = server maximum) */ function inspect_gcs( @@ -150,7 +151,11 @@ function inspect_gcs( print('No findings.' . PHP_EOL); } else { foreach ($infoTypeStats as $infoTypeStat) { - printf(' Found %s instance(s) of infoType %s' . PHP_EOL, $infoTypeStat->getCount(), $infoTypeStat->getInfoType()->getName()); + printf( + ' Found %s instance(s) of infoType %s' . PHP_EOL, + $infoTypeStat->getCount(), + $infoTypeStat->getInfoType()->getName() + ); } } break; diff --git a/dlp/src/list_triggers.php b/dlp/src/list_triggers.php index 21d35f79c7..cb6e8af4e8 100644 --- a/dlp/src/list_triggers.php +++ b/dlp/src/list_triggers.php @@ -56,8 +56,10 @@ function list_triggers(string $callingProjectId): void printf(' Status: %s' . PHP_EOL, $trigger->getStatus()); printf(' Error count: %s' . PHP_EOL, count($trigger->getErrors())); $timespanConfig = $trigger->getInspectJob()->getStorageConfig()->getTimespanConfig(); - printf(' Auto-populates timespan config: %s' . PHP_EOL, - ($timespanConfig && $timespanConfig->getEnableAutoPopulationOfTimespanConfig() ? 'yes' : 'no')); + printf( + ' Auto-populates timespan config: %s' . PHP_EOL, + ($timespanConfig && $timespanConfig->getEnableAutoPopulationOfTimespanConfig() ? 'yes' : 'no') + ); } } # [END dlp_list_triggers] diff --git a/dlp/src/reidentify_fpe.php b/dlp/src/reidentify_fpe.php index 9ad5f5374e..b2335e87be 100644 --- a/dlp/src/reidentify_fpe.php +++ b/dlp/src/reidentify_fpe.php @@ -66,7 +66,8 @@ function reidentify_fpe( $infoTypes = [$ssnInfoType]; // The set of characters to replace sensitive ones with - // For more information, see https://cloud.google.com/dlp/docs/reference/rest/v2/organizations.deidentifyTemplates#ffxcommonnativealphabet + // For more information, see + // https://cloud.google.com/dlp/docs/reference/rest/v2/organizations.deidentifyTemplates#ffxcommonnativealphabet $commonAlphabet = FfxCommonNativeAlphabet::NUMERIC; // Create the wrapped crypto key configuration object diff --git a/dlp/test/quickstartTest.php b/dlp/test/quickstartTest.php index 7460238d85..ae22b45a59 100644 --- a/dlp/test/quickstartTest.php +++ b/dlp/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Dlp\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/documentai/test/quickstartTest.php b/documentai/test/quickstartTest.php index 649d749df2..bf44f248f2 100644 --- a/documentai/test/quickstartTest.php +++ b/documentai/test/quickstartTest.php @@ -14,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Google\Cloud\Samples\DocumentAI\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/endpoints/getting-started/test/LocalTest.php b/endpoints/getting-started/test/LocalTest.php index ef67b0569b..a08133827a 100644 --- a/endpoints/getting-started/test/LocalTest.php +++ b/endpoints/getting-started/test/LocalTest.php @@ -14,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Google\Cloud\Samples\Endpoints\Test; + use PHPUnit\Framework\TestCase; use Slim\Psr7\Factory\RequestFactory; diff --git a/endpoints/getting-started/test/endpointsTest.php b/endpoints/getting-started/test/endpointsTest.php index 6b15903acf..7ff781ef7b 100644 --- a/endpoints/getting-started/test/endpointsTest.php +++ b/endpoints/getting-started/test/endpointsTest.php @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace Google\Cloud\Samples\Endpoints; +namespace Google\Cloud\Samples\Endpoints\Test; use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/firestore/src/query_filter_array_contains_any.php b/firestore/src/query_filter_array_contains_any.php index d40932e56b..10dfbde98e 100644 --- a/firestore/src/query_filter_array_contains_any.php +++ b/firestore/src/query_filter_array_contains_any.php @@ -41,7 +41,10 @@ function query_filter_array_contains_any(string $projectId): void $containsQuery = $citiesRef->where('regions', 'array-contains-any', ['west_coast', 'east_coast']); # [END firestore_query_filter_array_contains_any] foreach ($containsQuery->documents() as $document) { - printf('Document %s returned by query regions array-contains-any [west_coast, east_coast]' . PHP_EOL, $document->id()); + printf( + 'Document %s returned by query regions array-contains-any [west_coast, east_coast]' . PHP_EOL, + $document->id() + ); } } diff --git a/firestore/src/transaction_document_update.php b/firestore/src/transaction_document_update.php index 0ecfbf8c12..30592bea77 100644 --- a/firestore/src/transaction_document_update.php +++ b/firestore/src/transaction_document_update.php @@ -47,7 +47,8 @@ function transaction_document_update(string $projectId): void ]); }); # [END firestore_transaction_document_update] - printf('Ran a simple transaction to update the population field in the SF document in the cities collection.' . PHP_EOL); + print('Ran a simple transaction to update the population field in the SF document in the cities collection.'); + print(PHP_EOF); } // The following 2 lines are only needed to run the samples diff --git a/functions/firebase_auth/test/DeployTest.php b/functions/firebase_auth/test/DeployTest.php index 1b57304a96..6ad781007f 100644 --- a/functions/firebase_auth/test/DeployTest.php +++ b/functions/firebase_auth/test/DeployTest.php @@ -121,7 +121,9 @@ public function testFirebaseAuth( private function createAuthUser(string $email): void { if (empty(self::$apiHttpClient)) { - $credentials = ApplicationDefaultCredentials::getCredentials('https://www.googleapis.com/auth/cloud-platform'); + $credentials = ApplicationDefaultCredentials::getCredentials( + 'https://www.googleapis.com/auth/cloud-platform' + ); self::$apiHttpClient = CredentialsLoader::makeHttpClient($credentials, [ 'base_uri' => 'https://identitytoolkit.googleapis.com/' ]); diff --git a/functions/firebase_remote_config/test/DeployTest.php b/functions/firebase_remote_config/test/DeployTest.php index cbb7ec1549..ecffb250ae 100644 --- a/functions/firebase_remote_config/test/DeployTest.php +++ b/functions/firebase_remote_config/test/DeployTest.php @@ -140,7 +140,9 @@ private function updateRemoteConfig( $projectId = self::requireEnv('GOOGLE_PROJECT_ID'); if (empty(self::$apiHttpClient)) { - $credentials = ApplicationDefaultCredentials::getCredentials('https://www.googleapis.com/auth/cloud-platform'); + $credentials = ApplicationDefaultCredentials::getCredentials( + 'https://www.googleapis.com/auth/cloud-platform' + ); self::$apiHttpClient = CredentialsLoader::makeHttpClient($credentials, [ 'base_uri' => 'https://firebaseremoteconfig.googleapis.com/v1/projects/' . $projectId . '/remoteConfig' ]); diff --git a/functions/helloworld_pubsub/test/IntegrationTest.php b/functions/helloworld_pubsub/test/IntegrationTest.php index 2e351c8c2f..fb60af2463 100644 --- a/functions/helloworld_pubsub/test/IntegrationTest.php +++ b/functions/helloworld_pubsub/test/IntegrationTest.php @@ -74,8 +74,13 @@ public function dataProvider() /** * @dataProvider dataProvider */ - public function testHelloworldPubsub(array $cloudevent, array $data, int $statusCode, string $expected, string $label): void - { + public function testHelloworldPubsub( + array $cloudevent, + array $data, + int $statusCode, + string $expected, + string $label + ): void { // Prepare the HTTP headers for a CloudEvent. $cloudEventHeaders = []; foreach ($cloudevent as $key => $value) { diff --git a/functions/http_content_type/index.php b/functions/http_content_type/index.php index fc307df3e0..3b4d6bbbf2 100644 --- a/functions/http_content_type/index.php +++ b/functions/http_content_type/index.php @@ -37,15 +37,15 @@ function helloContent(ServerRequestInterface $request): string $name = $json['name'] ?? $name; } break; - // 'John', stored in a stream + // 'John', stored in a stream case 'application/octet-stream': $name = $body; break; - // 'John' + // 'John' case 'text/plain': $name = $body; break; - // 'name=John' in the body of a POST request (not the URL) + // 'name=John' in the body of a POST request (not the URL) case 'application/x-www-form-urlencoded': parse_str($body, $data); $name = $data['name'] ?? $name; diff --git a/functions/http_form_data/index.php b/functions/http_form_data/index.php index a93d12d92c..da0264f6ef 100644 --- a/functions/http_form_data/index.php +++ b/functions/http_form_data/index.php @@ -29,7 +29,10 @@ function uploadFile(ServerRequestInterface $request): ResponseInterface $contentType = $request->getHeader('Content-Type')[0]; if (strpos($contentType, 'multipart/form-data') !== 0) { - return new Response(400, [], 'Bad Request: content of type "multipart/form-data" not provided, found ' . $contentType); + return new Response(400, [], sprintf( + 'Bad Request: content of type "multipart/form-data" not provided, found %s', + $contentType + )); } $fileList = []; diff --git a/functions/tips_infinite_retries/test/IntegrationTest.php b/functions/tips_infinite_retries/test/IntegrationTest.php index 1a5b16ace5..fc52bd9898 100644 --- a/functions/tips_infinite_retries/test/IntegrationTest.php +++ b/functions/tips_infinite_retries/test/IntegrationTest.php @@ -74,8 +74,13 @@ public function dataProvider() /** * @dataProvider dataProvider */ - public function testLimitInfiniteRetries(array $cloudevent, array $data, string $statusCode, string $expected, string $label): void - { + public function testLimitInfiniteRetries( + array $cloudevent, + array $data, + string $statusCode, + string $expected, + string $label + ): void { // Prepare the HTTP headers for a CloudEvent. $cloudEventHeaders = []; foreach ($cloudevent as $key => $value) { diff --git a/iot/README.md b/iot/README.md deleted file mode 100644 index cb74ef1206..0000000000 --- a/iot/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Deprecation Notice - -*

Google Cloud IoT Core will be retired as of August 16, 2023.

- -*

Hence, the samples in this directory are archived and are no longer maintained.

- -*

If you are customer with an assigned Google Cloud account team, contact your account team for more information.

diff --git a/kms/src/create_key_asymmetric_decrypt.php b/kms/src/create_key_asymmetric_decrypt.php index 1ca1519294..ca89e279dd 100644 --- a/kms/src/create_key_asymmetric_decrypt.php +++ b/kms/src/create_key_asymmetric_decrypt.php @@ -44,13 +44,11 @@ function create_key_asymmetric_decrypt( $key = (new CryptoKey()) ->setPurpose(CryptoKeyPurpose::ASYMMETRIC_DECRYPT) ->setVersionTemplate((new CryptoKeyVersionTemplate()) - ->setAlgorithm(CryptoKeyVersionAlgorithm::RSA_DECRYPT_OAEP_2048_SHA256) - ) + ->setAlgorithm(CryptoKeyVersionAlgorithm::RSA_DECRYPT_OAEP_2048_SHA256)) // Optional: customize how long key versions should be kept before destroying. ->setDestroyScheduledDuration((new Duration()) - ->setSeconds(24 * 60 * 60) - ); + ->setSeconds(24 * 60 * 60)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/create_key_asymmetric_sign.php b/kms/src/create_key_asymmetric_sign.php index 7d0b655d58..d2dd34576d 100644 --- a/kms/src/create_key_asymmetric_sign.php +++ b/kms/src/create_key_asymmetric_sign.php @@ -44,13 +44,11 @@ function create_key_asymmetric_sign( $key = (new CryptoKey()) ->setPurpose(CryptoKeyPurpose::ASYMMETRIC_SIGN) ->setVersionTemplate((new CryptoKeyVersionTemplate()) - ->setAlgorithm(CryptoKeyVersionAlgorithm::RSA_SIGN_PKCS1_2048_SHA256) - ) + ->setAlgorithm(CryptoKeyVersionAlgorithm::RSA_SIGN_PKCS1_2048_SHA256)) // Optional: customize how long key versions should be kept before destroying. ->setDestroyScheduledDuration((new Duration()) - ->setSeconds(24 * 60 * 60) - ); + ->setSeconds(24 * 60 * 60)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/create_key_hsm.php b/kms/src/create_key_hsm.php index f8ae8d4306..2b9bbf955c 100644 --- a/kms/src/create_key_hsm.php +++ b/kms/src/create_key_hsm.php @@ -46,13 +46,11 @@ function create_key_hsm( ->setPurpose(CryptoKeyPurpose::ENCRYPT_DECRYPT) ->setVersionTemplate((new CryptoKeyVersionTemplate()) ->setAlgorithm(CryptoKeyVersionAlgorithm::GOOGLE_SYMMETRIC_ENCRYPTION) - ->setProtectionLevel(ProtectionLevel::HSM) - ) + ->setProtectionLevel(ProtectionLevel::HSM)) // Optional: customize how long key versions should be kept before destroying. ->setDestroyScheduledDuration((new Duration()) - ->setSeconds(24 * 60 * 60) - ); + ->setSeconds(24 * 60 * 60)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/create_key_labels.php b/kms/src/create_key_labels.php index 7e50de70bd..652168bbac 100644 --- a/kms/src/create_key_labels.php +++ b/kms/src/create_key_labels.php @@ -43,8 +43,7 @@ function create_key_labels( $key = (new CryptoKey()) ->setPurpose(CryptoKeyPurpose::ENCRYPT_DECRYPT) ->setVersionTemplate((new CryptoKeyVersionTemplate()) - ->setAlgorithm(CryptoKeyVersionAlgorithm::GOOGLE_SYMMETRIC_ENCRYPTION) - ) + ->setAlgorithm(CryptoKeyVersionAlgorithm::GOOGLE_SYMMETRIC_ENCRYPTION)) ->setLabels([ 'team' => 'alpha', 'cost_center' => 'cc1234', diff --git a/kms/src/create_key_mac.php b/kms/src/create_key_mac.php index f5f8344e59..dae05ee287 100644 --- a/kms/src/create_key_mac.php +++ b/kms/src/create_key_mac.php @@ -44,13 +44,11 @@ function create_key_mac( $key = (new CryptoKey()) ->setPurpose(CryptoKeyPurpose::MAC) ->setVersionTemplate((new CryptoKeyVersionTemplate()) - ->setAlgorithm(CryptoKeyVersionAlgorithm::HMAC_SHA256) - ) + ->setAlgorithm(CryptoKeyVersionAlgorithm::HMAC_SHA256)) // Optional: customize how long key versions should be kept before destroying. ->setDestroyScheduledDuration((new Duration()) - ->setSeconds(24 * 60 * 60) - ); + ->setSeconds(24 * 60 * 60)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/create_key_rotation_schedule.php b/kms/src/create_key_rotation_schedule.php index 9314797ea9..b2da2a6c0c 100644 --- a/kms/src/create_key_rotation_schedule.php +++ b/kms/src/create_key_rotation_schedule.php @@ -49,13 +49,11 @@ function create_key_rotation_schedule( // Rotate the key every 30 days. ->setRotationPeriod((new Duration()) - ->setSeconds(60 * 60 * 24 * 30) - ) + ->setSeconds(60 * 60 * 24 * 30)) // Start the first rotation in 24 hours. ->setNextRotationTime((new Timestamp()) - ->setSeconds(time() + 60 * 60 * 24) - ); + ->setSeconds(time() + 60 * 60 * 24)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/create_key_symmetric_encrypt_decrypt.php b/kms/src/create_key_symmetric_encrypt_decrypt.php index 3b3f2e3b9f..6941f3b8e6 100644 --- a/kms/src/create_key_symmetric_encrypt_decrypt.php +++ b/kms/src/create_key_symmetric_encrypt_decrypt.php @@ -43,8 +43,7 @@ function create_key_symmetric_encrypt_decrypt( $key = (new CryptoKey()) ->setPurpose(CryptoKeyPurpose::ENCRYPT_DECRYPT) ->setVersionTemplate((new CryptoKeyVersionTemplate()) - ->setAlgorithm(CryptoKeyVersionAlgorithm::GOOGLE_SYMMETRIC_ENCRYPTION) - ); + ->setAlgorithm(CryptoKeyVersionAlgorithm::GOOGLE_SYMMETRIC_ENCRYPTION)); // Call the API. $createCryptoKeyRequest = (new CreateCryptoKeyRequest()) diff --git a/kms/src/update_key_add_rotation.php b/kms/src/update_key_add_rotation.php index 9a668b4ba2..b934e0ce36 100644 --- a/kms/src/update_key_add_rotation.php +++ b/kms/src/update_key_add_rotation.php @@ -45,13 +45,11 @@ function update_key_add_rotation( // Rotate the key every 30 days. ->setRotationPeriod((new Duration()) - ->setSeconds(60 * 60 * 24 * 30) - ) + ->setSeconds(60 * 60 * 24 * 30)) // Start the first rotation in 24 hours. ->setNextRotationTime((new Timestamp()) - ->setSeconds(time() + 60 * 60 * 24) - ); + ->setSeconds(time() + 60 * 60 * 24)); // Create the field mask. $updateMask = (new FieldMask()) diff --git a/language/test/quickstartTest.php b/language/test/quickstartTest.php index 4e50c91f89..76f7e629de 100644 --- a/language/test/quickstartTest.php +++ b/language/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Language\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/logging/src/list_sinks.php b/logging/src/list_sinks.php index b3eb138b3e..e6dc7b602c 100644 --- a/logging/src/list_sinks.php +++ b/logging/src/list_sinks.php @@ -32,7 +32,8 @@ function list_sinks($projectId) foreach ($sinks as $sink) { /* @var $sink \Google\Cloud\Logging\Sink */ foreach ($sink->info() as $key => $value) { - printf('%s:%s' . PHP_EOL, + printf( + '%s:%s' . PHP_EOL, $key, is_string($value) ? $value : var_export($value, true) ); diff --git a/logging/test/quickstartTest.php b/logging/test/quickstartTest.php index 44ac33a84c..5264b3caae 100644 --- a/logging/test/quickstartTest.php +++ b/logging/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Logging\Tests; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/media/livestream/test/livestreamTest.php b/media/livestream/test/livestreamTest.php index 73a36c7969..c476368dd6 100644 --- a/media/livestream/test/livestreamTest.php +++ b/media/livestream/test/livestreamTest.php @@ -83,7 +83,12 @@ public static function setUpBeforeClass(): void public function testCreateInput() { self::$inputId = sprintf('%s-%s-%s', self::$inputIdPrefix, uniqid(), time()); - self::$inputName = sprintf('projects/%s/locations/%s/inputs/%s', self::$projectId, self::$location, self::$inputId); + self::$inputName = sprintf( + 'projects/%s/locations/%s/inputs/%s', + self::$projectId, + self::$location, + self::$inputId + ); $output = $this->runFunctionSnippet('create_input', [ self::$projectId, @@ -152,7 +157,12 @@ public function testCreateChannel() { // Create a test input for the channel self::$inputId = sprintf('%s-%s-%s', self::$inputIdPrefix, uniqid(), time()); - self::$inputName = sprintf('projects/%s/locations/%s/inputs/%s', self::$projectId, self::$location, self::$inputId); + self::$inputName = sprintf( + 'projects/%s/locations/%s/inputs/%s', + self::$projectId, + self::$location, + self::$inputId + ); $this->runFunctionSnippet('create_input', [ self::$projectId, @@ -161,7 +171,12 @@ public function testCreateChannel() ]); self::$channelId = sprintf('%s-%s-%s', self::$channelIdPrefix, uniqid(), time()); - self::$channelName = sprintf('projects/%s/locations/%s/channels/%s', self::$projectId, self::$location, self::$channelId); + self::$channelName = sprintf( + 'projects/%s/locations/%s/channels/%s', + self::$projectId, + self::$location, + self::$channelId + ); $output = $this->runFunctionSnippet('create_channel', [ self::$projectId, @@ -188,7 +203,12 @@ public function testUpdateChannel() { // Create a test input to update the channel self::$backupInputId = sprintf('%s-%s-%s', self::$inputIdPrefix, uniqid(), time()); - self::$backupInputName = sprintf('projects/%s/locations/%s/inputs/%s', self::$projectId, self::$location, self::$backupInputId); + self::$backupInputName = sprintf( + 'projects/%s/locations/%s/inputs/%s', + self::$projectId, + self::$location, + self::$backupInputId + ); $this->runFunctionSnippet('create_input', [ self::$projectId, @@ -269,7 +289,12 @@ public function testDeleteChannel() public function testCreateChannelWithBackupInput() { self::$channelId = sprintf('%s-%s-%s', self::$channelIdPrefix, uniqid(), time()); - self::$channelName = sprintf('projects/%s/locations/%s/channels/%s', self::$projectId, self::$location, self::$channelId); + self::$channelName = sprintf( + 'projects/%s/locations/%s/channels/%s', + self::$projectId, + self::$location, + self::$channelId + ); $output = $this->runFunctionSnippet('create_channel_with_backup_input', [ self::$projectId, @@ -312,7 +337,12 @@ public function testCreateChannelEvent() { // Create a test input for the channel self::$inputId = sprintf('%s-%s-%s', self::$inputIdPrefix, uniqid(), time()); - self::$inputName = sprintf('projects/%s/locations/%s/inputs/%s', self::$projectId, self::$location, self::$inputId); + self::$inputName = sprintf( + 'projects/%s/locations/%s/inputs/%s', + self::$projectId, + self::$location, + self::$inputId + ); $this->runFunctionSnippet('create_input', [ self::$projectId, @@ -322,7 +352,12 @@ public function testCreateChannelEvent() // Create a test channel for the event self::$channelId = sprintf('%s-%s-%s', self::$channelIdPrefix, uniqid(), time()); - self::$channelName = sprintf('projects/%s/locations/%s/channels/%s', self::$projectId, self::$location, self::$channelId); + self::$channelName = sprintf( + 'projects/%s/locations/%s/channels/%s', + self::$projectId, + self::$location, + self::$channelId + ); $this->runFunctionSnippet('create_channel', [ self::$projectId, @@ -339,7 +374,13 @@ public function testCreateChannelEvent() ]); self::$eventId = sprintf('%s-%s-%s', self::$eventIdPrefix, uniqid(), time()); - self::$eventName = sprintf('projects/%s/locations/%s/channels/%s/events/%s', self::$projectId, self::$location, self::$channelId, self::$eventId); + self::$eventName = sprintf( + 'projects/%s/locations/%s/channels/%s/events/%s', + self::$projectId, + self::$location, + self::$channelId, + self::$eventId + ); $output = $this->runFunctionSnippet('create_channel_event', [ self::$projectId, diff --git a/media/transcoder/src/create_job_with_concatenated_inputs.php b/media/transcoder/src/create_job_with_concatenated_inputs.php index 1434d7008a..10e5cb3035 100644 --- a/media/transcoder/src/create_job_with_concatenated_inputs.php +++ b/media/transcoder/src/create_job_with_concatenated_inputs.php @@ -50,8 +50,17 @@ * @param float $endTimeInput2 End time, in fractional seconds, relative to the second input video timeline. * @param string $outputUri Uri of the video output folder in the Cloud Storage bucket. */ -function create_job_with_concatenated_inputs($projectId, $location, $input1Uri, $startTimeInput1, $endTimeInput1, $input2Uri, $startTimeInput2, $endTimeInput2, $outputUri) -{ +function create_job_with_concatenated_inputs( + $projectId, + $location, + $input1Uri, + $startTimeInput1, + $endTimeInput1, + $input2Uri, + $startTimeInput2, + $endTimeInput2, + $outputUri +) { $startTimeInput1Sec = (int) floor(abs($startTimeInput1)); $startTimeInput1Nanos = (int) (1000000000 * bcsub((string) abs($startTimeInput1), (string) floor(abs($startTimeInput1)), 4)); $endTimeInput1Sec = (int) floor(abs($endTimeInput1)); diff --git a/media/transcoder/test/transcoderTest.php b/media/transcoder/test/transcoderTest.php index a69e799bd0..9154d94dcb 100644 --- a/media/transcoder/test/transcoderTest.php +++ b/media/transcoder/test/transcoderTest.php @@ -102,8 +102,14 @@ public static function setUpBeforeClass(): void self::$outputUriForTemplate = sprintf('gs://%s/test-output-template/', $bucketName); self::$outputUriForAnimatedOverlay = sprintf('gs://%s/test-output-animated-overlay/', $bucketName); self::$outputUriForStaticOverlay = sprintf('gs://%s/test-output-static-overlay/', $bucketName); - self::$outputUriForPeriodicImagesSpritesheet = sprintf('gs://%s/test-output-periodic-spritesheet/', $bucketName); - self::$outputUriForSetNumberImagesSpritesheet = sprintf('gs://%s/test-output-set-number-spritesheet/', $bucketName); + self::$outputUriForPeriodicImagesSpritesheet = sprintf( + 'gs://%s/test-output-periodic-spritesheet/', + $bucketName + ); + self::$outputUriForSetNumberImagesSpritesheet = sprintf( + 'gs://%s/test-output-set-number-spritesheet/', + $bucketName + ); self::$outputUriForConcat = sprintf('gs://%s/test-output-concat/', $bucketName); self::$jobIdRegex = sprintf('~projects/%s/locations/%s/jobs/~', self::$projectNumber, self::$location); @@ -131,7 +137,12 @@ public function assertJobStateSucceeded($jobId) public function testJobTemplate() { $jobTemplateId = sprintf('php-test-template-%s', time()); - $jobTemplateName = sprintf('projects/%s/locations/%s/jobTemplates/%s', self::$projectNumber, self::$location, $jobTemplateId); + $jobTemplateName = sprintf( + 'projects/%s/locations/%s/jobTemplates/%s', + self::$projectNumber, + self::$location, + $jobTemplateId + ); $output = $this->runFunctionSnippet('create_job_template', [ self::$projectId, diff --git a/media/videostitcher/test/videoStitcherTest.php b/media/videostitcher/test/videoStitcherTest.php index 8b671f2136..453dd35f13 100644 --- a/media/videostitcher/test/videoStitcherTest.php +++ b/media/videostitcher/test/videoStitcherTest.php @@ -80,7 +80,9 @@ class videoStitcherTest extends TestCase private static $inputBucketName = 'cloud-samples-data'; private static $inputVodFileName = '/media/hls-vod/manifest.m3u8'; private static $vodUri; - private static $vodAgTagUri = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator='; + private static $vodAgTagUri = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples' + . '&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap' + . '&unviewed_position_start=1&env=vp&impl=s&correlator='; private static $vodSessionId; private static $vodSessionName; @@ -91,7 +93,10 @@ class videoStitcherTest extends TestCase private static $inputLiveFileName = '/media/hls-live/manifest.m3u8'; private static $liveUri; - private static $liveAgTagUri = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator='; + private static $liveAgTagUri = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/' + . 'single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&' + . 'unviewed_position_start=1&env=vp&impl=s&correlator='; + private static $liveSessionId; private static $liveSessionName; private static $liveAdTagDetailId; @@ -107,11 +112,23 @@ public static function setUpBeforeClass(): void self::deleteOldLiveConfigs(); self::$slateUri = sprintf('https://storage.googleapis.com/%s%s', self::$bucket, self::$slateFileName); - self::$updatedSlateUri = sprintf('https://storage.googleapis.com/%s%s', self::$bucket, self::$updatedSlateFileName); + self::$updatedSlateUri = sprintf( + 'https://storage.googleapis.com/%s%s', + self::$bucket, + self::$updatedSlateFileName + ); - self::$vodUri = sprintf('https://storage.googleapis.com/%s%s', self::$inputBucketName, self::$inputVodFileName); + self::$vodUri = sprintf( + 'https://storage.googleapis.com/%s%s', + self::$inputBucketName, + self::$inputVodFileName + ); - self::$liveUri = sprintf('https://storage.googleapis.com/%s%s', self::$inputBucketName, self::$inputLiveFileName); + self::$liveUri = sprintf( + 'https://storage.googleapis.com/%s%s', + self::$inputBucketName, + self::$inputLiveFileName + ); } public function testCreateSlate() @@ -459,7 +476,11 @@ public function testGetVodSession() /** @depends testGetVodSession */ public function testListVodAdTagDetails() { - self::$vodAdTagDetailName = sprintf('/locations/%s/vodSessions/%s/vodAdTagDetails/', self::$location, self::$vodSessionId); + self::$vodAdTagDetailName = sprintf( + '/locations/%s/vodSessions/%s/vodAdTagDetails/', + self::$location, + self::$vodSessionId + ); $output = $this->runFunctionSnippet('list_vod_ad_tag_details', [ self::$projectId, self::$location, @@ -468,7 +489,12 @@ public function testListVodAdTagDetails() $this->assertStringContainsString(self::$vodAdTagDetailName, $output); self::$vodAdTagDetailId = explode('/', $output); self::$vodAdTagDetailId = trim(self::$vodAdTagDetailId[(count(self::$vodAdTagDetailId) - 1)]); - self::$vodAdTagDetailName = sprintf('/locations/%s/vodSessions/%s/vodAdTagDetails/%s', self::$location, self::$vodSessionId, self::$vodAdTagDetailId); + self::$vodAdTagDetailName = sprintf( + '/locations/%s/vodSessions/%s/vodAdTagDetails/%s', + self::$location, + self::$vodSessionId, + self::$vodAdTagDetailId + ); } /** @depends testListVodAdTagDetails */ @@ -486,7 +512,11 @@ public function testGetVodAdTagDetail() /** @depends testCreateVodSession */ public function testListVodStitchDetails() { - self::$vodStitchDetailName = sprintf('/locations/%s/vodSessions/%s/vodStitchDetails/', self::$location, self::$vodSessionId); + self::$vodStitchDetailName = sprintf( + '/locations/%s/vodSessions/%s/vodStitchDetails/', + self::$location, + self::$vodSessionId + ); $output = $this->runFunctionSnippet('list_vod_stitch_details', [ self::$projectId, self::$location, @@ -495,7 +525,12 @@ public function testListVodStitchDetails() $this->assertStringContainsString(self::$vodStitchDetailName, $output); self::$vodStitchDetailId = explode('/', $output); self::$vodStitchDetailId = trim(self::$vodStitchDetailId[(count(self::$vodStitchDetailId) - 1)]); - self::$vodStitchDetailName = sprintf('/locations/%s/vodSessions/%s/vodStitchDetails/%s', self::$location, self::$vodSessionId, self::$vodStitchDetailId); + self::$vodStitchDetailName = sprintf( + '/locations/%s/vodSessions/%s/vodStitchDetails/%s', + self::$location, + self::$vodSessionId, + self::$vodStitchDetailId + ); } /** @depends testListVodStitchDetails */ @@ -602,7 +637,11 @@ public function testListLiveAdTagDetails() $renditionsUri = sprintf('%s/%s', join('/', $tmp), $renditions); file_get_contents($renditionsUri); - self::$liveAdTagDetailName = sprintf('/locations/%s/liveSessions/%s/liveAdTagDetails/', self::$location, self::$liveSessionId); + self::$liveAdTagDetailName = sprintf( + '/locations/%s/liveSessions/%s/liveAdTagDetails/', + self::$location, + self::$liveSessionId + ); $output = $this->runFunctionSnippet('list_live_ad_tag_details', [ self::$projectId, self::$location, @@ -611,7 +650,12 @@ public function testListLiveAdTagDetails() $this->assertStringContainsString(self::$liveAdTagDetailName, $output); self::$liveAdTagDetailId = explode('/', $output); self::$liveAdTagDetailId = trim(self::$liveAdTagDetailId[(count(self::$liveAdTagDetailId) - 1)]); - self::$liveAdTagDetailName = sprintf('/locations/%s/liveSessions/%s/liveAdTagDetails/%s', self::$location, self::$liveSessionId, self::$liveAdTagDetailId); + self::$liveAdTagDetailName = sprintf( + '/locations/%s/liveSessions/%s/liveAdTagDetails/%s', + self::$location, + self::$liveSessionId, + self::$liveAdTagDetailId + ); } /** @depends testListLiveAdTagDetails */ diff --git a/monitoring/src/alert_create_policy.php b/monitoring/src/alert_create_policy.php index eced6b3afe..8657cbb99a 100644 --- a/monitoring/src/alert_create_policy.php +++ b/monitoring/src/alert_create_policy.php @@ -51,7 +51,11 @@ function alert_create_policy($projectId) $policy->setConditions([new Condition([ 'display_name' => 'condition-1', 'condition_threshold' => new MetricThreshold([ - 'filter' => 'resource.type = "gce_instance" AND metric.type = "compute.googleapis.com/instance/cpu/utilization"', + 'filter' => sprintf( + 'resource.type = "%s" AND metric.type = "%s"', + 'gce_instance', + 'compute.googleapis.com/instance/cpu/utilization' + ), 'duration' => new Duration(['seconds' => '60']), 'comparison' => ComparisonType::COMPARISON_LT, ]) diff --git a/monitoring/src/alert_enable_policies.php b/monitoring/src/alert_enable_policies.php index ca4ca20749..d314d2a540 100644 --- a/monitoring/src/alert_enable_policies.php +++ b/monitoring/src/alert_enable_policies.php @@ -51,7 +51,8 @@ function alert_enable_policies($projectId, $enable = true, $filter = null) foreach ($policies->iterateAllElements() as $policy) { $isEnabled = $policy->getEnabled()->getValue(); if ($enable == $isEnabled) { - printf('Policy %s is already %s' . PHP_EOL, + printf( + 'Policy %s is already %s' . PHP_EOL, $policy->getName(), $isEnabled ? 'enabled' : 'disabled' ); diff --git a/monitoring/src/get_descriptor.php b/monitoring/src/get_descriptor.php index b84dd0f146..7cb7a97418 100644 --- a/monitoring/src/get_descriptor.php +++ b/monitoring/src/get_descriptor.php @@ -55,10 +55,12 @@ function get_descriptor($projectId, $metricId) printf('Unit: ' . $descriptor->getUnit() . PHP_EOL); printf('Labels:' . PHP_EOL); foreach ($descriptor->getLabels() as $labels) { - printf(' %s (%s) - %s' . PHP_EOL, + printf( + ' %s (%s) - %s' . PHP_EOL, $labels->getKey(), $labels->getValueType(), - $labels->getDescription()); + $labels->getDescription() + ); } } // [END monitoring_get_descriptor] diff --git a/monitoring/src/get_resource.php b/monitoring/src/get_resource.php index f82558dcde..b892685770 100644 --- a/monitoring/src/get_resource.php +++ b/monitoring/src/get_resource.php @@ -53,10 +53,12 @@ function get_resource($projectId, $resourceType) printf('Description: %s' . PHP_EOL, $resource->getDescription()); printf('Labels:' . PHP_EOL); foreach ($resource->getLabels() as $labels) { - printf(' %s (%s) - %s' . PHP_EOL, + printf( + ' %s (%s) - %s' . PHP_EOL, $labels->getKey(), $labels->getValueType(), - $labels->getDescription()); + $labels->getDescription() + ); } } // [END monitoring_get_resource] diff --git a/phpcs-ruleset.xml b/phpcs-ruleset.xml new file mode 100644 index 0000000000..520d44338a --- /dev/null +++ b/phpcs-ruleset.xml @@ -0,0 +1,22 @@ + + + + + + + + **/test/*Test.php + + + compute/*-client/helloworld/app.php + + + **/test/* + index.php + + . + **/vendor/* + run/laravel + appengine + + diff --git a/pubsub/app/app.php b/pubsub/app/app.php index 8c1c489300..47d70f9c57 100644 --- a/pubsub/app/app.php +++ b/pubsub/app/app.php @@ -82,8 +82,7 @@ $app->post('/receive_message', function (Request $request, Response $response, $args) use ($container) { // pull the message from the post body $json = json_decode($request->getContent(), true); - if ( - !isset($json['message']['data']) + if (!isset($json['message']['data']) || !$message = base64_decode($json['message']['data']) ) { return new Response('', 400); diff --git a/pubsub/app/test/DeployAppEngineFlexTest.php b/pubsub/app/test/DeployAppEngineFlexTest.php index e1b7ddcaef..5c541bfd17 100644 --- a/pubsub/app/test/DeployAppEngineFlexTest.php +++ b/pubsub/app/test/DeployAppEngineFlexTest.php @@ -36,8 +36,11 @@ public function testIndex() { // Access the modules app top page. $resp = $this->client->get('/'); - $this->assertEquals('200', $resp->getStatusCode(), - 'top page status code'); + $this->assertEquals( + '200', + $resp->getStatusCode(), + 'top page status code' + ); } public function testSendMessage() @@ -48,17 +51,22 @@ public function testSendMessage() ] ]); - $this->assertEquals('204', $resp->getStatusCode(), - '/send_message status code'); + $this->assertEquals( + '204', + $resp->getStatusCode(), + '/send_message status code' + ); } public function testReceiveMessage() { $resp = $this->client->request('POST', '/receive_message', [ 'body' => json_encode(['message' => ['data' => 'Bye.']]), - ] + ]); + $this->assertEquals( + '200', + $resp->getStatusCode(), + '/receive_message status code' ); - $this->assertEquals('200', $resp->getStatusCode(), - '/receive_message status code'); } } diff --git a/pubsub/quickstart/test/quickstartTest.php b/pubsub/quickstart/test/quickstartTest.php index 92572d9b54..2c5392b7db 100644 --- a/pubsub/quickstart/test/quickstartTest.php +++ b/pubsub/quickstart/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\PubSub\Tests; + use PHPUnit\Framework\TestCase; class quickstartTest extends TestCase diff --git a/recaptcha/src/get_key.php b/recaptcha/src/get_key.php index 51b6edf151..c0c5acad87 100644 --- a/recaptcha/src/get_key.php +++ b/recaptcha/src/get_key.php @@ -52,8 +52,14 @@ function get_key(string $projectId, string $keyId): void // $key->getCreateTime() returns a Google\Protobuf\Timestamp object printf('Create time: %d' . PHP_EOL, $key->getCreateTime()->getSeconds()); printf('Web platform settings: %s' . PHP_EOL, $key->hasWebSettings() ? 'Yes' : 'No'); - printf('Allowed all domains: %s' . PHP_EOL, $key->hasWebSettings() && $webSettings->getAllowAllDomains() ? 'Yes' : 'No'); - printf('Integration Type: %s' . PHP_EOL, $key->hasWebSettings() ? IntegrationType::name($webSettings->getIntegrationType()) : 'N/A'); + printf( + 'Allowed all domains: %s' . PHP_EOL, + $key->hasWebSettings() && $webSettings->getAllowAllDomains() ? 'Yes' : 'No' + ); + printf( + 'Integration Type: %s' . PHP_EOL, + $key->hasWebSettings() ? IntegrationType::name($webSettings->getIntegrationType()) : 'N/A' + ); } catch (ApiException $e) { if ($e->getStatus() === 'NOT_FOUND') { printf('The key with Key ID: %s doesn\'t exist.' . PHP_EOL, $keyId); diff --git a/recaptcha/src/update_key.php b/recaptcha/src/update_key.php index 62481afcbf..9a49a91ad0 100644 --- a/recaptcha/src/update_key.php +++ b/recaptcha/src/update_key.php @@ -64,7 +64,7 @@ function update_key( $settings->setIntegrationType(IntegrationType::CHECKBOX); // Specify the possible challenge frequency and difficulty - // Read https://cloud.google.com/recaptcha-enterprise/docs/reference/rest/v1/projects.keys#challengesecuritypreference + // https://cloud.google.com/recaptcha-enterprise/docs/reference/rest/v1/projects.keys#challengesecuritypreference $settings->setChallengeSecurityPreference(ChallengeSecurityPreference::SECURITY); $key = new Key(); diff --git a/secretmanager/test/quickstartTest.php b/secretmanager/test/quickstartTest.php index 611f1169d7..9d379c6e84 100644 --- a/secretmanager/test/quickstartTest.php +++ b/secretmanager/test/quickstartTest.php @@ -17,6 +17,8 @@ declare(strict_types=1); +namespace Google\Cloud\Samples\SecretManager\Test; + use Google\ApiCore\ApiException as GaxApiException; use Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient; use Google\Cloud\SecretManager\V1\DeleteSecretRequest; diff --git a/servicedirectory/src/delete_endpoint.php b/servicedirectory/src/delete_endpoint.php index e6f14e486f..194f692b89 100644 --- a/servicedirectory/src/delete_endpoint.php +++ b/servicedirectory/src/delete_endpoint.php @@ -39,7 +39,13 @@ function delete_endpoint( $client = new RegistrationServiceClient(); // Run request. - $endpointName = RegistrationServiceClient::endpointName($projectId, $locationId, $namespaceId, $serviceId, $endpointId); + $endpointName = RegistrationServiceClient::endpointName( + $projectId, + $locationId, + $namespaceId, + $serviceId, + $endpointId + ); $endpoint = $client->deleteEndpoint($endpointName); // Print results. diff --git a/servicedirectory/test/quickstartTest.php b/servicedirectory/test/quickstartTest.php index 8f2e87711a..06d240e2a3 100644 --- a/servicedirectory/test/quickstartTest.php +++ b/servicedirectory/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Servicedirectory\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/spanner/src/create_backup.php b/spanner/src/create_backup.php index 10c4c58edc..13cf656d1c 100644 --- a/spanner/src/create_backup.php +++ b/spanner/src/create_backup.php @@ -81,7 +81,8 @@ function create_backup( basename($info->getName()), $info->getSizeBytes(), $info->getCreateTime()->getSeconds(), - $info->getVersionTime()->getSeconds()); + $info->getVersionTime()->getSeconds() + ); } // [END spanner_create_backup] diff --git a/spanner/src/create_client_with_query_options.php b/spanner/src/create_client_with_query_options.php index c8882697fd..3e0ad5b27b 100644 --- a/spanner/src/create_client_with_query_options.php +++ b/spanner/src/create_client_with_query_options.php @@ -57,8 +57,12 @@ function create_client_with_query_options(string $instanceId, string $databaseId ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['LastUpdateTime']); + printf( + 'VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['LastUpdateTime'] + ); } } // [END spanner_create_client_with_query_options] diff --git a/spanner/src/create_database.php b/spanner/src/create_database.php index 910c6273ef..6e0fe3a575 100644 --- a/spanner/src/create_database.php +++ b/spanner/src/create_database.php @@ -69,8 +69,11 @@ function create_database(string $projectId, string $instanceId, string $database print('Waiting for operation to complete...' . PHP_EOL); $operation->pollUntilComplete(); - printf('Created database %s on instance %s' . PHP_EOL, - $databaseId, $instanceId); + printf( + 'Created database %s on instance %s' . PHP_EOL, + $databaseId, + $instanceId + ); } // [END spanner_create_database] diff --git a/spanner/src/create_table_with_datatypes.php b/spanner/src/create_table_with_datatypes.php index dc73379b7c..c0e47a8671 100644 --- a/spanner/src/create_table_with_datatypes.php +++ b/spanner/src/create_table_with_datatypes.php @@ -63,8 +63,11 @@ function create_table_with_datatypes(string $projectId, string $instanceId, stri print('Waiting for operation to complete...' . PHP_EOL); $operation->pollUntilComplete(); - printf('Created Venues table in database %s on instance %s' . PHP_EOL, - $databaseId, $instanceId); + printf( + 'Created Venues table in database %s on instance %s' . PHP_EOL, + $databaseId, + $instanceId + ); } // [END spanner_create_table_with_datatypes] diff --git a/spanner/src/create_table_with_timestamp_column.php b/spanner/src/create_table_with_timestamp_column.php index 909f2f2788..56ebbec8da 100644 --- a/spanner/src/create_table_with_timestamp_column.php +++ b/spanner/src/create_table_with_timestamp_column.php @@ -60,8 +60,11 @@ function create_table_with_timestamp_column(string $projectId, string $instanceI print('Waiting for operation to complete...' . PHP_EOL); $operation->pollUntilComplete(); - printf('Created Performances table in database %s on instance %s' . PHP_EOL, - $databaseId, $instanceId); + printf( + 'Created Performances table in database %s on instance %s' . PHP_EOL, + $databaseId, + $instanceId + ); } // [END spanner_create_table_with_timestamp_column] diff --git a/spanner/src/delete_data_with_dml.php b/spanner/src/delete_data_with_dml.php index e2435a4329..42e70cea8b 100644 --- a/spanner/src/delete_data_with_dml.php +++ b/spanner/src/delete_data_with_dml.php @@ -41,7 +41,8 @@ function delete_data_with_dml(string $instanceId, string $databaseId): void $database->runTransaction(function (Transaction $t) { $rowCount = $t->executeUpdate( - "DELETE FROM Singers WHERE FirstName = 'Alice'"); + "DELETE FROM Singers WHERE FirstName = 'Alice'" + ); $t->commit(); printf('Deleted %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/dml_batch_update_request_priority.php b/spanner/src/dml_batch_update_request_priority.php index 9b366a8919..d9a81a0314 100644 --- a/spanner/src/dml_batch_update_request_priority.php +++ b/spanner/src/dml_batch_update_request_priority.php @@ -71,8 +71,10 @@ function dml_batch_update_request_priority(string $instanceId, string $databaseI ], array('priority' => $priority)); $t->commit(); $rowCounts = count($result->rowCounts()); - printf('Executed %s SQL statements using Batch DML with PRIORITY_LOW.' . PHP_EOL, - $rowCounts); + printf( + 'Executed %s SQL statements using Batch DML with PRIORITY_LOW.' . PHP_EOL, + $rowCounts + ); }); } // [END spanner_dml_batch_update_request_priority] diff --git a/spanner/src/insert_data_with_dml.php b/spanner/src/insert_data_with_dml.php index a272042671..efce3974e4 100644 --- a/spanner/src/insert_data_with_dml.php +++ b/spanner/src/insert_data_with_dml.php @@ -49,7 +49,8 @@ function insert_data_with_dml(string $instanceId, string $databaseId): void $database->runTransaction(function (Transaction $t) { $rowCount = $t->executeUpdate( 'INSERT Singers (SingerId, FirstName, LastName) ' - . " VALUES (10, 'Virginia', 'Watson')"); + . " VALUES (10, 'Virginia', 'Watson')" + ); $t->commit(); printf('Inserted %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/insert_data_with_timestamp_column.php b/spanner/src/insert_data_with_timestamp_column.php index 58f4ccedd9..19c7634ec0 100644 --- a/spanner/src/insert_data_with_timestamp_column.php +++ b/spanner/src/insert_data_with_timestamp_column.php @@ -47,9 +47,25 @@ function insert_data_with_timestamp_column(string $instanceId, string $databaseI $operation = $database->transaction(['singleUse' => true]) ->insertBatch('Performances', [ - ['SingerId' => 1, 'VenueId' => 4, 'EventDate' => '2017-10-05', 'Revenue' => 11000, 'LastUpdateTime' => $spanner->commitTimestamp()], - ['SingerId' => 1, 'VenueId' => 19, 'EventDate' => '2017-11-02', 'Revenue' => 15000, 'LastUpdateTime' => $spanner->commitTimestamp()], - ['SingerId' => 2, 'VenueId' => 42, 'EventDate' => '2017-12-23', 'Revenue' => 7000, 'LastUpdateTime' => $spanner->commitTimestamp()], + [ + 'SingerId' => 1, + 'VenueId' => 4, + 'EventDate' => '2017-10-05', + 'Revenue' => 11000, + 'LastUpdateTime' => $spanner->commitTimestamp(), + ], [ + 'SingerId' => 1, + 'VenueId' => 19, + 'EventDate' => '2017-11-02', + 'Revenue' => 15000, + 'LastUpdateTime' => $spanner->commitTimestamp(), + ], [ + 'SingerId' => 2, + 'VenueId' => 42, + 'EventDate' => '2017-12-23', + 'Revenue' => 7000, + 'LastUpdateTime' => $spanner->commitTimestamp(), + ], ]) ->commit(); diff --git a/spanner/src/pg_case_sensitivity.php b/spanner/src/pg_case_sensitivity.php index 1afedf35ec..c2e0c25406 100644 --- a/spanner/src/pg_case_sensitivity.php +++ b/spanner/src/pg_case_sensitivity.php @@ -62,8 +62,12 @@ function pg_case_sensitivity(string $projectId, string $instanceId, string $data print('Waiting for operation to complete...' . PHP_EOL); $operation->pollUntilComplete(); - printf('Created %s table in database %s on instance %s' . PHP_EOL, - $table, $databaseId, $instanceId); + printf( + 'Created %s table in database %s on instance %s' . PHP_EOL, + $tableName, + $databaseId, + $instanceId + ); } // [END spanner_postgresql_case_sensitivity] diff --git a/spanner/src/pg_information_schema.php b/spanner/src/pg_information_schema.php index 9f4762bfba..dc8ca2c0da 100644 --- a/spanner/src/pg_information_schema.php +++ b/spanner/src/pg_information_schema.php @@ -74,7 +74,8 @@ function pg_information_schema(string $projectId, string $instanceId, string $da user_defined_type_name FROM INFORMATION_SCHEMA.tables WHERE table_schema=\'public\' - '); + ' + ); printf('Details fetched.' . PHP_EOL); foreach ($results as $row) { diff --git a/spanner/src/pg_interleaved_table.php b/spanner/src/pg_interleaved_table.php index e384629d19..81ded0f0bc 100644 --- a/spanner/src/pg_interleaved_table.php +++ b/spanner/src/pg_interleaved_table.php @@ -36,8 +36,12 @@ * @param string $parentTable The parent table to create. Defaults to 'Singers' * @param string $childTable The child table to create. Defaults to 'Albums' */ -function pg_interleaved_table(string $projectId, string $instanceId, string $databaseId, string $parentTable = 'Singers', string $childTable = 'Albums'): void -{ +function pg_interleaved_table( + string $instanceId, + string $databaseId, + string $parentTable = 'Singers', + string $childTable = 'Albums' +): void { $databaseAdminClient = new DatabaseAdminClient(); $databaseName = DatabaseAdminClient::databaseName($projectId, $instanceId, $databaseId); diff --git a/spanner/src/pg_jsonb_query_parameter.php b/spanner/src/pg_jsonb_query_parameter.php index 05f270b785..41c752eb09 100644 --- a/spanner/src/pg_jsonb_query_parameter.php +++ b/spanner/src/pg_jsonb_query_parameter.php @@ -54,7 +54,8 @@ function pg_jsonb_query_parameter( 'types' => [ 'p1' => Database::TYPE_INT64 ] - ]); + ] + ); foreach ($results as $row) { printf('VenueId: %s, VenueDetails: %s' . PHP_EOL, $row['venueid'], $row['venuedetails']); diff --git a/spanner/src/pg_query_parameter.php b/spanner/src/pg_query_parameter.php index 80a9984909..97d2e31632 100644 --- a/spanner/src/pg_query_parameter.php +++ b/spanner/src/pg_query_parameter.php @@ -50,11 +50,16 @@ function pg_query_parameter(string $instanceId, string $databaseId): void 'parameters' => [ 'p1' => 'A%' ] - ] + ] ); foreach ($results as $row) { - printf('SingerId: %s, Firstname: %s, LastName: %s' . PHP_EOL, $row['singerid'], $row['firstname'], $row['lastname']); + printf( + 'SingerId: %s, Firstname: %s, LastName: %s' . PHP_EOL, + $row['singerid'], + $row['firstname'], + $row['lastname'] + ); } } // [END spanner_postgresql_query_parameter] diff --git a/spanner/src/query_data.php b/spanner/src/query_data.php index 91505376cf..bac4aaff1a 100644 --- a/spanner/src/query_data.php +++ b/spanner/src/query_data.php @@ -47,8 +47,12 @@ function query_data(string $instanceId, string $databaseId): void ); foreach ($results as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_query_data] diff --git a/spanner/src/query_data_with_array_of_struct.php b/spanner/src/query_data_with_array_of_struct.php index 8cbc8293f1..83c10a35e8 100644 --- a/spanner/src/query_data_with_array_of_struct.php +++ b/spanner/src/query_data_with_array_of_struct.php @@ -82,8 +82,10 @@ function query_data_with_array_of_struct(string $instanceId, string $databaseId) ] ); foreach ($results as $row) { - printf('SingerId: %s' . PHP_EOL, - $row['SingerId']); + printf( + 'SingerId: %s' . PHP_EOL, + $row['SingerId'] + ); } // [END spanner_query_data_with_array_of_struct] } diff --git a/spanner/src/query_data_with_array_parameter.php b/spanner/src/query_data_with_array_parameter.php index f813f2284e..0af2dae4f4 100644 --- a/spanner/src/query_data_with_array_parameter.php +++ b/spanner/src/query_data_with_array_parameter.php @@ -61,8 +61,12 @@ function query_data_with_array_parameter(string $instanceId, string $databaseId) ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, AvailableDate: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['AvailableDate']); + printf( + 'VenueId: %s, VenueName: %s, AvailableDate: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['AvailableDate'] + ); } } // [END spanner_query_with_array_parameter] diff --git a/spanner/src/query_data_with_bool_parameter.php b/spanner/src/query_data_with_bool_parameter.php index fbc8eafe59..44fbbc70ab 100644 --- a/spanner/src/query_data_with_bool_parameter.php +++ b/spanner/src/query_data_with_bool_parameter.php @@ -56,9 +56,12 @@ function query_data_with_bool_parameter(string $instanceId, string $databaseId): ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, OutdoorVenue: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], - $row['OutdoorVenue'] ? 'True' : 'False'); + printf( + 'VenueId: %s, VenueName: %s, OutdoorVenue: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['OutdoorVenue'] ? 'True' : 'False' + ); } } // [END spanner_query_with_bool_parameter] diff --git a/spanner/src/query_data_with_bytes_parameter.php b/spanner/src/query_data_with_bytes_parameter.php index d592c7efa5..19e2fd9874 100644 --- a/spanner/src/query_data_with_bytes_parameter.php +++ b/spanner/src/query_data_with_bytes_parameter.php @@ -59,8 +59,11 @@ function query_data_with_bytes_parameter(string $instanceId, string $databaseId) ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName']); + printf( + 'VenueId: %s, VenueName: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'] + ); } } // [END spanner_query_with_bytes_parameter] diff --git a/spanner/src/query_data_with_date_parameter.php b/spanner/src/query_data_with_date_parameter.php index 54c41eaf59..f071826c6a 100644 --- a/spanner/src/query_data_with_date_parameter.php +++ b/spanner/src/query_data_with_date_parameter.php @@ -56,8 +56,12 @@ function query_data_with_date_parameter(string $instanceId, string $databaseId): ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, LastContactDate: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['LastContactDate']); + printf( + 'VenueId: %s, VenueName: %s, LastContactDate: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['LastContactDate'] + ); } } // [END spanner_query_with_date_parameter] diff --git a/spanner/src/query_data_with_float_parameter.php b/spanner/src/query_data_with_float_parameter.php index 1c0b920208..c8fb0391f0 100644 --- a/spanner/src/query_data_with_float_parameter.php +++ b/spanner/src/query_data_with_float_parameter.php @@ -56,8 +56,12 @@ function query_data_with_float_parameter(string $instanceId, string $databaseId) ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, PopularityScore: %f' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['PopularityScore']); + printf( + 'VenueId: %s, VenueName: %s, PopularityScore: %f' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['PopularityScore'] + ); } } // [END spanner_query_with_float_parameter] diff --git a/spanner/src/query_data_with_index.php b/spanner/src/query_data_with_index.php index c5e781f3a9..aae65555e6 100644 --- a/spanner/src/query_data_with_index.php +++ b/spanner/src/query_data_with_index.php @@ -68,8 +68,12 @@ function query_data_with_index( ); foreach ($results as $row) { - printf('AlbumId: %s, AlbumTitle: %s, MarketingBudget: %d' . PHP_EOL, - $row['AlbumId'], $row['AlbumTitle'], $row['MarketingBudget']); + printf( + 'AlbumId: %s, AlbumTitle: %s, MarketingBudget: %d' . PHP_EOL, + $row['AlbumId'], + $row['AlbumTitle'], + $row['MarketingBudget'] + ); } } // [END spanner_query_data_with_index] diff --git a/spanner/src/query_data_with_int_parameter.php b/spanner/src/query_data_with_int_parameter.php index abef9b55f1..abe19a97df 100644 --- a/spanner/src/query_data_with_int_parameter.php +++ b/spanner/src/query_data_with_int_parameter.php @@ -56,8 +56,12 @@ function query_data_with_int_parameter(string $instanceId, string $databaseId): ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, Capacity: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['Capacity']); + printf( + 'VenueId: %s, VenueName: %s, Capacity: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['Capacity'] + ); } } // [END spanner_query_with_int_parameter] diff --git a/spanner/src/query_data_with_nested_struct_field.php b/spanner/src/query_data_with_nested_struct_field.php index a45297e0d8..4292ab0363 100644 --- a/spanner/src/query_data_with_nested_struct_field.php +++ b/spanner/src/query_data_with_nested_struct_field.php @@ -77,8 +77,11 @@ function query_data_with_nested_struct_field(string $instanceId, string $databas ] ); foreach ($results as $row) { - printf('SingerId: %s SongName: %s' . PHP_EOL, - $row['SingerId'], $row['SongName']); + printf( + 'SingerId: %s SongName: %s' . PHP_EOL, + $row['SingerId'], + $row['SongName'] + ); } } // [END spanner_field_access_on_nested_struct_parameters] diff --git a/spanner/src/query_data_with_new_column.php b/spanner/src/query_data_with_new_column.php index f8e505652b..be51fe0961 100644 --- a/spanner/src/query_data_with_new_column.php +++ b/spanner/src/query_data_with_new_column.php @@ -53,8 +53,12 @@ function query_data_with_new_column(string $instanceId, string $databaseId): voi ); foreach ($results as $row) { - printf('SingerId: %s, AlbumId: %s, MarketingBudget: %d' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['MarketingBudget']); + printf( + 'SingerId: %s, AlbumId: %s, MarketingBudget: %d' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['MarketingBudget'] + ); } } // [END spanner_query_data_with_new_column] diff --git a/spanner/src/query_data_with_numeric_parameter.php b/spanner/src/query_data_with_numeric_parameter.php index 0cea1ea8b8..eb766149a5 100644 --- a/spanner/src/query_data_with_numeric_parameter.php +++ b/spanner/src/query_data_with_numeric_parameter.php @@ -56,8 +56,11 @@ function query_data_with_numeric_parameter(string $instanceId, string $databaseI ); foreach ($results as $row) { - printf('VenueId: %s, Revenue: %s' . PHP_EOL, - $row['VenueId'], $row['Revenue']); + printf( + 'VenueId: %s, Revenue: %s' . PHP_EOL, + $row['VenueId'], + $row['Revenue'] + ); } } // [END spanner_query_with_numeric_parameter] diff --git a/spanner/src/query_data_with_parameter.php b/spanner/src/query_data_with_parameter.php index 47db1101e5..ba475c84fa 100644 --- a/spanner/src/query_data_with_parameter.php +++ b/spanner/src/query_data_with_parameter.php @@ -49,8 +49,12 @@ function query_data_with_parameter(string $instanceId, string $databaseId): void ); foreach ($results as $row) { - printf('SingerId: %s, FirstName: %s, LastName: %s' . PHP_EOL, - $row['SingerId'], $row['FirstName'], $row['LastName']); + printf( + 'SingerId: %s, FirstName: %s, LastName: %s' . PHP_EOL, + $row['SingerId'], + $row['FirstName'], + $row['LastName'] + ); } } // [END spanner_query_with_parameter] diff --git a/spanner/src/query_data_with_query_options.php b/spanner/src/query_data_with_query_options.php index 5af91ca298..3e901f8f4b 100644 --- a/spanner/src/query_data_with_query_options.php +++ b/spanner/src/query_data_with_query_options.php @@ -56,8 +56,12 @@ function query_data_with_query_options(string $instanceId, string $databaseId): ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['LastUpdateTime']); + printf( + 'VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['LastUpdateTime'] + ); } } // [END spanner_query_with_query_options] diff --git a/spanner/src/query_data_with_string_parameter.php b/spanner/src/query_data_with_string_parameter.php index 6442892c70..028c700cd1 100644 --- a/spanner/src/query_data_with_string_parameter.php +++ b/spanner/src/query_data_with_string_parameter.php @@ -56,8 +56,11 @@ function query_data_with_string_parameter(string $instanceId, string $databaseId ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName']); + printf( + 'VenueId: %s, VenueName: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'] + ); } } // [END spanner_query_with_string_parameter] diff --git a/spanner/src/query_data_with_struct.php b/spanner/src/query_data_with_struct.php index 6e3153f175..cc1c5a0278 100644 --- a/spanner/src/query_data_with_struct.php +++ b/spanner/src/query_data_with_struct.php @@ -68,8 +68,10 @@ function query_data_with_struct(string $instanceId, string $databaseId): void ] ); foreach ($results as $row) { - printf('SingerId: %s' . PHP_EOL, - $row['SingerId']); + printf( + 'SingerId: %s' . PHP_EOL, + $row['SingerId'] + ); } // [END spanner_query_data_with_struct] } diff --git a/spanner/src/query_data_with_struct_field.php b/spanner/src/query_data_with_struct_field.php index da2b7cb858..f06a8c152c 100644 --- a/spanner/src/query_data_with_struct_field.php +++ b/spanner/src/query_data_with_struct_field.php @@ -62,8 +62,10 @@ function query_data_with_struct_field(string $instanceId, string $databaseId): v ] ); foreach ($results as $row) { - printf('SingerId: %s' . PHP_EOL, - $row['SingerId']); + printf( + 'SingerId: %s' . PHP_EOL, + $row['SingerId'] + ); } } // [END spanner_field_access_on_struct_parameters] diff --git a/spanner/src/query_data_with_timestamp_column.php b/spanner/src/query_data_with_timestamp_column.php index 6b0fac0392..dc9e7d7d76 100644 --- a/spanner/src/query_data_with_timestamp_column.php +++ b/spanner/src/query_data_with_timestamp_column.php @@ -39,7 +39,7 @@ * add the column by running the `add_timestamp_column` sample or by running * this DDL statement against your database: * - * ALTER TABLE Albums ADD COLUMN LastUpdateTime TIMESTAMP OPTIONS (allow_commit_timestamp=true) + * ALTER TABLE Albums ADD COLUMN LastUpdateTime TIMESTAMP OPTIONS (allow_commit_timestamp=true) * * Example: * ``` @@ -67,8 +67,13 @@ function query_data_with_timestamp_column(string $instanceId, string $databaseId if ($row['LastUpdateTime'] == null) { $row['LastUpdateTime'] = 'NULL'; } - printf('SingerId: %s, AlbumId: %s, MarketingBudget: %s, LastUpdateTime: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['MarketingBudget'], $row['LastUpdateTime']); + printf( + 'SingerId: %s, AlbumId: %s, MarketingBudget: %s, LastUpdateTime: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['MarketingBudget'], + $row['LastUpdateTime'] + ); } } // [END spanner_query_data_with_timestamp_column] diff --git a/spanner/src/query_data_with_timestamp_parameter.php b/spanner/src/query_data_with_timestamp_parameter.php index c4ad8c7ed5..9258f5cbfc 100644 --- a/spanner/src/query_data_with_timestamp_parameter.php +++ b/spanner/src/query_data_with_timestamp_parameter.php @@ -56,8 +56,12 @@ function query_data_with_timestamp_parameter(string $instanceId, string $databas ); foreach ($results as $row) { - printf('VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, - $row['VenueId'], $row['VenueName'], $row['LastUpdateTime']); + printf( + 'VenueId: %s, VenueName: %s, LastUpdateTime: %s' . PHP_EOL, + $row['VenueId'], + $row['VenueName'], + $row['LastUpdateTime'] + ); } } // [END spanner_query_with_timestamp_parameter] diff --git a/spanner/src/read_data.php b/spanner/src/read_data.php index 514cc12c08..c85aa1fcc2 100644 --- a/spanner/src/read_data.php +++ b/spanner/src/read_data.php @@ -50,8 +50,12 @@ function read_data(string $instanceId, string $databaseId): void ); foreach ($results->rows() as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_read_data] diff --git a/spanner/src/read_data_with_database_role.php b/spanner/src/read_data_with_database_role.php index 2b86d288e7..9d19e7d3d4 100644 --- a/spanner/src/read_data_with_database_role.php +++ b/spanner/src/read_data_with_database_role.php @@ -45,7 +45,12 @@ function read_data_with_database_role(string $instanceId, string $databaseId): v $results = $database->execute('SELECT * FROM Singers'); foreach ($results as $row) { - printf('SingerId: %s, Firstname: %s, LastName: %s' . PHP_EOL, $row['SingerId'], $row['FirstName'], $row['LastName']); + printf( + 'SingerId: %s, Firstname: %s, LastName: %s' . PHP_EOL, + $row['SingerId'], + $row['FirstName'], + $row['LastName'] + ); } } // [END spanner_read_data_with_database_role] diff --git a/spanner/src/read_data_with_index.php b/spanner/src/read_data_with_index.php index 366cb6f1a5..977906898f 100644 --- a/spanner/src/read_data_with_index.php +++ b/spanner/src/read_data_with_index.php @@ -58,8 +58,11 @@ function read_data_with_index(string $instanceId, string $databaseId): void ); foreach ($results->rows() as $row) { - printf('AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['AlbumId'], $row['AlbumTitle']); + printf( + 'AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_read_data_with_index] diff --git a/spanner/src/read_data_with_storing_index.php b/spanner/src/read_data_with_storing_index.php index b45116f512..5d4991ff48 100644 --- a/spanner/src/read_data_with_storing_index.php +++ b/spanner/src/read_data_with_storing_index.php @@ -64,8 +64,12 @@ function read_data_with_storing_index(string $instanceId, string $databaseId): v ); foreach ($results->rows() as $row) { - printf('AlbumId: %s, AlbumTitle: %s, MarketingBudget: %d' . PHP_EOL, - $row['AlbumId'], $row['AlbumTitle'], $row['MarketingBudget']); + printf( + 'AlbumId: %s, AlbumTitle: %s, MarketingBudget: %d' . PHP_EOL, + $row['AlbumId'], + $row['AlbumTitle'], + $row['MarketingBudget'] + ); } } // [END spanner_read_data_with_storing_index] diff --git a/spanner/src/read_only_transaction.php b/spanner/src/read_only_transaction.php index 1fb603e25f..a1ebccc55f 100644 --- a/spanner/src/read_only_transaction.php +++ b/spanner/src/read_only_transaction.php @@ -51,8 +51,12 @@ function read_only_transaction(string $instanceId, string $databaseId): void ); print('Results from the first read:' . PHP_EOL); foreach ($results as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } // Perform another read using the `read` method. Even if the data @@ -67,8 +71,12 @@ function read_only_transaction(string $instanceId, string $databaseId): void print('Results from the second read:' . PHP_EOL); foreach ($results->rows() as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_read_only_transaction] diff --git a/spanner/src/read_stale_data.php b/spanner/src/read_stale_data.php index f06695410c..4f51352b2a 100644 --- a/spanner/src/read_stale_data.php +++ b/spanner/src/read_stale_data.php @@ -53,8 +53,12 @@ function read_stale_data(string $instanceId, string $databaseId): void ); foreach ($results->rows() as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_read_stale_data] diff --git a/spanner/src/set_request_tag.php b/spanner/src/set_request_tag.php index 85d6b35e88..64d4c599bb 100644 --- a/spanner/src/set_request_tag.php +++ b/spanner/src/set_request_tag.php @@ -52,8 +52,12 @@ function set_request_tag(string $instanceId, string $databaseId): void ] ); foreach ($results as $row) { - printf('SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, - $row['SingerId'], $row['AlbumId'], $row['AlbumTitle']); + printf( + 'SingerId: %s, AlbumId: %s, AlbumTitle: %s' . PHP_EOL, + $row['SingerId'], + $row['AlbumId'], + $row['AlbumTitle'] + ); } } // [END spanner_set_request_tag] diff --git a/spanner/src/update_data_with_batch_dml.php b/spanner/src/update_data_with_batch_dml.php index 86d9ec9396..24a60a8d01 100644 --- a/spanner/src/update_data_with_batch_dml.php +++ b/spanner/src/update_data_with_batch_dml.php @@ -65,8 +65,10 @@ function update_data_with_batch_dml(string $instanceId, string $databaseId): voi ]); $t->commit(); $rowCounts = count($result->rowCounts()); - printf('Executed %s SQL statements using Batch DML.' . PHP_EOL, - $rowCounts); + printf( + 'Executed %s SQL statements using Batch DML.' . PHP_EOL, + $rowCounts + ); }); } // [END spanner_dml_batch_update] diff --git a/spanner/src/update_data_with_dml.php b/spanner/src/update_data_with_dml.php index 7658f74172..294cddc4f2 100644 --- a/spanner/src/update_data_with_dml.php +++ b/spanner/src/update_data_with_dml.php @@ -54,7 +54,8 @@ function update_data_with_dml(string $instanceId, string $databaseId): void $rowCount = $t->executeUpdate( 'UPDATE Albums ' . 'SET MarketingBudget = MarketingBudget * 2 ' - . 'WHERE SingerId = 1 and AlbumId = 1'); + . 'WHERE SingerId = 1 and AlbumId = 1' + ); $t->commit(); printf('Updated %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/update_data_with_dml_structs.php b/spanner/src/update_data_with_dml_structs.php index 139933c2ea..588221550b 100644 --- a/spanner/src/update_data_with_dml_structs.php +++ b/spanner/src/update_data_with_dml_structs.php @@ -68,7 +68,8 @@ function update_data_with_dml_structs(string $instanceId, string $databaseId): v 'types' => [ 'name' => $nameType ] - ]); + ] + ); $t->commit(); printf('Updated %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/update_data_with_dml_timestamp.php b/spanner/src/update_data_with_dml_timestamp.php index 12a5532b5a..3ed283d470 100644 --- a/spanner/src/update_data_with_dml_timestamp.php +++ b/spanner/src/update_data_with_dml_timestamp.php @@ -49,7 +49,8 @@ function update_data_with_dml_timestamp(string $instanceId, string $databaseId): $database->runTransaction(function (Transaction $t) { $rowCount = $t->executeUpdate( 'UPDATE Albums ' - . 'SET LastUpdateTime = PENDING_COMMIT_TIMESTAMP() WHERE SingerId = 1'); + . 'SET LastUpdateTime = PENDING_COMMIT_TIMESTAMP() WHERE SingerId = 1' + ); $t->commit(); printf('Updated %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/update_data_with_timestamp_column.php b/spanner/src/update_data_with_timestamp_column.php index c4b1b585c6..a7d1e40466 100644 --- a/spanner/src/update_data_with_timestamp_column.php +++ b/spanner/src/update_data_with_timestamp_column.php @@ -51,8 +51,17 @@ function update_data_with_timestamp_column(string $instanceId, string $databaseI $operation = $database->transaction(['singleUse' => true]) ->updateBatch('Albums', [ - ['SingerId' => 1, 'AlbumId' => 1, 'MarketingBudget' => 1000000, 'LastUpdateTime' => $spanner->commitTimestamp()], - ['SingerId' => 2, 'AlbumId' => 2, 'MarketingBudget' => 750000, 'LastUpdateTime' => $spanner->commitTimestamp()], + [ + 'SingerId' => 1, + 'AlbumId' => 1, + 'MarketingBudget' => 1000000, + 'LastUpdateTime' => $spanner->commitTimestamp() + ], [ + 'SingerId' => 2, + 'AlbumId' => 2, + 'MarketingBudget' => 750000, + 'LastUpdateTime' => $spanner->commitTimestamp() + ], ]) ->commit(); diff --git a/spanner/src/write_data_with_dml.php b/spanner/src/write_data_with_dml.php index 88ede3ed04..a1e374b9f2 100644 --- a/spanner/src/write_data_with_dml.php +++ b/spanner/src/write_data_with_dml.php @@ -52,7 +52,8 @@ function write_data_with_dml(string $instanceId, string $databaseId): void . "(12, 'Melissa', 'Garcia'), " . "(13, 'Russell', 'Morales'), " . "(14, 'Jacqueline', 'Long'), " - . "(15, 'Dylan', 'Shaw')"); + . "(15, 'Dylan', 'Shaw')" + ); $t->commit(); printf('Inserted %d row(s).' . PHP_EOL, $rowCount); }); diff --git a/spanner/src/write_read_with_dml.php b/spanner/src/write_read_with_dml.php index 28ad05e34e..d64303051e 100644 --- a/spanner/src/write_read_with_dml.php +++ b/spanner/src/write_read_with_dml.php @@ -49,7 +49,8 @@ function write_read_with_dml(string $instanceId, string $databaseId): void $database->runTransaction(function (Transaction $t) { $rowCount = $t->executeUpdate( 'INSERT Singers (SingerId, FirstName, LastName) ' - . " VALUES (11, 'Timothy', 'Campbell')"); + . " VALUES (11, 'Timothy', 'Campbell')" + ); printf('Inserted %d row(s).' . PHP_EOL, $rowCount); diff --git a/spanner/test/spannerBackupTest.php b/spanner/test/spannerBackupTest.php index 5e738ff8f8..dc24fb0bc0 100644 --- a/spanner/test/spannerBackupTest.php +++ b/spanner/test/spannerBackupTest.php @@ -90,7 +90,7 @@ public static function setUpBeforeClass(): void self::$instance = $spanner->instance(self::$instanceId); self::$kmsKeyName = - 'projects/' . self::$projectId . '/locations/us-central1/keyRings/spanner-test-keyring/cryptoKeys/spanner-test-cmek'; + 'projects/' . self::$projectId . '/locations/us-central1/keyRings/spanner-test-keyring/cryptoKeys/spanner-test-cmek'; } public function testCreateDatabaseWithVersionRetentionPeriod() diff --git a/spanner/test/spannerPgTest.php b/spanner/test/spannerPgTest.php index 125ca99fe6..7397ea821a 100644 --- a/spanner/test/spannerPgTest.php +++ b/spanner/test/spannerPgTest.php @@ -101,7 +101,10 @@ public function testFunctions() $output = $this->runFunctionSnippet('pg_functions'); self::$lastUpdateDataTimestamp = time(); - $this->assertStringContainsString('1284352323 seconds after epoch is 2010-09-13T04:32:03.000000Z', $output); + $this->assertStringContainsString( + '1284352323 seconds after epoch is 2010-09-13T04:32:03.000000Z', + $output + ); } /* @@ -189,8 +192,7 @@ public function testPartitionedDml() $db->runTransaction(function (Transaction $t) { $t->executeUpdate( - 'INSERT INTO users (id, name, active)' - . ' VALUES ($1, $2, $3), ($4, $5, $6)', + 'INSERT INTO users (id, name, active) VALUES ($1, $2, $3), ($4, $5, $6)', [ 'parameters' => [ 'p1' => 1, @@ -275,7 +277,10 @@ public function testJsonbAddColumn() ]); self::$lastUpdateDataTimestamp = time(); - $this->assertStringContainsString(sprintf('Added column VenueDetails on table %s.', self::$jsonbTable), $output); + $this->assertStringContainsString( + sprintf('Added column VenueDetails on table %s.', self::$jsonbTable), + $output + ); } /** diff --git a/spanner/test/spannerTest.php b/spanner/test/spannerTest.php index ffaa6d9744..3a933b1514 100644 --- a/spanner/test/spannerTest.php +++ b/spanner/test/spannerTest.php @@ -127,8 +127,10 @@ public static function setUpBeforeClass(): void self::$encryptedDatabaseId = 'en-test-' . time() . rand(); self::$backupId = 'backup-' . self::$databaseId; self::$instance = $spanner->instance(self::$instanceId); - self::$kmsKeyName = - 'projects/' . self::$projectId . '/locations/us-central1/keyRings/spanner-test-keyring/cryptoKeys/spanner-test-cmek'; + self::$kmsKeyName = sprintf( + 'projects/%s/locations/us-central1/keyRings/spanner-test-keyring/cryptoKeys/spanner-test-cmek', + self::$projectId + ); self::$lowCostInstance = $spanner->instance(self::$lowCostInstanceId); self::$multiInstanceId = 'kokoro-multi-instance'; @@ -169,7 +171,10 @@ public function testCreateInstanceConfig() self::$projectId, self::$customInstanceConfigId, self::$baseConfigId ]); - $this->assertStringContainsString(sprintf('Created instance configuration %s', self::$customInstanceConfigId), $output); + $this->assertStringContainsString( + sprintf('Created instance configuration %s', self::$customInstanceConfigId), + $output + ); } public function testCreateInstanceWithAutoscalingConfig() @@ -193,7 +198,10 @@ public function testUpdateInstanceConfig() self::$customInstanceConfigId ]); - $this->assertStringContainsString(sprintf('Updated instance configuration %s', self::$customInstanceConfigId), $output); + $this->assertStringContainsString( + sprintf('Updated instance configuration %s', self::$customInstanceConfigId), + $output + ); } /** @@ -205,7 +213,10 @@ public function testDeleteInstanceConfig() self::$projectId, self::$customInstanceConfigId ]); - $this->assertStringContainsString(sprintf('Deleted instance configuration %s', self::$customInstanceConfigId), $output); + $this->assertStringContainsString( + sprintf('Deleted instance configuration %s', self::$customInstanceConfigId), + $output + ); } /** @@ -224,7 +235,8 @@ public function testListInstanceConfigOperations() self::$customInstanceConfigId, 'type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata' ), - $output); + $output + ); $this->assertStringContainsString( sprintf( @@ -233,7 +245,8 @@ public function testListInstanceConfigOperations() self::$customInstanceConfigId, 'type.googleapis.com/google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata' ), - $output); + $output + ); } /** @@ -399,7 +412,10 @@ public function testReadWriteTransaction() { $this->runFunctionSnippet('update_data'); $output = $this->runFunctionSnippet('read_write_transaction'); - $this->assertStringContainsString('Setting first album\'s budget to 300000 and the second album\'s budget to 300000', $output); + $this->assertStringContainsString( + 'Setting first album\'s budget to 300000 and the second album\'s budget to 300000', + $output + ); $this->assertStringContainsString('Transaction complete.', $output); } @@ -535,12 +551,12 @@ public function testUpdateDataTimestamp() */ public function testQueryDataTimestamp() { - $output = $this->runFunctionSnippet('query_data_with_timestamp_column'); - $this->assertStringContainsString('SingerId: 1, AlbumId: 1, MarketingBudget: 1000000, LastUpdateTime: 20', $output); - $this->assertStringContainsString('SingerId: 2, AlbumId: 2, MarketingBudget: 750000, LastUpdateTime: 20', $output); - $this->assertStringContainsString('SingerId: 1, AlbumId: 2, MarketingBudget: NULL, LastUpdateTime: NULL', $output); - $this->assertStringContainsString('SingerId: 2, AlbumId: 1, MarketingBudget: NULL, LastUpdateTime: NULL', $output); - $this->assertStringContainsString('SingerId: 2, AlbumId: 3, MarketingBudget: NULL, LastUpdateTime: NULL', $output); + $o = $this->runFunctionSnippet('query_data_with_timestamp_column'); + $this->assertStringContainsString('SingerId: 1, AlbumId: 1, MarketingBudget: 1000000, LastUpdateTime: 20', $o); + $this->assertStringContainsString('SingerId: 2, AlbumId: 2, MarketingBudget: 750000, LastUpdateTime: 20', $o); + $this->assertStringContainsString('SingerId: 1, AlbumId: 2, MarketingBudget: NULL, LastUpdateTime: NULL', $o); + $this->assertStringContainsString('SingerId: 2, AlbumId: 1, MarketingBudget: NULL, LastUpdateTime: NULL', $o); + $this->assertStringContainsString('SingerId: 2, AlbumId: 3, MarketingBudget: NULL, LastUpdateTime: NULL', $o); } /** diff --git a/speech/src/transcribe_async_words.php b/speech/src/transcribe_async_words.php index 0e7f12c0d3..e4e3861efc 100644 --- a/speech/src/transcribe_async_words.php +++ b/speech/src/transcribe_async_words.php @@ -78,10 +78,12 @@ function transcribe_async_words(string $audioFile) foreach ($mostLikely->getWords() as $wordInfo) { $startTime = $wordInfo->getStartTime(); $endTime = $wordInfo->getEndTime(); - printf(' Word: %s (start: %s, end: %s)' . PHP_EOL, + printf( + ' Word: %s (start: %s, end: %s)' . PHP_EOL, $wordInfo->getWord(), $startTime->serializeToJsonString(), - $endTime->serializeToJsonString()); + $endTime->serializeToJsonString() + ); } } } else { diff --git a/speech/test/quickstartTest.php b/speech/test/quickstartTest.php index d958182ff9..c39c682ae9 100644 --- a/speech/test/quickstartTest.php +++ b/speech/test/quickstartTest.php @@ -14,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +namespace Google\Cloud\Samples\Speech\Test; + use PHPUnit\Framework\TestCase; use Google\Cloud\TestUtils\TestTrait; diff --git a/storage/src/add_bucket_conditional_iam_binding.php b/storage/src/add_bucket_conditional_iam_binding.php index 30429e6131..260ee09390 100644 --- a/storage/src/add_bucket_conditional_iam_binding.php +++ b/storage/src/add_bucket_conditional_iam_binding.php @@ -44,8 +44,14 @@ * To see how to express a condition in CEL, visit: * @see https://cloud.google.com/storage/docs/access-control/iam#conditions. */ -function add_bucket_conditional_iam_binding(string $bucketName, string $role, array $members, string $title, string $description, string $expression): void -{ +function add_bucket_conditional_iam_binding( + string $bucketName, + string $role, + array $members, + string $title, + string $description, + string $expression +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/compose_file.php b/storage/src/compose_file.php index c355f2d584..c0b0ebee7c 100644 --- a/storage/src/compose_file.php +++ b/storage/src/compose_file.php @@ -38,8 +38,12 @@ * @param string $targetObjectName The name of the object to be created. * (e.g. 'composed-my-object-1-my-object-2') */ -function compose_file(string $bucketName, string $firstObjectName, string $secondObjectName, string $targetObjectName): void -{ +function compose_file( + string $bucketName, + string $firstObjectName, + string $secondObjectName, + string $targetObjectName +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/copy_file_archived_generation.php b/storage/src/copy_file_archived_generation.php index 8cac77f420..4b98b074f0 100644 --- a/storage/src/copy_file_archived_generation.php +++ b/storage/src/copy_file_archived_generation.php @@ -38,8 +38,12 @@ * @param string $newObjectName The name of the target object. * (e.g. 'my-object-1579287380533984') */ -function copy_file_archived_generation(string $bucketName, string $objectToCopy, string $generationToCopy, string $newObjectName): void -{ +function copy_file_archived_generation( + string $bucketName, + string $objectToCopy, + string $generationToCopy, + string $newObjectName +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/copy_object.php b/storage/src/copy_object.php index d4baf7e852..a9ffb8be23 100644 --- a/storage/src/copy_object.php +++ b/storage/src/copy_object.php @@ -44,8 +44,13 @@ function copy_object(string $bucketName, string $objectName, string $newBucketNa $bucket = $storage->bucket($bucketName); $object = $bucket->object($objectName); $object->copy($newBucketName, ['name' => $newObjectName]); - printf('Copied gs://%s/%s to gs://%s/%s' . PHP_EOL, - $bucketName, $objectName, $newBucketName, $newObjectName); + printf( + 'Copied gs://%s/%s to gs://%s/%s' . PHP_EOL, + $bucketName, + $objectName, + $newBucketName, + $newObjectName + ); } # [END storage_copy_file] diff --git a/storage/src/cors_configuration.php b/storage/src/cors_configuration.php index 008c90d99e..eb483b304d 100644 --- a/storage/src/cors_configuration.php +++ b/storage/src/cors_configuration.php @@ -40,8 +40,13 @@ * (e.g. 3600) * requests before it must repeat preflighted requests. */ -function cors_configuration(string $bucketName, string $method, string $origin, string $responseHeader, int $maxAgeSeconds): void -{ +function cors_configuration( + string $bucketName, + string $method, + string $origin, + string $responseHeader, + int $maxAgeSeconds +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/define_bucket_website_configuration.php b/storage/src/define_bucket_website_configuration.php index 781fa96966..421688401a 100644 --- a/storage/src/define_bucket_website_configuration.php +++ b/storage/src/define_bucket_website_configuration.php @@ -38,8 +38,11 @@ * (e.g. '404.html') * as the 404 Not Found page. */ -function define_bucket_website_configuration(string $bucketName, string $indexPageObject, string $notFoundPageObject): void -{ +function define_bucket_website_configuration( + string $bucketName, + string $indexPageObject, + string $notFoundPageObject +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/download_encrypted_object.php b/storage/src/download_encrypted_object.php index 56f8056024..3179c1731d 100644 --- a/storage/src/download_encrypted_object.php +++ b/storage/src/download_encrypted_object.php @@ -39,16 +39,24 @@ * (e.g. 'TIbv/fjexq+VmtXzAlc63J4z5kFmWJ6NdAPQulQBT7g=') * be the same key originally used to encrypt the object. */ -function download_encrypted_object(string $bucketName, string $objectName, string $destination, string $base64EncryptionKey): void -{ +function download_encrypted_object( + string $bucketName, + string $objectName, + string $destination, + string $base64EncryptionKey +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); $object = $bucket->object($objectName); $object->downloadToFile($destination, [ 'encryptionKey' => $base64EncryptionKey, ]); - printf('Encrypted object gs://%s/%s downloaded to %s' . PHP_EOL, - $bucketName, $objectName, basename($destination)); + printf( + 'Encrypted object gs://%s/%s downloaded to %s' . PHP_EOL, + $bucketName, + $objectName, + basename($destination) + ); } # [END storage_download_encrypted_file] diff --git a/storage/src/download_file_requester_pays.php b/storage/src/download_file_requester_pays.php index e55c93f11e..f0ded6c5ea 100644 --- a/storage/src/download_file_requester_pays.php +++ b/storage/src/download_file_requester_pays.php @@ -38,8 +38,12 @@ * @param string $destination The local destination to save the object. * (e.g. '/path/to/your/file') */ -function download_file_requester_pays(string $projectId, string $bucketName, string $objectName, string $destination): void -{ +function download_file_requester_pays( + string $projectId, + string $bucketName, + string $objectName, + string $destination +): void { $storage = new StorageClient([ 'projectId' => $projectId ]); @@ -47,8 +51,12 @@ function download_file_requester_pays(string $projectId, string $bucketName, str $bucket = $storage->bucket($bucketName, $userProject); $object = $bucket->object($objectName); $object->downloadToFile($destination); - printf('Downloaded gs://%s/%s to %s using requester-pays requests.' . PHP_EOL, - $bucketName, $objectName, basename($destination)); + printf( + 'Downloaded gs://%s/%s to %s using requester-pays requests.' . PHP_EOL, + $bucketName, + $objectName, + basename($destination) + ); } # [END storage_download_file_requester_pays] diff --git a/storage/src/enable_default_kms_key.php b/storage/src/enable_default_kms_key.php index 6af686ab39..7e611c8ca5 100644 --- a/storage/src/enable_default_kms_key.php +++ b/storage/src/enable_default_kms_key.php @@ -44,9 +44,11 @@ function enable_default_kms_key(string $bucketName, string $kmsKeyName): void 'defaultKmsKeyName' => $kmsKeyName ] ]); - printf('Default KMS key for %s was set to %s' . PHP_EOL, + printf( + 'Default KMS key for %s was set to %s' . PHP_EOL, $bucketName, - $bucket->info()['encryption']['defaultKmsKeyName']); + $bucket->info()['encryption']['defaultKmsKeyName'] + ); } # [END storage_set_bucket_default_kms_key] diff --git a/storage/src/get_bucket_autoclass.php b/storage/src/get_bucket_autoclass.php index 89a869615f..0d75b8867f 100644 --- a/storage/src/get_bucket_autoclass.php +++ b/storage/src/get_bucket_autoclass.php @@ -39,11 +39,13 @@ function get_bucket_autoclass(string $bucketName): void $info = $bucket->info(); if (isset($info['autoclass'])) { - printf('Bucket %s has autoclass enabled: %s' . PHP_EOL, + printf( + 'Bucket %s has autoclass enabled: %s' . PHP_EOL, $bucketName, $info['autoclass']['enabled'] ); - printf('Bucket %s has autoclass toggle time: %s' . PHP_EOL, + printf( + 'Bucket %s has autoclass toggle time: %s' . PHP_EOL, $bucketName, $info['autoclass']['toggleTime'] ); diff --git a/storage/src/move_object.php b/storage/src/move_object.php index 0145a4849a..8caf5cf191 100644 --- a/storage/src/move_object.php +++ b/storage/src/move_object.php @@ -45,11 +45,13 @@ function move_object(string $bucketName, string $objectName, string $newBucketNa $object = $bucket->object($objectName); $object->copy($newBucketName, ['name' => $newObjectName]); $object->delete(); - printf('Moved gs://%s/%s to gs://%s/%s' . PHP_EOL, + printf( + 'Moved gs://%s/%s to gs://%s/%s' . PHP_EOL, $bucketName, $objectName, $newBucketName, - $newObjectName); + $newObjectName + ); } # [END storage_move_file] diff --git a/storage/src/remove_bucket_conditional_iam_binding.php b/storage/src/remove_bucket_conditional_iam_binding.php index 3df5e932e4..0436aec159 100644 --- a/storage/src/remove_bucket_conditional_iam_binding.php +++ b/storage/src/remove_bucket_conditional_iam_binding.php @@ -42,8 +42,13 @@ * @param string $expression Te condition specified in CEL expression language. * (e.g. 'resource.name.startsWith("projects/_/buckets/bucket-name/objects/prefix-a-")') */ -function remove_bucket_conditional_iam_binding(string $bucketName, string $role, string $title, string $description, string $expression): void -{ +function remove_bucket_conditional_iam_binding( + string $bucketName, + string $role, + string $title, + string $description, + string $expression +): void { $storage = new StorageClient(); $bucket = $storage->bucket($bucketName); diff --git a/storage/src/rotate_encryption_key.php b/storage/src/rotate_encryption_key.php index dc0c7d252d..f1ac67ce3f 100644 --- a/storage/src/rotate_encryption_key.php +++ b/storage/src/rotate_encryption_key.php @@ -55,8 +55,11 @@ function rotate_encryption_key( 'destinationEncryptionKey' => $newBase64EncryptionKey, ]); - printf('Rotated encryption key for object gs://%s/%s' . PHP_EOL, - $bucketName, $objectName); + printf( + 'Rotated encryption key for object gs://%s/%s' . PHP_EOL, + $bucketName, + $objectName + ); } # [END storage_rotate_encryption_key] diff --git a/storage/src/set_retention_policy.php b/storage/src/set_retention_policy.php index 86bc80c23f..1c23302a67 100644 --- a/storage/src/set_retention_policy.php +++ b/storage/src/set_retention_policy.php @@ -42,8 +42,11 @@ function set_retention_policy(string $bucketName, int $retentionPeriod): void 'retentionPolicy' => [ 'retentionPeriod' => $retentionPeriod ]]); - printf('Bucket %s retention period set to %s seconds' . PHP_EOL, $bucketName, - $retentionPeriod); + printf( + 'Bucket %s retention period set to %s seconds' . PHP_EOL, + $bucketName, + $retentionPeriod + ); } # [END storage_set_retention_policy] diff --git a/storage/src/upload_encrypted_object.php b/storage/src/upload_encrypted_object.php index cccc6f8fc3..ecd8cdb0a6 100644 --- a/storage/src/upload_encrypted_object.php +++ b/storage/src/upload_encrypted_object.php @@ -38,8 +38,12 @@ * @param string $base64EncryptionKey The base64 encoded encryption key. * (e.g. 'TIbv/fjexq+VmtXzAlc63J4z5kFmWJ6NdAPQulQBT7g=') */ -function upload_encrypted_object(string $bucketName, string $objectName, string $source, string $base64EncryptionKey): void -{ +function upload_encrypted_object( + string $bucketName, + string $objectName, + string $source, + string $base64EncryptionKey +): void { $storage = new StorageClient(); $file = fopen($source, 'r'); $bucket = $storage->bucket($bucketName); @@ -47,8 +51,12 @@ function upload_encrypted_object(string $bucketName, string $objectName, string 'name' => $objectName, 'encryptionKey' => $base64EncryptionKey, ]); - printf('Uploaded encrypted %s to gs://%s/%s' . PHP_EOL, - basename($source), $bucketName, $objectName); + printf( + 'Uploaded encrypted %s to gs://%s/%s' . PHP_EOL, + basename($source), + $bucketName, + $objectName + ); } # [END storage_upload_encrypted_file] diff --git a/storage/src/upload_with_kms_key.php b/storage/src/upload_with_kms_key.php index 20f69c7a3c..d2b53e6ede 100644 --- a/storage/src/upload_with_kms_key.php +++ b/storage/src/upload_with_kms_key.php @@ -50,11 +50,13 @@ function upload_with_kms_key(string $bucketName, string $objectName, string $sou 'name' => $objectName, 'destinationKmsKeyName' => $kmsKeyName, ]); - printf('Uploaded %s to gs://%s/%s using encryption key %s' . PHP_EOL, + printf( + 'Uploaded %s to gs://%s/%s using encryption key %s' . PHP_EOL, basename($source), $bucketName, $objectName, - $kmsKeyName); + $kmsKeyName + ); } # [END storage_upload_with_kms_key] diff --git a/storage/test/BucketLockTest.php b/storage/test/BucketLockTest.php index aaa36fc67a..9cfd121eab 100644 --- a/storage/test/BucketLockTest.php +++ b/storage/test/BucketLockTest.php @@ -76,8 +76,10 @@ public function testRetentionPolicyNoLock() $this->bucket->reload(); $effectiveTime = $this->bucket->info()['retentionPolicy']['effectiveTime']; - $this->assertFalse(array_key_exists('isLocked', - $this->bucket->info()['retentionPolicy'])); + $this->assertFalse(array_key_exists( + 'isLocked', + $this->bucket->info()['retentionPolicy'] + )); $this->assertNotNull($effectiveTime); $this->assertEquals($this->bucket->info()['retentionPolicy']['retentionPeriod'], $retentionPeriod); diff --git a/storage/test/IamTest.php b/storage/test/IamTest.php index ce9d600c86..fa7007a426 100644 --- a/storage/test/IamTest.php +++ b/storage/test/IamTest.php @@ -58,8 +58,7 @@ private static function setUpIam() $policy = $iam->policy(['requestedPolicyVersion' => 3]); foreach ($policy['bindings'] as $i => $binding) { - if ( - $binding['role'] == self::$role && + if ($binding['role'] == self::$role && in_array(self::$user, $binding['members']) ) { unset($policy['bindings'][$i]); @@ -120,7 +119,14 @@ public function testAddBucketConditionalIamBinding() Title: %s Description: %s Expression: %s -', self::$role, self::$bucket, self::$user, $title, $description, $expression); +', + self::$role, + self::$bucket, + self::$user, + $title, + $description, + $expression + ); $this->assertEquals($outputString, $output); @@ -175,7 +181,9 @@ public function testListIamMembers() Title: always true Description: this condition is always true Expression: 1 < 2 -', self::$user); +', + self::$user + ); $this->assertStringContainsString($bindingWithCondition, $output); } @@ -206,8 +214,7 @@ public function testRemoveBucketIamMember() 'requestedPolicyVersion' => 3 ]); foreach ($policy['bindings'] as $binding) { - if ( - $binding['role'] == self::$role + if ($binding['role'] == self::$role && empty($binding['condition']) ) { $foundRoleMember = in_array(self::$user, $binding['members']); @@ -245,8 +252,7 @@ public function testRemoveBucketConditionalIamBinding() 'requestedPolicyVersion' => 3 ]); foreach ($policy['bindings'] as $binding) { - if ( - $binding['role'] == self::$role + if ($binding['role'] == self::$role && isset($binding['condition']) ) { $condition = $binding['condition']; diff --git a/storage/test/quickstartTest.php b/storage/test/quickstartTest.php index e2d9678453..10dca4d2d6 100644 --- a/storage/test/quickstartTest.php +++ b/storage/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Storage\Test; + use Google\Cloud\Storage\Bucket; use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/storagetransfer/src/quickstart.php b/storagetransfer/src/quickstart.php index 85383317cd..e792d66d25 100644 --- a/storagetransfer/src/quickstart.php +++ b/storagetransfer/src/quickstart.php @@ -56,7 +56,12 @@ function quickstart($projectId, $sourceGcsBucketName, $sinkGcsBucketName) ->setProjectId($projectId); $client->runTransferJob($request2); - printf('Created and ran transfer job from %s to %s with name %s ' . PHP_EOL, $sourceGcsBucketName, $sinkGcsBucketName, $response->getName()); + printf( + 'Created and ran transfer job from %s to %s with name %s ' . PHP_EOL, + $sourceGcsBucketName, + $sinkGcsBucketName, + $response->getName() + ); } # [END storagetransfer_quickstart] diff --git a/tasks/test/tasksTest.php b/tasks/test/tasksTest.php index 3c33d397c4..382a07a074 100644 --- a/tasks/test/tasksTest.php +++ b/tasks/test/tasksTest.php @@ -69,7 +69,8 @@ public function testCreateHttpTaskWithToken() private function getTaskNamePrefix() { - $taskNamePrefix = sprintf('projects/%s/locations/%s/queues/%s/tasks/', + $taskNamePrefix = sprintf( + 'projects/%s/locations/%s/queues/%s/tasks/', self::$projectId, self::$location, self::$queue diff --git a/testing/sample_helpers.php b/testing/sample_helpers.php index da7a4e0bcb..28a838e19f 100644 --- a/testing/sample_helpers.php +++ b/testing/sample_helpers.php @@ -22,8 +22,7 @@ function execute_sample(string $file, string $namespace, ?array $argv) // Verify the user has supplied the correct number of arguments $functionReflection = new ReflectionFunction($functionName); - if ( - count($argv) < $functionReflection->getNumberOfRequiredParameters() + if (count($argv) < $functionReflection->getNumberOfRequiredParameters() || count($argv) > $functionReflection->getNumberOfParameters() ) { print(get_usage(basename($file), $functionReflection)); diff --git a/texttospeech/src/list_voices.php b/texttospeech/src/list_voices.php index 9fdc773bac..7cbee93992 100644 --- a/texttospeech/src/list_voices.php +++ b/texttospeech/src/list_voices.php @@ -55,8 +55,10 @@ function list_voices(): void printf('SSML voice gender: %s' . PHP_EOL, $ssmlVoiceGender[$gender]); // display the natural hertz rate for this voice - printf('Natural Sample Rate Hertz: %d' . PHP_EOL, - $voice->getNaturalSampleRateHertz()); + printf( + 'Natural Sample Rate Hertz: %d' . PHP_EOL, + $voice->getNaturalSampleRateHertz() + ); } $client->close(); diff --git a/texttospeech/test/quickstartTest.php b/texttospeech/test/quickstartTest.php index 509b8b31b5..1ee3d3a12c 100644 --- a/texttospeech/test/quickstartTest.php +++ b/texttospeech/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\TextToSpeech\Tests; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; @@ -26,8 +28,11 @@ public function testQuickstart() { $file = sys_get_temp_dir() . '/tts_quickstart.php'; $contents = file_get_contents(__DIR__ . '/../quickstart.php'); - $contents = str_replace('__DIR__', sprintf('"%s/.."', __DIR__), - $contents); + $contents = str_replace( + '__DIR__', + sprintf('"%s/.."', __DIR__), + $contents + ); file_put_contents($file, $contents); // invoke quickstart.php $audioContent = include $file; diff --git a/trace/test/TraceTest.php b/trace/test/TraceTest.php index 54841a0688..e8db5f9665 100644 --- a/trace/test/TraceTest.php +++ b/trace/test/TraceTest.php @@ -1,6 +1,6 @@ setAccessible(true); diff --git a/translate/test/quickstartTest.php b/translate/test/quickstartTest.php index 51305088fb..68397e3082 100644 --- a/translate/test/quickstartTest.php +++ b/translate/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Translate\Test; + use Google\Cloud\TestUtils\TestTrait; use PHPUnit\Framework\TestCase; diff --git a/translate/test/translateTest.php b/translate/test/translateTest.php index 5d64da4c45..9957b62673 100644 --- a/translate/test/translateTest.php +++ b/translate/test/translateTest.php @@ -112,7 +112,8 @@ public function testV3TranslateText() $option2 = 'Pozdrav svijetu'; $option3 = 'Zdravo svijete'; $option4 = 'Здраво Свете'; - $this->assertThat($output, + $this->assertThat( + $output, $this->logicalOr( $this->stringContains($option1), $this->stringContains($option2), @@ -179,7 +180,8 @@ public function testV3TranslateTextWithGlossary() ); $option1 = 'アカウント'; $option2 = '口座'; - $this->assertThat($output, + $this->assertThat( + $output, $this->logicalOr( $this->stringContains($option1), $this->stringContains($option2) diff --git a/video/quickstart.php b/video/quickstart.php index 589df8a746..47a2dafe45 100644 --- a/video/quickstart.php +++ b/video/quickstart.php @@ -52,7 +52,8 @@ foreach ($label->getSegments() as $segment) { $start = $segment->getSegment()->getStartTimeOffset(); $end = $segment->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, $end->getSeconds() + $end->getNanos() / 1000000000.0 ); diff --git a/video/src/analyze_labels_file.php b/video/src/analyze_labels_file.php index d0c1e7fc1a..0adb912454 100644 --- a/video/src/analyze_labels_file.php +++ b/video/src/analyze_labels_file.php @@ -60,9 +60,11 @@ function analyze_labels_file(string $path, int $pollingIntervalSeconds = 0) foreach ($label->getSegments() as $segment) { $start = $segment->getSegment()->getStartTimeOffset(); $end = $segment->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $segment->getConfidence()); } } @@ -77,9 +79,11 @@ function analyze_labels_file(string $path, int $pollingIntervalSeconds = 0) foreach ($label->getSegments() as $shot) { $start = $shot->getSegment()->getStartTimeOffset(); $end = $shot->getSegment()->getEndTimeOffset(); - printf(' Shot: %ss to %ss' . PHP_EOL, + printf( + ' Shot: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $shot->getConfidence()); } } diff --git a/video/src/analyze_labels_gcs.php b/video/src/analyze_labels_gcs.php index 88dad68ad8..211205e17a 100644 --- a/video/src/analyze_labels_gcs.php +++ b/video/src/analyze_labels_gcs.php @@ -57,9 +57,11 @@ function analyze_labels_gcs(string $uri, int $pollingIntervalSeconds = 0) foreach ($label->getSegments() as $segment) { $start = $segment->getSegment()->getStartTimeOffset(); $end = $segment->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $segment->getConfidence()); } } @@ -74,9 +76,11 @@ function analyze_labels_gcs(string $uri, int $pollingIntervalSeconds = 0) foreach ($label->getSegments() as $shot) { $start = $shot->getSegment()->getStartTimeOffset(); $end = $shot->getSegment()->getEndTimeOffset(); - printf(' Shot: %ss to %ss' . PHP_EOL, + printf( + ' Shot: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $shot->getConfidence()); } } diff --git a/video/src/analyze_object_tracking.php b/video/src/analyze_object_tracking.php index cbf7d0f744..00d8fb17ac 100644 --- a/video/src/analyze_object_tracking.php +++ b/video/src/analyze_object_tracking.php @@ -55,16 +55,20 @@ function analyze_object_tracking(string $uri, int $pollingIntervalSeconds = 0) $start = $objectEntity->getSegment()->getStartTimeOffset(); $end = $objectEntity->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $objectEntity->getConfidence()); foreach ($objectEntity->getFrames() as $objectEntityFrame) { $offset = $objectEntityFrame->getTimeOffset(); $boundingBox = $objectEntityFrame->getNormalizedBoundingBox(); - printf(' Time offset: %ss' . PHP_EOL, - $offset->getSeconds() + $offset->getNanos() / 1000000000.0); + printf( + ' Time offset: %ss' . PHP_EOL, + $offset->getSeconds() + $offset->getNanos() / 1000000000.0 + ); printf(' Bounding box position:' . PHP_EOL); printf(' Left: %s', $boundingBox->getLeft()); printf(' Top: %s', $boundingBox->getTop()); diff --git a/video/src/analyze_object_tracking_file.php b/video/src/analyze_object_tracking_file.php index 3ba3fa4e58..c05b6c42da 100644 --- a/video/src/analyze_object_tracking_file.php +++ b/video/src/analyze_object_tracking_file.php @@ -58,16 +58,20 @@ function analyze_object_tracking_file(string $path, int $pollingIntervalSeconds $start = $objectEntity->getSegment()->getStartTimeOffset(); $end = $objectEntity->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $objectEntity->getConfidence()); foreach ($objectEntity->getFrames() as $objectEntityFrame) { $offset = $objectEntityFrame->getTimeOffset(); $boundingBox = $objectEntityFrame->getNormalizedBoundingBox(); - printf(' Time offset: %ss' . PHP_EOL, - $offset->getSeconds() + $offset->getNanos() / 1000000000.0); + printf( + ' Time offset: %ss' . PHP_EOL, + $offset->getSeconds() + $offset->getNanos() / 1000000000.0 + ); printf(' Bounding box position:' . PHP_EOL); printf(' Left: %s', $boundingBox->getLeft()); printf(' Top: %s', $boundingBox->getTop()); diff --git a/video/src/analyze_shots.php b/video/src/analyze_shots.php index f695bb6d33..32b1c9fc8e 100644 --- a/video/src/analyze_shots.php +++ b/video/src/analyze_shots.php @@ -50,9 +50,11 @@ function analyze_shots(string $uri, int $pollingIntervalSeconds = 0) foreach ($results->getShotAnnotations() as $shot) { $start = $shot->getStartTimeOffset(); $end = $shot->getEndTimeOffset(); - printf('Shot: %ss to %ss' . PHP_EOL, + printf( + 'Shot: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); } } else { print_r($operation->getError()); diff --git a/video/src/analyze_text_detection.php b/video/src/analyze_text_detection.php index 25a66fe27e..2d673f6a2a 100644 --- a/video/src/analyze_text_detection.php +++ b/video/src/analyze_text_detection.php @@ -54,9 +54,11 @@ function analyze_text_detection(string $uri, int $pollingIntervalSeconds = 0) foreach ($text->getSegments() as $segment) { $start = $segment->getSegment()->getStartTimeOffset(); $end = $segment->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $segment->getConfidence()); } } diff --git a/video/src/analyze_text_detection_file.php b/video/src/analyze_text_detection_file.php index 08f05aa85e..8875c136a3 100644 --- a/video/src/analyze_text_detection_file.php +++ b/video/src/analyze_text_detection_file.php @@ -57,9 +57,11 @@ function analyze_text_detection_file(string $path, int $pollingIntervalSeconds = foreach ($text->getSegments() as $segment) { $start = $segment->getSegment()->getStartTimeOffset(); $end = $segment->getSegment()->getEndTimeOffset(); - printf(' Segment: %ss to %ss' . PHP_EOL, + printf( + ' Segment: %ss to %ss' . PHP_EOL, $start->getSeconds() + $start->getNanos() / 1000000000.0, - $end->getSeconds() + $end->getNanos() / 1000000000.0); + $end->getSeconds() + $end->getNanos() / 1000000000.0 + ); printf(' Confidence: %f' . PHP_EOL, $segment->getConfidence()); } } diff --git a/video/test/quickstartTest.php b/video/test/quickstartTest.php index c30cfe5827..2d70d7f289 100644 --- a/video/test/quickstartTest.php +++ b/video/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Video\Test; + use PHPUnit\Framework\TestCase; use Google\Cloud\TestUtils\TestTrait; diff --git a/vision/src/detect_document_text.php b/vision/src/detect_document_text.php index e6f9e51c14..0899bb5ccb 100644 --- a/vision/src/detect_document_text.php +++ b/vision/src/detect_document_text.php @@ -47,15 +47,20 @@ function detect_document_text(string $path) $block_text .= "\n"; } printf('Block content: %s', $block_text); - printf('Block confidence: %f' . PHP_EOL, - $block->getConfidence()); + printf( + 'Block confidence: %f' . PHP_EOL, + $block->getConfidence() + ); # get bounds $vertices = $block->getBoundingBox()->getVertices(); $bounds = []; foreach ($vertices as $vertex) { - $bounds[] = sprintf('(%d,%d)', $vertex->getX(), - $vertex->getY()); + $bounds[] = sprintf( + '(%d,%d)', + $vertex->getX(), + $vertex->getY() + ); } print('Bounds: ' . join(', ', $bounds) . PHP_EOL); print(PHP_EOL); diff --git a/vision/src/detect_document_text_gcs.php b/vision/src/detect_document_text_gcs.php index 6406819f87..8f25153633 100644 --- a/vision/src/detect_document_text_gcs.php +++ b/vision/src/detect_document_text_gcs.php @@ -46,15 +46,20 @@ function detect_document_text_gcs(string $path) $block_text .= "\n"; } printf('Block content: %s', $block_text); - printf('Block confidence: %f' . PHP_EOL, - $block->getConfidence()); + printf( + 'Block confidence: %f' . PHP_EOL, + $block->getConfidence() + ); # get bounds $vertices = $block->getBoundingBox()->getVertices(); $bounds = []; foreach ($vertices as $vertex) { - $bounds[] = sprintf('(%d,%d)', $vertex->getX(), - $vertex->getY()); + $bounds[] = sprintf( + '(%d,%d)', + $vertex->getX(), + $vertex->getY() + ); } print('Bounds: ' . join(', ', $bounds) . PHP_EOL); diff --git a/vision/src/detect_web.php b/vision/src/detect_web.php index a071ec2970..b379a857f6 100644 --- a/vision/src/detect_web.php +++ b/vision/src/detect_web.php @@ -33,52 +33,66 @@ function detect_web(string $path) $web = $response->getWebDetection(); // Print best guess labels - printf('%d best guess labels found' . PHP_EOL, - count($web->getBestGuessLabels())); + printf( + '%d best guess labels found' . PHP_EOL, + count($web->getBestGuessLabels()) + ); foreach ($web->getBestGuessLabels() as $label) { printf('Best guess label: %s' . PHP_EOL, $label->getLabel()); } print(PHP_EOL); // Print pages with matching images - printf('%d pages with matching images found' . PHP_EOL, - count($web->getPagesWithMatchingImages())); + printf( + '%d pages with matching images found' . PHP_EOL, + count($web->getPagesWithMatchingImages()) + ); foreach ($web->getPagesWithMatchingImages() as $page) { printf('URL: %s' . PHP_EOL, $page->getUrl()); } print(PHP_EOL); // Print full matching images - printf('%d full matching images found' . PHP_EOL, - count($web->getFullMatchingImages())); + printf( + '%d full matching images found' . PHP_EOL, + count($web->getFullMatchingImages()) + ); foreach ($web->getFullMatchingImages() as $fullMatchingImage) { printf('URL: %s' . PHP_EOL, $fullMatchingImage->getUrl()); } print(PHP_EOL); // Print partial matching images - printf('%d partial matching images found' . PHP_EOL, - count($web->getPartialMatchingImages())); + printf( + '%d partial matching images found' . PHP_EOL, + count($web->getPartialMatchingImages()) + ); foreach ($web->getPartialMatchingImages() as $partialMatchingImage) { printf('URL: %s' . PHP_EOL, $partialMatchingImage->getUrl()); } print(PHP_EOL); // Print visually similar images - printf('%d visually similar images found' . PHP_EOL, - count($web->getVisuallySimilarImages())); + printf( + '%d visually similar images found' . PHP_EOL, + count($web->getVisuallySimilarImages()) + ); foreach ($web->getVisuallySimilarImages() as $visuallySimilarImage) { printf('URL: %s' . PHP_EOL, $visuallySimilarImage->getUrl()); } print(PHP_EOL); // Print web entities - printf('%d web entities found' . PHP_EOL, - count($web->getWebEntities())); + printf( + '%d web entities found' . PHP_EOL, + count($web->getWebEntities()) + ); foreach ($web->getWebEntities() as $entity) { - printf('Description: %s, Score %s' . PHP_EOL, + printf( + 'Description: %s, Score %s' . PHP_EOL, $entity->getDescription(), - $entity->getScore()); + $entity->getScore() + ); } $imageAnnotator->close(); diff --git a/vision/src/detect_web_gcs.php b/vision/src/detect_web_gcs.php index 330ac95f00..280e2ca02d 100644 --- a/vision/src/detect_web_gcs.php +++ b/vision/src/detect_web_gcs.php @@ -32,52 +32,66 @@ function detect_web_gcs(string $path) $web = $response->getWebDetection(); if ($web) { - printf('%d best guess labels found' . PHP_EOL, - count($web->getPagesWithMatchingImages())); + printf( + '%d best guess labels found' . PHP_EOL, + count($web->getPagesWithMatchingImages()) + ); foreach ($web->getBestGuessLabels() as $label) { printf('Best guess label: %s' . PHP_EOL, $label->getLabel()); } print(PHP_EOL); // Print pages with matching images - printf('%d pages with matching images found' . PHP_EOL, - count($web->getPagesWithMatchingImages())); + printf( + '%d pages with matching images found' . PHP_EOL, + count($web->getPagesWithMatchingImages()) + ); foreach ($web->getPagesWithMatchingImages() as $page) { printf('URL: %s' . PHP_EOL, $page->getUrl()); } print(PHP_EOL); // Print full matching images - printf('%d full matching images found' . PHP_EOL, - count($web->getFullMatchingImages())); + printf( + '%d full matching images found' . PHP_EOL, + count($web->getFullMatchingImages()) + ); foreach ($web->getFullMatchingImages() as $fullMatchingImage) { printf('URL: %s' . PHP_EOL, $fullMatchingImage->getUrl()); } print(PHP_EOL); // Print partial matching images - printf('%d partial matching images found' . PHP_EOL, - count($web->getPartialMatchingImages())); + printf( + '%d partial matching images found' . PHP_EOL, + count($web->getPartialMatchingImages()) + ); foreach ($web->getPartialMatchingImages() as $partialMatchingImage) { printf('URL: %s' . PHP_EOL, $partialMatchingImage->getUrl()); } print(PHP_EOL); // Print visually similar images - printf('%d visually similar images found' . PHP_EOL, - count($web->getVisuallySimilarImages())); + printf( + '%d visually similar images found' . PHP_EOL, + count($web->getVisuallySimilarImages()) + ); foreach ($web->getVisuallySimilarImages() as $visuallySimilarImage) { printf('URL: %s' . PHP_EOL, $visuallySimilarImage->getUrl()); } print(PHP_EOL); // Print web entities - printf('%d web entities found' . PHP_EOL, - count($web->getWebEntities())); + printf( + '%d web entities found' . PHP_EOL, + count($web->getWebEntities()) + ); foreach ($web->getWebEntities() as $entity) { - printf('Description: %s, Score: %f' . PHP_EOL, + printf( + 'Description: %s, Score: %f' . PHP_EOL, $entity->getDescription(), - $entity->getScore()); + $entity->getScore() + ); } } else { print('No Results.' . PHP_EOL); diff --git a/vision/src/detect_web_with_geo_metadata_gcs.php b/vision/src/detect_web_with_geo_metadata_gcs.php index 8a0cc0d594..410268c29b 100644 --- a/vision/src/detect_web_with_geo_metadata_gcs.php +++ b/vision/src/detect_web_with_geo_metadata_gcs.php @@ -43,8 +43,10 @@ function detect_web_with_geo_metadata_gcs(string $path) $web = $response->getWebDetection(); if ($web) { - printf('%d web entities found:' . PHP_EOL, - count($web->getWebEntities())); + printf( + '%d web entities found:' . PHP_EOL, + count($web->getWebEntities()) + ); foreach ($web->getWebEntities() as $entity) { printf('Description: %s ' . PHP_EOL, $entity->getDescription()); printf('Score: %f' . PHP_EOL, $entity->getScore()); diff --git a/vision/test/quickstartTest.php b/vision/test/quickstartTest.php index 1dc760a5f9..1e0ac2f7cb 100644 --- a/vision/test/quickstartTest.php +++ b/vision/test/quickstartTest.php @@ -15,6 +15,8 @@ * limitations under the License. */ +namespace Google\Cloud\Samples\Vision\Test; + use PHPUnit\Framework\TestCase; class quickstartTest extends TestCase