Skip to content

Commit

Permalink
Apply CS fixer to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jan 14, 2024
1 parent af97e31 commit da283ad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

$config = new Amp\CodeStyle\Config;
$config->getFinder()
->in(__DIR__ . '/examples')
->in(__DIR__ . '/src')
->in(__DIR__ . '/test');

Expand Down
6 changes: 3 additions & 3 deletions examples/1-basic.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

require \dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Postgres;

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

foreach ($result as $row) {
\printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
}
8 changes: 4 additions & 4 deletions examples/2-transaction.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

require \dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

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

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

$transaction->rollback();
Expand Down
8 changes: 4 additions & 4 deletions examples/3-listen.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

require \dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Postgres\PostgresConfig;
use Amp\Postgres\PostgresConnectionPool;
Expand All @@ -15,7 +15,7 @@

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

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

async(function () use ($pool, $channel, $listener): void {
delay(1);
Expand All @@ -32,7 +32,7 @@
});

foreach ($listener as $notification) {
\printf(
printf(
"Received notification from PID %d on channel '%s' with payload: %s\n",
$notification->pid,
$notification->channel,
Expand Down
14 changes: 7 additions & 7 deletions examples/4-multi-listen.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

require \dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Future;
use Amp\Postgres\PostgresConfig;
Expand All @@ -19,11 +19,11 @@

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

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

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

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

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

delay(0.5);

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

delay(0.5);
Expand All @@ -47,14 +47,14 @@

delay(0.5);

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

$consumer = function (PostgresListener $listener): void {
/** @var PostgresNotification $notification */
foreach ($listener as $notification) {
\printf(
printf(
"Received notification from PID %d on channel '%s' with payload: %s\n",
$notification->pid,
$notification->channel,
Expand Down
10 changes: 5 additions & 5 deletions examples/5-bytea.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

require \dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Postgres\ByteA;
use Amp\Postgres\PostgresConfig;
Expand All @@ -18,9 +18,9 @@

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

$statement->execute([new ByteA($a = \random_bytes(10))]);
$statement->execute([new ByteA($b = \random_bytes(10))]);
$statement->execute([new ByteA($c = \random_bytes(10))]);
$statement->execute([new ByteA($a = random_bytes(10))]);
$statement->execute([new ByteA($b = random_bytes(10))]);
$statement->execute([new ByteA($c = random_bytes(10))]);

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

Expand Down

0 comments on commit da283ad

Please sign in to comment.