Skip to content

Commit 0b5d908

Browse files
committed
phpstan level 9
opencode (opus 4.5)
1 parent 130e8ae commit 0b5d908

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=100 --verbose --coverage=build/phpunit",
6767
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-directory=build/phpunit",
6868
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
69-
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=7 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
69+
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=9 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
7070
"test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-directory=build/phpunit"
7171
}
7272
}

phpstan.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
11
parameters:
2-
ignoreErrors:
3-
-
4-
message: '/uploadedFiles/'
5-
path: %currentWorkingDirectory%/src/PsrRequestFactory.php
6-
-
7-
message: '/createStreamFromFile/'
8-
path: %currentWorkingDirectory%/src/PsrRequestFactory.php
9-
-
10-
message: '/createUploadedFile/'
11-
path: %currentWorkingDirectory%/src/PsrRequestFactory.php

src/PsrRequestFactory.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ public function create(WorkermanTcpConnection $workermanTcpConnection, Workerman
3939
$cookies = $workermanRequest->cookie();
4040

4141
$request = $request->withCookieParams($cookies);
42-
$request = $request->withQueryParams($workermanRequest->get());
43-
$request = $request->withParsedBody($workermanRequest->post());
44-
$request = $request->withUploadedFiles($this->uploadedFiles($workermanRequest->file()));
42+
43+
/** @var array<string, string> $queryParams */
44+
$queryParams = $workermanRequest->get() ?? [];
45+
46+
/** @var null|array<string, mixed>|object $parsedBody */
47+
$parsedBody = $workermanRequest->post();
48+
49+
/** @var array<string, array<string, mixed>> $uploadedFilesData */
50+
$uploadedFilesData = $workermanRequest->file() ?? [];
51+
52+
$request = $request->withQueryParams($queryParams);
53+
$request = $request->withParsedBody($parsedBody);
54+
$request = $request->withUploadedFiles($this->uploadedFiles($uploadedFilesData));
4555

4656
$request->getBody()->write($workermanRequest->rawBody());
4757

@@ -60,22 +70,28 @@ private function createServerParams(WorkermanTcpConnection $workermanTcpConnecti
6070
}
6171

6272
/**
63-
* @param array<string, array<string, int|string>> $files
73+
* @param array<string, array<string, mixed>> $files
6474
*
65-
* @return array<string, UploadedFileInterface>
75+
* @return array<string, mixed>
6676
*/
6777
private function uploadedFiles(array $files): array
6878
{
6979
$uploadedFiles = [];
7080
foreach ($files as $key => $file) {
71-
$uploadedFiles[$key] = isset($file['tmp_name']) ? $this->createUploadedFile($file) : $this->uploadedFiles($file);
81+
if (isset($file['tmp_name'])) {
82+
/** @var array{tmp_name: string, size: null|int, error: int, name: null|string, type: null|string} $file */
83+
$uploadedFiles[$key] = $this->createUploadedFile($file);
84+
} else {
85+
/** @var array<string, array<string, mixed>> $file */
86+
$uploadedFiles[$key] = $this->uploadedFiles($file);
87+
}
7288
}
7389

7490
return $uploadedFiles;
7591
}
7692

7793
/**
78-
* @param array<string, int|string> $file
94+
* @param array{tmp_name: string, size: null|int, error: int, name: null|string, type: null|string} $file
7995
*/
8096
private function createUploadedFile(array $file): UploadedFileInterface
8197
{

0 commit comments

Comments
 (0)