Skip to content

Commit 1599c68

Browse files
authored
Merge pull request #342 from utopia-php/feat-static-analysis-update
Update pint + phpstan
2 parents 08750f7 + 30d94db commit 1599c68

8 files changed

Lines changed: 46 additions & 46 deletions

File tree

bin/tasks/load.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
);
8585

8686
// A coroutine is assigned per 1000 documents
87-
for ($i=0; $i < $limit/1000; $i++) {
87+
for ($i = 0; $i < $limit / 1000; $i++) {
8888
go(function () use ($pool, $faker, $name, $cache, $namespace) {
8989
$pdo = $pool->get();
9090

@@ -93,7 +93,7 @@
9393
$database->setNamespace($namespace);
9494

9595
// Each coroutine loads 1000 documents
96-
for ($i=0; $i < 1000; $i++) {
96+
for ($i = 0; $i < 1000; $i++) {
9797
addArticle($database, $faker);
9898
}
9999

@@ -145,7 +145,7 @@
145145
);
146146

147147
// A coroutine is assigned per 1000 documents
148-
for ($i=0; $i < $limit/1000; $i++) {
148+
for ($i = 0; $i < $limit / 1000; $i++) {
149149
go(function () use ($pool, $faker, $name, $cache, $namespace) {
150150
$pdo = $pool->get();
151151

@@ -154,7 +154,7 @@
154154
$database->setNamespace($namespace);
155155

156156
// Each coroutine loads 1000 documents
157-
for ($i=0; $i < 1000; $i++) {
157+
for ($i = 0; $i < 1000; $i++) {
158158
addArticle($database, $faker);
159159
}
160160

@@ -189,14 +189,14 @@
189189

190190
$start = microtime(true);
191191

192-
for ($i=0; $i < $limit/1000; $i++) {
192+
for ($i = 0; $i < $limit / 1000; $i++) {
193193
go(function () use ($client, $faker, $name, $namespace, $cache) {
194194
$database = new Database(new Mongo($client), $cache);
195195
$database->setDefaultDatabase($name);
196196
$database->setNamespace($namespace);
197197

198198
// Each coroutine loads 1000 documents
199-
for ($i=0; $i < 1000; $i++) {
199+
for ($i = 0; $i < 1000; $i++) {
200200
addArticle($database, $faker);
201201
}
202202

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"pcov/clobber": "^2.0",
4444
"swoole/ide-helper": "4.8.0",
4545
"utopia-php/cli": "^0.14.0",
46-
"laravel/pint": "1.4.*",
46+
"laravel/pint": "1.13.*",
4747
"phpstan/phpstan": "1.10.*",
4848
"rregeer/phpunit-coverage-check": "^0.3.1"
4949
},

composer.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Database/Adapter/Mongo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ private function timeFilter(array $filters): array
980980
foreach ($filters as $k => $v) {
981981
if ($k === '_createdAt' || $k == '_updatedAt') {
982982
if (is_array($v)) {
983-
foreach ($v as $sk=>$sv) {
983+
foreach ($v as $sk => $sv) {
984984
$results[$k][$sk] = $this->toMongoDatetime($sv);
985985
}
986986
} else {

src/Database/Adapter/MySQL.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ protected function processException(PDOException $e): void
9393
throw $e;
9494
}
9595

96-
/**
97-
* Get Collection Size
98-
* @param string $collection
99-
* @return int
100-
* @throws DatabaseException
101-
*/
96+
/**
97+
* Get Collection Size
98+
* @param string $collection
99+
* @return int
100+
* @throws DatabaseException
101+
*/
102102
public function getSizeOfCollection(string $collection): int
103103
{
104104
$collection = $this->filter($collection);

src/Database/Validator/Roles.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Roles extends Validator
4141
'allowed' => false,
4242
'required' => false,
4343
],
44-
'dimension' =>[
44+
'dimension' => [
4545
'allowed' => false,
4646
'required' => false,
4747
],
@@ -51,7 +51,7 @@ class Roles extends Validator
5151
'allowed' => false,
5252
'required' => false,
5353
],
54-
'dimension' =>[
54+
'dimension' => [
5555
'allowed' => false,
5656
'required' => false,
5757
],
@@ -61,7 +61,7 @@ class Roles extends Validator
6161
'allowed' => false,
6262
'required' => false,
6363
],
64-
'dimension' =>[
64+
'dimension' => [
6565
'allowed' => true,
6666
'required' => false,
6767
'options' => self::USER_DIMENSIONS
@@ -72,7 +72,7 @@ class Roles extends Validator
7272
'allowed' => true,
7373
'required' => true,
7474
],
75-
'dimension' =>[
75+
'dimension' => [
7676
'allowed' => true,
7777
'required' => false,
7878
'options' => self::USER_DIMENSIONS
@@ -83,7 +83,7 @@ class Roles extends Validator
8383
'allowed' => true,
8484
'required' => true,
8585
],
86-
'dimension' =>[
86+
'dimension' => [
8787
'allowed' => true,
8888
'required' => false,
8989
],
@@ -93,7 +93,7 @@ class Roles extends Validator
9393
'allowed' => true,
9494
'required' => true,
9595
],
96-
'dimension' =>[
96+
'dimension' => [
9797
'allowed' => false,
9898
'required' => false,
9999
],
@@ -103,7 +103,7 @@ class Roles extends Validator
103103
'allowed' => true,
104104
'required' => true,
105105
],
106-
'dimension' =>[
106+
'dimension' => [
107107
'allowed' => false,
108108
'required' => false,
109109
],

tests/Database/Base.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,13 +3427,13 @@ public function testNoChangeUpdateDocumentWithRelationWithoutPermission(): void
34273427
Permission::create(Role::any()),
34283428
Permission::delete(Role::any()),
34293429
];
3430-
for ($i=1; $i < 6; $i++) {
3430+
for ($i = 1; $i < 6; $i++) {
34313431
static::getDatabase()->createCollection("level{$i}", [$attribute], [], $permissions);
34323432
}
34333433

34343434
for ($i = 1; $i < 5; $i++) {
34353435
$collectionId = $i;
3436-
$relatedCollectionId = $i+1;
3436+
$relatedCollectionId = $i + 1;
34373437
static::getDatabase()->createRelationship(
34383438
collection: "level{$collectionId}",
34393439
relatedCollection: "level{$relatedCollectionId}",
@@ -3495,7 +3495,7 @@ public function testNoChangeUpdateDocumentWithRelationWithoutPermission(): void
34953495
$level1 = static::getDatabase()->updateDocument('level1', $level1->getId(), $level1);
34963496
$this->assertEquals('updated value', $level1['level2']['level3']['name']);
34973497

3498-
for ($i=1; $i < 6; $i++) {
3498+
for ($i = 1; $i < 6; $i++) {
34993499
static::getDatabase()->deleteCollection("level{$i}");
35003500
}
35013501
}
@@ -3661,7 +3661,7 @@ public function testExceptionWidthLimit(int $key, int $stringSize, int $stringCo
36613661
*/
36623662
public function testCheckAttributeWidthLimit(int $key, int $stringSize, int $stringCount, int $intCount, int $floatCount, int $boolCount): void
36633663
{
3664-
if (static::getDatabase()->getAdapter()::getDocumentSizeLimit()> 0) {
3664+
if (static::getDatabase()->getAdapter()::getDocumentSizeLimit() > 0) {
36653665
$collection = static::getDatabase()->getCollection("widthLimit{$key}");
36663666

36673667
// create same attribute in testExceptionWidthLimit
@@ -4116,7 +4116,7 @@ public function testUpdateAttributeStructure(): void
41164116
$this->assertEquals(false, $attribute['array']);
41174117
$this->assertEquals(false, $attribute['required']);
41184118
$this->assertEquals('priceRange', $attribute['format']);
4119-
$this->assertEquals(['min'=>1, 'max'=>10000], $attribute['formatOptions']);
4119+
$this->assertEquals(['min' => 1, 'max' => 10000], $attribute['formatOptions']);
41204120

41214121
$database->updateAttribute('flowers', 'price', default: 100);
41224122
$collection = $database->getCollection('flowers');
@@ -4128,7 +4128,7 @@ public function testUpdateAttributeStructure(): void
41284128
$this->assertEquals(false, $attribute['array']);
41294129
$this->assertEquals(false, $attribute['required']);
41304130
$this->assertEquals('priceRange', $attribute['format']);
4131-
$this->assertEquals(['min'=>1, 'max'=>10000], $attribute['formatOptions']);
4131+
$this->assertEquals(['min' => 1, 'max' => 10000], $attribute['formatOptions']);
41324132

41334133
$database->updateAttribute('flowers', 'price', format: 'priceRangeNew');
41344134
$collection = $database->getCollection('flowers');
@@ -4140,7 +4140,7 @@ public function testUpdateAttributeStructure(): void
41404140
$this->assertEquals(false, $attribute['array']);
41414141
$this->assertEquals(false, $attribute['required']);
41424142
$this->assertEquals('priceRangeNew', $attribute['format']);
4143-
$this->assertEquals(['min'=>1, 'max'=>10000], $attribute['formatOptions']);
4143+
$this->assertEquals(['min' => 1, 'max' => 10000], $attribute['formatOptions']);
41444144

41454145
$database->updateAttribute('flowers', 'price', format: '');
41464146
$collection = $database->getCollection('flowers');
@@ -4152,7 +4152,7 @@ public function testUpdateAttributeStructure(): void
41524152
$this->assertEquals(false, $attribute['array']);
41534153
$this->assertEquals(false, $attribute['required']);
41544154
$this->assertEquals('', $attribute['format']);
4155-
$this->assertEquals(['min'=>1, 'max'=>10000], $attribute['formatOptions']);
4155+
$this->assertEquals(['min' => 1, 'max' => 10000], $attribute['formatOptions']);
41564156

41574157
$database->updateAttribute('flowers', 'price', formatOptions: ['min' => 1, 'max' => 999]);
41584158
$collection = $database->getCollection('flowers');
@@ -4164,7 +4164,7 @@ public function testUpdateAttributeStructure(): void
41644164
$this->assertEquals(false, $attribute['array']);
41654165
$this->assertEquals(false, $attribute['required']);
41664166
$this->assertEquals('', $attribute['format']);
4167-
$this->assertEquals(['min'=>1, 'max'=>999], $attribute['formatOptions']);
4167+
$this->assertEquals(['min' => 1, 'max' => 999], $attribute['formatOptions']);
41684168

41694169
$database->updateAttribute('flowers', 'price', formatOptions: []);
41704170
$collection = $database->getCollection('flowers');

tests/Database/Validator/IndexedQueriesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testValid(): void
8787
);
8888

8989
$this->assertEquals(true, $validator->isValid(['cursorAfter("asdf")']), $validator->getDescription());
90-
$this->assertEquals(true, $validator->isValid([Query::cursorAfter(new Document(['$id'=>'asdf']))]), $validator->getDescription());
90+
$this->assertEquals(true, $validator->isValid([Query::cursorAfter(new Document(['$id' => 'asdf']))]), $validator->getDescription());
9191
$this->assertEquals(true, $validator->isValid(['equal("name", "value")']), $validator->getDescription());
9292
$this->assertEquals(true, $validator->isValid([Query::equal('name', ['value'])]), $validator->getDescription());
9393
$this->assertEquals(true, $validator->isValid(['limit(10)']), $validator->getDescription());

0 commit comments

Comments
 (0)