Skip to content

Commit f36da90

Browse files
committed
fix static
1 parent f43e6c7 commit f36da90

4 files changed

Lines changed: 128 additions & 24 deletions

File tree

phpstan-baseline.neon

Lines changed: 117 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ parameters:
183183
-
184184
message: '#^Cannot cast mixed to string\.$#'
185185
identifier: cast.string
186-
count: 5
186+
count: 6
187187
path: src/Query/FilterBuilder.php
188188

189189
-
@@ -204,12 +204,6 @@ parameters:
204204
count: 1
205205
path: src/Query/FilterBuilder.php
206206

207-
-
208-
message: '#^Parameter \#1 \$haystack of function str_contains expects string, mixed given\.$#'
209-
identifier: argument.type
210-
count: 1
211-
path: src/Query/FilterBuilder.php
212-
213207
-
214208
message: '#^Parameter \#1 \$queries of method Patchlevel\\Rango\\Query\\FilterBuilder\:\:buildLogicalOperator\(\) expects list\<array\<string, mixed\>\>, mixed given\.$#'
215209
identifier: argument.type
@@ -237,19 +231,13 @@ parameters:
237231
-
238232
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
239233
identifier: foreach.nonIterable
240-
count: 12
241-
path: src/Query/UpdateBuilder.php
242-
243-
-
244-
message: '#^Binary operation "\." between ''\{'' and mixed results in an error\.$#'
245-
identifier: binaryOp.invalid
246-
count: 11
234+
count: 14
247235
path: src/Query/UpdateBuilder.php
248236

249237
-
250238
message: '#^Cannot cast mixed to float\.$#'
251239
identifier: cast.double
252-
count: 1
240+
count: 2
253241
path: src/Query/UpdateBuilder.php
254242

255243
-
@@ -259,17 +247,35 @@ parameters:
259247
path: src/Query/UpdateBuilder.php
260248

261249
-
262-
message: '#^Method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:buildUpdateExpression\(\) should return array\{expression\: string, setData\: array\<string, mixed\>\|null\} but returns array\{expression\: non\-falsy\-string, setData\: array\<mixed, mixed\>\|null\}\.$#'
250+
message: '#^Method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:buildUpdateExpression\(\) should return array\{expression\: string, setData\: array\<string, mixed\>\|null, setOnInsertData\: array\<string, mixed\>\|null\} but returns array\{expression\: non\-falsy\-string, setData\: array\<mixed, mixed\>\|null, setOnInsertData\: array\<mixed, mixed\>\|null\}\.$#'
263251
identifier: return.type
264252
count: 1
265253
path: src/Query/UpdateBuilder.php
266254

267255
-
268-
message: '#^Parameter \#1 \$string of method PDO\:\:quote\(\) expects string, mixed given\.$#'
256+
message: '#^Parameter \#1 \$field of method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:baseExpression\(\) expects string, mixed given\.$#'
269257
identifier: argument.type
270258
count: 12
271259
path: src/Query/UpdateBuilder.php
272260

261+
-
262+
message: '#^Parameter \#1 \$field of method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:jsonbExtract\(\) expects string, mixed given\.$#'
263+
identifier: argument.type
264+
count: 8
265+
path: src/Query/UpdateBuilder.php
266+
267+
-
268+
message: '#^Parameter \#1 \$field of method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:jsonbExtractText\(\) expects string, mixed given\.$#'
269+
identifier: argument.type
270+
count: 3
271+
path: src/Query/UpdateBuilder.php
272+
273+
-
274+
message: '#^Parameter \#1 \$field of method Patchlevel\\Rango\\Query\\UpdateBuilder\:\:pathLiteral\(\) expects string, mixed given\.$#'
275+
identifier: argument.type
276+
count: 15
277+
path: src/Query/UpdateBuilder.php
278+
273279
-
274280
message: '#^Parameter \#1 \$string of method PDO\:\:quote\(\) expects string, string\|false given\.$#'
275281
identifier: argument.type
@@ -354,6 +360,12 @@ parameters:
354360
count: 19
355361
path: tests/IntegrationTest.php
356362

363+
-
364+
message: '#^Cannot access offset ''a'' on array\|object\|null\.$#'
365+
identifier: offsetAccess.nonOffsetAccessible
366+
count: 2
367+
path: tests/IntegrationTest.php
368+
357369
-
358370
message: '#^Cannot access offset ''age'' on array\|object\|null\.$#'
359371
identifier: offsetAccess.nonOffsetAccessible
@@ -366,6 +378,18 @@ parameters:
366378
count: 1
367379
path: tests/IntegrationTest.php
368380

