Skip to content

Commit ebc9c26

Browse files
feat: new rules for php-cs-fixer (GoogleCloudPlatform#1533)
1 parent 62f55c2 commit ebc9c26

File tree

188 files changed

+517
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+517
-491
lines changed

.kokoro/secrets-example.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export POSTGRES_DSN=
6060
export POSTGRES_DATABASE=
6161
export POSTGRES_USER=
6262
export POSTGRES_PASSWORD=
63+
export SQLSERVER_DSN=
64+
export SQLSERVER_DATABASE=
65+
export SQLSERVER_USER=
66+
export SQLSERVER_PASSWORD=
67+
export DB_SOCKET_DIR=
6368

6469
# Datastore
6570
export CLOUD_DATASTORE_NAMESPACE=

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
'return_type_declaration' => [
1717
'space_before' => 'none'
1818
],
19+
// only converts simple strings in double quotes to single quotes
20+
// ignores strings using variables, escape characters or single quotes inside
21+
'single_quote' => true,
22+
// there should be a single space b/w the cast and it's operand
23+
'cast_spaces' => ['space' => 'single'],
24+
// there shouldn't be any trailing whitespace at the end of a non-blank line
25+
'no_trailing_whitespace' => true,
26+
// there shouldn't be any trailing whitespace at the end of a blank line
27+
'no_whitespace_in_blank_line' => true,
28+
// there should be a space around binary operators like (=, => etc)
29+
'binary_operator_spaces' => ['default' => 'single_space'],
30+
// deals with rogue empty blank lines
31+
'no_extra_blank_lines' => ['tokens' => ['extra']],
32+
// reduces multi blank lines b/w phpdoc description and @param to a single line
33+
// NOTE: Doesn't add a blank line if none exist
34+
'phpdoc_trim_consecutive_blank_line_separation' => true,
1935
])
2036
->setFinder(
2137
PhpCsFixer\Finder::create()

analyticsdata/quickstart_json_credentials.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
*/
4444
$property_id = 'YOUR-GA4-PROPERTY-ID';
4545

46-
4746
// [START analyticsdata_json_credentials_initialize]
4847
/* TODO(developer): Replace this variable with a valid path to the
4948
* credentials.json file for your service account downloaded from the

appengine/flexible/datastore/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
$entity['user_ip']);
7373
}
7474
# [END gae_flex_datastore_query]
75-
array_unshift($visits, "Last 10 visits:");
75+
array_unshift($visits, 'Last 10 visits:');
7676
$response->getBody()->write(implode("\n", $visits));
7777

7878
return $response

appengine/flexible/datastore/test/DeployTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function testIndex()
3030
$this->assertEquals('200', $resp->getStatusCode(),
3131
'top page status code');
3232

33-
$this->assertStringContainsString("Last 10 visits:", (string) $resp->getBody());
33+
$this->assertStringContainsString('Last 10 visits:', (string) $resp->getBody());
3434
}
3535
}

appengine/flexible/datastore/test/LocalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function testIndex()
3333
$response = $app->handle($request);
3434
$this->assertEquals(200, $response->getStatusCode());
3535
$text = (string) $response->getBody();
36-
$this->assertStringContainsString("Last 10 visits:", $text);
36+
$this->assertStringContainsString('Last 10 visits:', $text);
3737
}
3838
}

appengine/flexible/logging/test/DeployTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testIndex()
4141
$this->assertEquals('200', $resp->getStatusCode(),
4242
'top page status code');
4343

44-
$this->assertStringContainsString("Logs:", (string) $resp->getBody());
44+
$this->assertStringContainsString('Logs:', (string) $resp->getBody());
4545
}
4646
public function testAsyncLog()
4747
{

appengine/flexible/logging/test/LocalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testSomeLogs()
3333

3434
$this->assertEquals(200, $response->getStatusCode());
3535
$text = (string) $response->getBody();
36-
$this->assertStringContainsString("Logs:", $text);
36+
$this->assertStringContainsString('Logs:', $text);
3737
}
3838

3939
public function testAsyncLog()

appengine/flexible/memcache/test/DeployTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public function testIndex()
5050
$key = rand(0, 1000);
5151

5252
// Test the /memcached REST API.
53-
$this->put("/memcached/test$key", "sour");
54-
$this->assertEquals("sour", $this->get("/memcached/test$key"));
55-
$this->put("/memcached/test$key", "sweet");
56-
$this->assertEquals("sweet", $this->get("/memcached/test$key"));
53+
$this->put("/memcached/test$key", 'sour');
54+
$this->assertEquals('sour', $this->get("/memcached/test$key"));
55+
$this->put("/memcached/test$key", 'sweet');
56+
$this->assertEquals('sweet', $this->get("/memcached/test$key"));
5757

5858
// Make sure it handles a POST request too, which will increment the
5959
// counter.

appengine/flexible/memcache/test/LocalTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ public function testGetAndPut()
6262
// Use a random key to avoid colliding with simultaneous tests.
6363

6464
// Test the /memcached REST API.
65-
$request1 = (new RequestFactory)->createRequest('PUT', "/memcached/testkey1");
65+
$request1 = (new RequestFactory)->createRequest('PUT', '/memcached/testkey1');
6666
$request1->getBody()->write('sour');
6767
$response1 = $app->handle($request1);
6868
$this->assertEquals(200, (string) $response1->getStatusCode());
6969

7070
// Check that the key was written as expected
71-
$request2 = (new RequestFactory)->createRequest('GET', "/memcached/testkey1");
71+
$request2 = (new RequestFactory)->createRequest('GET', '/memcached/testkey1');
7272
$response2 = $app->handle($request2);
73-
$this->assertEquals("sour", (string) $response2->getBody());
73+
$this->assertEquals('sour', (string) $response2->getBody());
7474

7575
// Test the /memcached REST API with a new value.
76-
$request3 = (new RequestFactory)->createRequest('PUT', "/memcached/testkey2");
76+
$request3 = (new RequestFactory)->createRequest('PUT', '/memcached/testkey2');
7777
$request3->getBody()->write('sweet');
7878
$response3 = $app->handle($request3);
7979
$this->assertEquals(200, (string) $response3->getStatusCode());
8080

8181
// Check that the key was written as expected
82-
$request4 = (new RequestFactory)->createRequest('GET', "/memcached/testkey2");
82+
$request4 = (new RequestFactory)->createRequest('GET', '/memcached/testkey2');
8383
$response4 = $app->handle($request4);
84-
$this->assertEquals("sweet", (string) $response4->getBody());
84+
$this->assertEquals('sweet', (string) $response4->getBody());
8585
}
8686
}
8787

0 commit comments

Comments
 (0)