Skip to content

Commit da283ad

Browse files
committed
Apply CS fixer to examples
1 parent af97e31 commit da283ad

6 files changed

Lines changed: 24 additions & 23 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
$config = new Amp\CodeStyle\Config;
44
$config->getFinder()
5+
->in(__DIR__ . '/examples')
56
->in(__DIR__ . '/src')
67
->in(__DIR__ . '/test');
78

examples/1-basic.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
require \dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
55

66
use Amp\Postgres;
77

@@ -12,5 +12,5 @@
1212
$result = $connection->query('SHOW ALL');
1313

1414
foreach ($result as $row) {
15-
\printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
15+
printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
1616
}

examples/2-transaction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
require \dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
55

66
use Amp\Postgres\PostgresConfig;
77
use Amp\Postgres\PostgresConnectionPool;
@@ -24,9 +24,9 @@
2424
$result = $transaction->execute('SELECT * FROM test WHERE tld = :tld', ['tld' => 'com']);
2525

2626
$format = "%-20s | %-10s\n";
27-
\printf($format, 'TLD', 'Domain');
27+
printf($format, 'TLD', 'Domain');
2828
foreach ($result as $row) {
29-
\printf($format, $row['domain'], $row['tld']);
29+
printf($format, $row['domain'], $row['tld']);
3030
}
3131

3232
$transaction->rollback();

examples/3-listen.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
require \dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
55

66
use Amp\Postgres\PostgresConfig;
77
use Amp\Postgres\PostgresConnectionPool;
@@ -15,7 +15,7 @@
1515

1616
$listener = $pool->listen($channel);
1717

18-
\printf("Listening on channel '%s'\n", $listener->getChannel());
18+
printf("Listening on channel '%s'\n", $listener->getChannel());
1919

2020
async(function () use ($pool, $channel, $listener): void {
2121
delay(1);
@@ -32,7 +32,7 @@
3232
});
3333

3434
foreach ($listener as $notification) {
35-
\printf(
35+
printf(
3636
"Received notification from PID %d on channel '%s' with payload: %s\n",
3737
$notification->pid,
3838
$notification->channel,

examples/4-multi-listen.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
require \dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
55

66
use Amp\Future;
77
use Amp\Postgres\PostgresConfig;
@@ -19,11 +19,11 @@
1919

2020
$listener1 = $pool->listen($channel1);
2121

22-
\printf("Listening on channel '%s'\n", $listener1->getChannel());
22+
printf("Listening on channel '%s'\n", $listener1->getChannel());
2323

2424
$listener2 = $pool->listen($channel2);
2525

26-
\printf("Listening on channel '%s'\n", $listener2->getChannel());
26+
printf("Listening on channel '%s'\n", $listener2->getChannel());
2727

2828
async(function () use ($pool, $listener1, $listener2, $channel1, $channel2): void {
2929
$pool->notify($channel1, "Data 1.1");
@@ -38,7 +38,7 @@
3838

3939
delay(0.5);
4040

41-
\printf("Unlistening from channel '%s'\n", $listener2->getChannel());
41+
printf("Unlistening from channel '%s'\n", $listener2->getChannel());
4242
$listener2->unlisten();
4343

4444
delay(0.5);
@@ -47,14 +47,14 @@
4747

4848
delay(0.5);
4949

50-
\printf("Unlistening from channel '%s'\n", $listener1->getChannel());
50+
printf("Unlistening from channel '%s'\n", $listener1->getChannel());
5151
$listener1->unlisten();
5252
});
5353

5454
$consumer = function (PostgresListener $listener): void {
5555
/** @var PostgresNotification $notification */
5656
foreach ($listener as $notification) {
57-
\printf(
57+
printf(
5858
"Received notification from PID %d on channel '%s' with payload: %s\n",
5959
$notification->pid,
6060
$notification->channel,

examples/5-bytea.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
require \dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';
55

66
use Amp\Postgres\ByteA;
77
use Amp\Postgres\PostgresConfig;
@@ -18,9 +18,9 @@
1818

1919
$statement = $transaction->prepare('INSERT INTO test VALUES (?)');
2020

21-
$statement->execute([new ByteA($a = \random_bytes(10))]);
22-
$statement->execute([new ByteA($b = \random_bytes(10))]);
23-
$statement->execute([new ByteA($c = \random_bytes(10))]);
21+
$statement->execute([new ByteA($a = random_bytes(10))]);
22+
$statement->execute([new ByteA($b = random_bytes(10))]);
23+
$statement->execute([new ByteA($c = random_bytes(10))]);
2424

2525
$result = $transaction->execute('SELECT * FROM test WHERE value = :value', ['value' => new ByteA($a)]);
2626

0 commit comments

Comments
 (0)