381+
-
382+
message: '#^Cannot access offset ''b'' on mixed\.$#'
383+
identifier: offsetAccess.nonOffsetAccessible
384+
count: 2
385+
path: tests/IntegrationTest.php
386+
387+
-
388+
message: '#^Cannot access offset ''c'' on mixed\.$#'
389+
identifier: offsetAccess.nonOffsetAccessible
390+
count: 2
391+
path: tests/IntegrationTest.php
392+
369393
-
370394
message: '#^Cannot access offset ''category'' on array\|object\|null\.$#'
371395
identifier: offsetAccess.nonOffsetAccessible
@@ -381,9 +405,39 @@ parameters:
381405
-
382406
message: '#^Cannot access offset ''counter'' on array\|object\|null\.$#'
383407
identifier: offsetAccess.nonOffsetAccessible
408+
count: 3
409+
path: tests/IntegrationTest.php
410+
411+
-
412+
message: '#^Cannot access offset ''counter'' on mixed\.$#'
413+
identifier: offsetAccess.nonOffsetAccessible
414+
count: 1
415+
path: tests/IntegrationTest.php
416+
417+
-
418+
message: '#^Cannot access offset ''created'' on array\|object\|null\.$#'
419+
identifier: offsetAccess.nonOffsetAccessible
384420
count: 2
385421
path: tests/IntegrationTest.php
386422

423+
-
424+
message: '#^Cannot access offset ''d'' on mixed\.$#'
425+
identifier: offsetAccess.nonOffsetAccessible
426+
count: 2
427+
path: tests/IntegrationTest.php
428+
429+
-
430+
message: '#^Cannot access offset ''e'' on mixed\.$#'
431+
identifier: offsetAccess.nonOffsetAccessible
432+
count: 2
433+
path: tests/IntegrationTest.php
434+
435+
-
436+
message: '#^Cannot access offset ''f'' on mixed\.$#'
437+
identifier: offsetAccess.nonOffsetAccessible
438+
count: 1
439+
path: tests/IntegrationTest.php
440+
387441
-
388442
message: '#^Cannot access offset ''first'' on array\|object\|null\.$#'
389443
identifier: offsetAccess.nonOffsetAccessible
@@ -408,6 +462,12 @@ parameters:
408462
count: 1
409463
path: tests/IntegrationTest.php
410464

465+
-
466+
message: '#^Cannot access offset ''level'' on mixed\.$#'
467+
identifier: offsetAccess.nonOffsetAccessible
468+
count: 2
469+
path: tests/IntegrationTest.php
470+
411471
-
412472
message: '#^Cannot access offset ''max'' on array\|object\|null\.$#'
413473
identifier: offsetAccess.nonOffsetAccessible
@@ -435,13 +495,13 @@ parameters:
435495
-
436496
message: '#^Cannot access offset ''name'' on array\|object\|null\.$#'
437497
identifier: offsetAccess.nonOffsetAccessible
438-
count: 7
498+
count: 9
439499
path: tests/IntegrationTest.php
440500

441501
-
442502
message: '#^Cannot access offset ''name'' on mixed\.$#'
443503
identifier: offsetAccess.nonOffsetAccessible
444-
count: 4
504+
count: 5
445505
path: tests/IntegrationTest.php
446506

447507
-
@@ -450,6 +510,12 @@ parameters:
450510
count: 1
451511
path: tests/IntegrationTest.php
452512

513+
-
514+
message: '#^Cannot access offset ''points'' on mixed\.$#'
515+
identifier: offsetAccess.nonOffsetAccessible
516+
count: 1
517+
path: tests/IntegrationTest.php
518+
453519
-
454520
message: '#^Cannot access offset ''product'' on array\|object\|null\.$#'
455521
identifier: offsetAccess.nonOffsetAccessible
@@ -462,12 +528,30 @@ parameters:
462528
count: 4
463529
path: tests/IntegrationTest.php
464530

531+
-
532+
message: '#^Cannot access offset ''profile'' on array\|object\|null\.$#'
533+
identifier: offsetAccess.nonOffsetAccessible
534+
count: 5
535+
path: tests/IntegrationTest.php
536+
465537
-
466538
message: '#^Cannot access offset ''score'' on array\|object\|null\.$#'
467539
identifier: offsetAccess.nonOffsetAccessible
468540
count: 1
469541
path: tests/IntegrationTest.php
470542

