Skip to content

Commit 3e37884

Browse files
author
Ace Nassri
authored
Merge branch 'master' into functions-scopes
2 parents 6f06176 + 0aa1285 commit 3e37884

File tree

87 files changed

+2888
-115
lines changed

Some content is hidden

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

87 files changed

+2888
-115
lines changed

.kokoro/secrets.sh.enc

28 Bytes
Binary file not shown.

.php_cs.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ return PhpCsFixer\Config::create()
1010
'method_argument_space' => [
1111
'keep_multiple_spaces_after_comma' => true
1212
],
13+
'return_type_declaration' => [
14+
'space_before' => 'none'
15+
],
1316
])
1417
->setFinder(
1518
PhpCsFixer\Finder::create()

appengine/php72/getting-started/test/CloudSqlTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CloudSqlTest extends TestCase
2525
{
2626
use TestTrait;
2727

28-
public function setUp() : void
28+
public function setUp(): void
2929
{
3030
$connection = $this->requireEnv('CLOUDSQL_CONNECTION_NAME');
3131
$dbUser = $this->requireEnv('CLOUDSQL_USER');

cloud_sql/mysql/pdo/src/Votes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createTableIfNotExists()
6868
*
6969
* @return array
7070
*/
71-
public function listVotes() : array
71+
public function listVotes(): array
7272
{
7373
$sql = "SELECT vote_value, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5";
7474
$statement = $this->connection->prepare($sql);
@@ -82,7 +82,7 @@ public function listVotes() : array
8282
* @param string $value
8383
* @param int
8484
*/
85-
public function getCountByValue(string $value) : int
85+
public function getCountByValue(string $value): int
8686
{
8787
$sql = "SELECT COUNT(vote_id) as voteCount FROM votes WHERE vote_value = ?";
8888

@@ -98,7 +98,7 @@ public function getCountByValue(string $value) : int
9898
* @param string $value The value to vote for.
9999
* @return boolean
100100
*/
101-
public function insertVote(string $value) : bool
101+
public function insertVote(string $value): bool
102102
{
103103
$conn = $this->connection;
104104
$res = false;

cloud_sql/mysql/pdo/src/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
/**
5555
* @param $conn_config array driver-specific options for PDO
5656
*/
57-
function init_tcp_database_connection(array $conn_config) : PDO
57+
function init_tcp_database_connection(array $conn_config): PDO
5858
{
5959
$username = getenv('DB_USER');
6060
$password = getenv('DB_PASS');
@@ -107,7 +107,7 @@ function init_tcp_database_connection(array $conn_config) : PDO
107107
/**
108108
* @param $conn_config array driver-specific options for PDO
109109
*/
110-
function init_unix_database_connection(array $conn_config) : PDO
110+
function init_unix_database_connection(array $conn_config): PDO
111111
{
112112
$username = getenv('DB_USER');
113113
$password = getenv('DB_PASS');

cloud_sql/mysql/pdo/tests/VotesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VotesTest extends TestCase
2929
{
3030
private $conn;
3131

32-
public function setUp() : void
32+
public function setUp(): void
3333
{
3434
$this->conn = $this->prophesize(PDO::class);
3535
}

cloud_sql/postgres/pdo/src/Votes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function createTableIfNotExists()
6868
*
6969
* @return array
7070
*/
71-
public function listVotes() : array
71+
public function listVotes(): array
7272
{
7373
$sql = "SELECT vote_value, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5";
7474
$statement = $this->connection->prepare($sql);
@@ -82,7 +82,7 @@ public function listVotes() : array
8282
* @param string $value
8383
* @param int
8484
*/
85-
public function getCountByValue(string $value) : int
85+
public function getCountByValue(string $value): int
8686
{
8787
$sql = "SELECT COUNT(vote_id) as voteCount FROM votes WHERE vote_value = ?";
8888

@@ -98,7 +98,7 @@ public function getCountByValue(string $value) : int
9898
* @param string $value The value to vote for.
9999
* @return boolean
100100
*/
101-
public function insertVote(string $value) : bool
101+
public function insertVote(string $value): bool
102102
{
103103
$conn = $this->connection;
104104
$res = false;

cloud_sql/postgres/pdo/src/app.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,26 @@
5454
/**
5555
* @param $conn_config array driver-specific options for PDO
5656
*/
57-
function init_tcp_database_connection(array $conn_config) : PDO
57+
function init_tcp_database_connection(array $conn_config): PDO
5858
{
5959
$username = getenv('DB_USER');
6060
$password = getenv('DB_PASS');
6161
$db_name = getenv('DB_NAME');
6262
$host = getenv('DB_HOST');
6363

6464
try {
65-
// # [START cloud_sql_postgres_pdo_create_tcp]
66-
// // $username = 'your_db_user';
67-
// // $password = 'yoursupersecretpassword';
68-
// // $db_name = 'your_db_name';
69-
// // $host = "127.0.0.1";
65+
# [START cloud_sql_postgres_pdo_create_tcp]
66+
// $username = 'your_db_user';
67+
// $password = 'yoursupersecretpassword';
68+
// $db_name = 'your_db_name';
69+
// $host = "127.0.0.1";
7070

7171
// Connect using TCP
7272
$dsn = sprintf('pgsql:dbname=%s;host=%s', $db_name, $host);
7373

7474
// Connect to the database
7575
$conn = new PDO($dsn, $username, $password, $conn_config);
76+
# [END cloud_sql_postgres_pdo_create_tcp]
7677
} catch (TypeError $e) {
7778
throw new RuntimeException(
7879
sprintf(
@@ -115,12 +116,12 @@ function init_unix_database_connection(array $conn_config)
115116
$socket_dir = getenv('DB_SOCKET_DIR') ?: '/cloudsql';
116117

117118
try {
118-
// # [START cloud_sql_postgres_pdo_create_socket]
119-
// // $username = 'your_db_user';
120-
// // $password = 'yoursupersecretpassword';
121-
// // $db_name = 'your_db_name';
122-
// // $cloud_sql_connection_name = getenv("CLOUD_SQL_CONNECTION_NAME");
123-
// // $socket_dir = getenv('DB_SOCKET_DIR') ?: '/cloudsql';
119+
# [START cloud_sql_postgres_pdo_create_socket]
120+
// $username = 'your_db_user';
121+
// $password = 'yoursupersecretpassword';
122+
// $db_name = 'your_db_name';
123+
// $cloud_sql_connection_name = getenv("CLOUD_SQL_CONNECTION_NAME");
124+
// $socket_dir = getenv('DB_SOCKET_DIR') ?: '/cloudsql';
124125

125126
// Connect using UNIX sockets
126127
$dsn = sprintf(

cloud_sql/postgres/pdo/tests/VotesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VotesTest extends TestCase
2929
{
3030
private $conn;
3131

32-
public function setUp() : void
32+
public function setUp(): void
3333
{
3434
$this->conn = $this->prophesize(PDO::class);
3535
}

cloud_sql/sqlserver/pdo/src/Votes.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function createTableIfNotExists()
7474
*
7575
* @return array
7676
*/
77-
public function listVotes() : array
77+
public function listVotes(): array
7878
{
7979
$sql = "SELECT TOP 5 vote_value, time_cast FROM votes ORDER BY time_cast DESC";
8080
$statement = $this->connection->prepare($sql);
@@ -88,7 +88,7 @@ public function listVotes() : array
8888
* @param string $value
8989
* @param int
9090
*/
91-
public function getCountByValue(string $value) : int
91+
public function getCountByValue(string $value): int
9292
{
9393
$sql = "SELECT COUNT(vote_id) as voteCount FROM votes WHERE vote_value = ?";
9494

@@ -104,12 +104,12 @@ public function getCountByValue(string $value) : int
104104
* @param string $value The value to vote for.
105105
* @return boolean
106106
*/
107-
public function insertVote(string $value) : bool
107+
public function insertVote(string $value): bool
108108
{
109109
$conn = $this->connection;
110110
$res = false;
111111

112-
# [START cloud_sql_server_pdo_connection]
112+
# [START cloud_sql_sqlserver_pdo_connection]
113113
// Use prepared statements to guard against SQL injection.
114114
$sql = "INSERT INTO votes (time_cast, vote_value) VALUES (GETDATE(), :voteValue)";
115115

@@ -126,7 +126,7 @@ public function insertVote(string $value) : bool
126126
$e
127127
);
128128
}
129-
# [END cloud_sql_server_pdo_connection]
129+
# [END cloud_sql_sqlserver_pdo_connection]
130130

131131
return $res;
132132
}

0 commit comments

Comments
 (0)