Skip to content

Commit 1125cf1

Browse files
committed
(style): auto-fix lint issues with pint
1 parent 97400a8 commit 1125cf1

169 files changed

Lines changed: 6585 additions & 7892 deletions

File tree

Some content is hidden

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

bin/cli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ini_set('memory_limit', '-1');
99

10-
$cli = new CLI();
10+
$cli = new CLI;
1111

1212
include 'tasks/load.php';
1313
include 'tasks/index.php';

bin/tasks/index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
->param('sharedTables', false, new Boolean(true), 'Whether to use shared tables', true)
3030
->action(function (string $adapter, string $name, bool $sharedTables) {
3131
$namespace = '_ns';
32-
$cache = new Cache(new NoCache());
32+
$cache = new Cache(new NoCache);
3333

3434
$dbAdapters = [
3535
'mariadb' => [
@@ -61,8 +61,9 @@
6161
],
6262
];
6363

64-
if (!isset($dbAdapters[$adapter])) {
64+
if (! isset($dbAdapters[$adapter])) {
6565
Console::error("Adapter '{$adapter}' not supported");
66+
6667
return;
6768
}
6869

bin/tasks/load.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
$genresPool = ['fashion', 'food', 'travel', 'music', 'lifestyle', 'fitness', 'diy', 'sports', 'finance'];
2626
$tagsPool = ['short', 'quick', 'easy', 'medium', 'hard'];
2727

28-
2928
/**
3029
* @Example
3130
* docker compose exec tests bin/load --adapter=mariadb --limit=1000
@@ -35,11 +34,10 @@
3534
->desc('Load database with mock data for testing')
3635
->param('adapter', '', new Text(0), 'Database adapter')
3736
->param('limit', 0, new Integer(true), 'Total number of records to add to database')
38-
->param('name', 'myapp_' . uniqid(), new Text(0), 'Name of created database.', true)
37+
->param('name', 'myapp_'.uniqid(), new Text(0), 'Name of created database.', true)
3938
->param('sharedTables', false, new Boolean(true), 'Whether to use shared tables', true)
4039
->action(function (string $adapter, int $limit, string $name, bool $sharedTables) {
4140

42-
4341
$createSchema = function (Database $database): void {
4442
if ($database->exists($database->getDatabase())) {
4543
$database->delete($database->getDatabase());
@@ -61,14 +59,13 @@
6159
$database->createIndex('articles', 'text', Database::INDEX_FULLTEXT, ['text']);
6260
};
6361

64-
6562
$start = null;
6663
$namespace = '_ns';
67-
$cache = new Cache(new NoCache());
64+
$cache = new Cache(new NoCache);
6865

6966
Console::info("Filling {$adapter} with {$limit} records: {$name}");
7067

71-
//Runtime::enableCoroutine();
68+
// Runtime::enableCoroutine();
7269

7370
$dbAdapters = [
7471
'mariadb' => [
@@ -103,15 +100,16 @@
103100
],
104101
];
105102

106-
if (!isset($dbAdapters[$adapter])) {
103+
if (! isset($dbAdapters[$adapter])) {
107104
Console::error("Adapter '{$adapter}' not supported");
105+
108106
return;
109107
}
110108

111109
$cfg = $dbAdapters[$adapter];
112110
$dsn = ($cfg['dsn'])($cfg['host'], $cfg['port']);
113111

114-
//Co\run(function () use (&$start, $limit, $name, $sharedTables, $namespace, $cache, $cfg) {
112+
// Co\run(function () use (&$start, $limit, $name, $sharedTables, $namespace, $cache, $cfg) {
115113
$pdo = new PDO(
116114
$dsn,
117115
$cfg['user'],
@@ -127,12 +125,12 @@
127125
);
128126

129127
$pool = new PDOPool(
130-
(new PDOConfig())
128+
(new PDOConfig)
131129
->withDriver($cfg['driver'])
132130
->withHost($cfg['host'])
133131
->withPort($cfg['port'])
134132
->withDbName($name)
135-
//->withCharset('utf8mb4')
133+
// ->withCharset('utf8mb4')
136134
->withUsername($cfg['user'])
137135
->withPassword($cfg['pass']),
138136
128
@@ -141,29 +139,27 @@
141139
$start = \microtime(true);
142140

143141
for ($i = 0; $i < $limit / 1000; $i++) {
144-
//\go(function () use ($cfg, $pool, $name, $namespace, $sharedTables, $cache) {
142+
// \go(function () use ($cfg, $pool, $name, $namespace, $sharedTables, $cache) {
145143
try {
146-
//$pdo = $pool->get();
144+
// $pdo = $pool->get();
147145

148146
$database = (new Database(new ($cfg['adapter'])($pdo), $cache))
149147
->setDatabase($name)
150148
->setNamespace($namespace)
151149
->setSharedTables($sharedTables);
152150

153151
createDocuments($database);
154-
//$pool->put($pdo);
152+
// $pool->put($pdo);
155153
} catch (\Throwable $error) {
156-
Console::error('Coroutine error: ' . $error->getMessage());
154+
Console::error('Coroutine error: '.$error->getMessage());
157155
}
158-
//});
156+
// });
159157
}
160158

161159
$time = microtime(true) - $start;
162160
Console::success("Completed in {$time} seconds");
163161
});
164162

165-
166-
167163
function createDocuments(Database $database): void
168164
{
169165
global $namesPool, $genresPool, $tagsPool;
@@ -176,7 +172,7 @@ function createDocuments(Database $database): void
176172
$bytes = \random_bytes(intdiv($length + 1, 2));
177173
$text = \substr(\bin2hex($bytes), 0, $length);
178174
$tagCount = \mt_rand(1, count($tagsPool));
179-
$tagKeys = (array)\array_rand($tagsPool, $tagCount);
175+
$tagKeys = (array) \array_rand($tagsPool, $tagCount);
180176
$tags = \array_map(fn ($k) => $tagsPool[$k], $tagKeys);
181177

182178
$documents[] = new Document([

0 commit comments

Comments
 (0)