543+
-
544+
message: '#^Cannot access offset ''score'' on mixed\.$#'
545+
identifier: offsetAccess.nonOffsetAccessible
546+
count: 1
547+
path: tests/IntegrationTest.php
548+
549+
-
550+
message: '#^Cannot access offset ''stats'' on mixed\.$#'
551+
identifier: offsetAccess.nonOffsetAccessible
552+
count: 4
553+
path: tests/IntegrationTest.php
554+
471555
-
472556
message: '#^Cannot access offset ''tags'' on array\|object\|null\.$#'
473557
identifier: offsetAccess.nonOffsetAccessible
@@ -492,6 +576,12 @@ parameters:
492576
count: 4
493577
path: tests/IntegrationTest.php
494578

579+
-
580+
message: '#^Cannot access offset ''value'' on array\|object\|null\.$#'
581+
identifier: offsetAccess.nonOffsetAccessible
582+
count: 1
583+
path: tests/IntegrationTest.php
584+
495585
-
496586
message: '#^Cannot access offset 0 on mixed\.$#'
497587
identifier: offsetAccess.nonOffsetAccessible
@@ -513,7 +603,13 @@ parameters:
513603
-
514604
message: '#^Parameter \#2 \$array of method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) expects array\<mixed\>\|ArrayAccess\<\(int\|string\), mixed\>, array\|object\|null given\.$#'
515605
identifier: argument.type
516-
count: 5
606+
count: 9
607+
path: tests/IntegrationTest.php
608+
609+
-
610+
message: '#^Parameter \#2 \$array of method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) expects array\<mixed\>\|ArrayAccess\<\(int\|string\), mixed\>, mixed given\.$#'
611+
identifier: argument.type
612+
count: 4
517613
path: tests/IntegrationTest.php
518614

519615
-
@@ -525,7 +621,7 @@ parameters:
525621
-
526622
message: '#^Parameter \#2 \$array of method PHPUnit\\Framework\\Assert\:\:assertArrayNotHasKey\(\) expects array\<mixed\>\|ArrayAccess\<\(int\|string\), mixed\>, mixed given\.$#'
527623
identifier: argument.type
528-
count: 1
624+
count: 5
529625
path: tests/IntegrationTest.php
530626

531627
-

src/Query/FilterBuilder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ private function buildOperatorFilter(string $field, string $operator, mixed $ope
225225
if (isset($allOperators['$options'])) {
226226
$options = (string)$allOperators['$options'];
227227
foreach (['i', 'm', 's', 'x'] as $flag) {
228-
if (str_contains($options, $flag) && !str_contains($flags, $flag)) {
229-
$flags .= $flag;
228+
if (!str_contains($options, $flag) || str_contains($flags, $flag)) {
229+
continue;
230230
}
231+
232+
$flags .= $flag;
231233
}
232234
}
233235

src/Query/UpdateBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use RuntimeException;
99

1010
use function array_merge;
11+
use function array_pop;
12+
use function explode;
13+
use function implode;
1114
use function is_array;
1215
use function json_encode;
1316
use function sprintf;
@@ -84,6 +87,7 @@ public function buildUpdateExpression(array $update): array
8487
);
8588
}
8689
}
90+
8791
if ($unsetData) {
8892
foreach ($unsetData as $field => $value) {
8993
$updateParts[] = sprintf('%s #- %s', self::DATA_PLACEHOLDER, $this->pathLiteral($field));

tests/IntegrationTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use MongoDB\Client as MongoDbClient;
88
use MongoDB\Collection as MongoDbCollection;
99
use MongoDB\Database as MongoDbDatabase;
10+
use MongoDB\Exception\InvalidArgumentException;
1011
use Patchlevel\Rango\Client as RangoClient;
1112
use Patchlevel\Rango\Collection as RangoCollection;
1213
use Patchlevel\Rango\Database as RangoDatabase;
@@ -1066,7 +1067,7 @@ public function testUpdateWithoutOperatorsThrows(): void
10661067
{
10671068
$this->collection->insertOne(['_id' => '1', 'name' => 'foo']);
10681069

1069-
$this->expectException($this->collection instanceof RangoCollection ? RuntimeException::class : \MongoDB\Exception\InvalidArgumentException::class);
1070+
$this->expectException($this->collection instanceof RangoCollection ? RuntimeException::class : InvalidArgumentException::class);
10701071
$this->collection->updateOne(['_id' => '1'], []);
10711072
}
10721073

@@ -1091,6 +1092,7 @@ public function testInvalidBitOperatorThrows(): void
10911092
$this->expectException(RuntimeException::class);
10921093
$this->collection->updateOne(['_id' => '1'], ['$bit' => ['v' => ['invalid' => 1]]]);
10931094
}
1095+
10941096
public function testElemMatchComplex(): void
10951097
{
10961098
$this->collection->insertMany([

0 commit comments

Comments
 (0)