diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index bc71b62f..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -coverage_clover: clover.xml -json_path: coveralls-upload.json diff --git a/.gitattributes b/.gitattributes index 172d0b01..20bba50a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,13 @@ -/.coveralls.yml export-ignore /.gitattributes export-ignore /.github/ export-ignore /.gitignore export-ignore -/.travis.yml export-ignore -/.travis/ export-ignore /docs/ export-ignore /mkdocs.yml export-ignore /phpcs.xml export-ignore /phpunit.xml.dist export-ignore /test/ export-ignore +/psalm.xml.dist export-ignore +/psalm-baseline.xml export-ignore +/.laminas-ci.json export-ignore +/composer.lock export-ignore +/renovate.json export-ignore diff --git a/composer.json b/composer.json index d51a7a53..ddb9a911 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "phpunit/phpunit": "9.5.26", "psalm/plugin-phpunit": "^0.18.4", "swoole/ide-helper": "^5.0.3", - "vimeo/psalm": "^4.29.0" + "vimeo/psalm": "^5.12" }, "suggest": { "ext-inotify": "To use inotify based file watcher. Required for hot code reloading.", diff --git a/composer.lock b/composer.lock index 292e6f74..94d0bc94 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f343cf947b7536dab48c90994991c21a", + "content-hash": "245c8f51262c0cbf5ad62607cff464a9", "packages": [ { "name": "dflydev/fig-cookies", @@ -2802,6 +2802,67 @@ }, "time": "2022-03-02T22:36:06+00:00" }, + { + "name": "fidry/cpu-core-counter", + "version": "0.5.1", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/b58e5a3933e541dc286cc91fc4f3898bbc6f1623", + "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^1.9.2", + "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.2.2", + "phpstan/phpstan-strict-rules": "^1.4.4", + "phpunit/phpunit": "^9.5.26 || ^8.5.31", + "theofidry/php-cs-fixer-config": "^1.0", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/0.5.1" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2022-12-24T12:35:10+00:00" + }, { "name": "filp/whoops", "version": "2.15.2", @@ -3245,59 +3306,6 @@ }, "time": "2023-05-19T20:20:00+00:00" }, - { - "name": "openlss/lib-array2xml", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/nullivex/lib-array2xml.git", - "reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nullivex/lib-array2xml/zipball/a91f18a8dfc69ffabe5f9b068bc39bb202c81d90", - "reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "autoload": { - "psr-0": { - "LSS": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Bryan Tong", - "email": "bryan@nullivex.com", - "homepage": "https://www.nullivex.com" - }, - { - "name": "Tony Butler", - "email": "spudz76@gmail.com", - "homepage": "https://www.nullivex.com" - } - ], - "description": "Array2XML conversion library credit to lalit.org", - "homepage": "https://www.nullivex.com", - "keywords": [ - "array", - "array conversion", - "xml", - "xml conversion" - ], - "support": { - "issues": "https://github.com/nullivex/lib-array2xml/issues", - "source": "https://github.com/nullivex/lib-array2xml/tree/master" - }, - "time": "2019-03-29T20:06:56+00:00" - }, { "name": "phar-io/manifest", "version": "2.0.3", @@ -5123,6 +5131,69 @@ ], "time": "2022-05-25T10:58:12+00:00" }, + { + "name": "spatie/array-to-xml", + "version": "3.1.6", + "source": { + "type": "git", + "url": "https://github.com/spatie/array-to-xml.git", + "reference": "e210b98957987c755372465be105d32113f339a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/e210b98957987c755372465be105d32113f339a4", + "reference": "e210b98957987c755372465be105d32113f339a4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "php": "^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "pestphp/pest": "^1.21", + "spatie/pest-plugin-snapshots": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ArrayToXml\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://freek.dev", + "role": "Developer" + } + ], + "description": "Convert an array to xml", + "homepage": "https://github.com/spatie/array-to-xml", + "keywords": [ + "array", + "convert", + "xml" + ], + "support": { + "source": "https://github.com/spatie/array-to-xml/tree/3.1.6" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-05-11T14:04:07+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.7.2", @@ -5212,6 +5283,69 @@ }, "time": "2023-04-28T22:20:18+00:00" }, + { + "name": "symfony/filesystem", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "97b698e1d77d356304def77a8d0cd73090b359ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/97b698e1d77d356304def77a8d0cd73090b359ea", + "reference": "97b698e1d77d356304def77a8d0cd73090b359ea", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-30T17:12:32+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -5264,24 +5398,24 @@ }, { "name": "vimeo/psalm", - "version": "4.30.0", + "version": "5.12.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69" + "reference": "f90118cdeacd0088e7215e64c0c99ceca819e176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/d0bc6e25d89f649e4f36a534f330f8bb4643dd69", - "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/f90118cdeacd0088e7215e64c0c99ceca819e176", + "reference": "f90118cdeacd0088e7215e64c0c99ceca819e176", "shasum": "" }, "require": { "amphp/amp": "^2.4.2", "amphp/byte-stream": "^1.5", - "composer/package-versions-deprecated": "^1.8.0", + "composer-runtime-api": "^2", "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^2.0 || ^3.0", "dnoegel/php-xdg-base-dir": "^0.1.1", "ext-ctype": "*", "ext-dom": "*", @@ -5290,35 +5424,35 @@ "ext-mbstring": "*", "ext-simplexml": "*", "ext-tokenizer": "*", - "felixfbecker/advanced-json-rpc": "^3.0.3", - "felixfbecker/language-server-protocol": "^1.5", + "felixfbecker/advanced-json-rpc": "^3.1", + "felixfbecker/language-server-protocol": "^1.5.2", + "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", - "nikic/php-parser": "^4.13", - "openlss/lib-array2xml": "^1.0", - "php": "^7.1|^8", - "sebastian/diff": "^3.0 || ^4.0", - "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0 || ^6.0", - "symfony/polyfill-php80": "^1.25", - "webmozart/path-util": "^2.3" + "nikic/php-parser": "^4.14", + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "sebastian/diff": "^4.0 || ^5.0", + "spatie/array-to-xml": "^2.17.0 || ^3.0", + "symfony/console": "^4.1.6 || ^5.0 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0" }, "provide": { "psalm/psalm": "self.version" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.2", - "brianium/paratest": "^4.0||^6.0", + "amphp/phpunit-util": "^2.0", + "bamarni/composer-bin-plugin": "^1.4", + "brianium/paratest": "^6.9", "ext-curl": "*", + "mockery/mockery": "^1.5", + "nunomaduro/mock-final-classes": "^1.1", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpdocumentor/reflection-docblock": "^5", - "phpmyadmin/sql-parser": "5.1.0||dev-master", - "phpspec/prophecy": ">=1.9.0", - "phpstan/phpdoc-parser": "1.2.* || 1.6.4", - "phpunit/phpunit": "^9.0", - "psalm/plugin-phpunit": "^0.16", - "slevomat/coding-standard": "^7.0", - "squizlabs/php_codesniffer": "^3.5", - "symfony/process": "^4.3 || ^5.0 || ^6.0", - "weirdan/prophecy-shim": "^1.0 || ^2.0" + "phpstan/phpdoc-parser": "^1.6", + "phpunit/phpunit": "^9.6", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.6", + "symfony/process": "^4.4 || ^5.0 || ^6.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -5334,17 +5468,14 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev", + "dev-master": "5.x-dev", + "dev-4.x": "4.x-dev", "dev-3.x": "3.x-dev", "dev-2.x": "2.x-dev", "dev-1.x": "1.x-dev" } }, "autoload": { - "files": [ - "src/functions.php", - "src/spl_object_id.php" - ], "psr-4": { "Psalm\\": "src/Psalm/" } @@ -5362,13 +5493,14 @@ "keywords": [ "code", "inspection", - "php" + "php", + "static analysis" ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.30.0" + "source": "https://github.com/vimeo/psalm/tree/5.12.0" }, - "time": "2022-11-06T20:37:08+00:00" + "time": "2023-05-22T21:19:03+00:00" }, { "name": "webimpress/coding-standard", @@ -5424,57 +5556,6 @@ } ], "time": "2023-03-09T15:05:18+00:00" - }, - { - "name": "webmozart/path-util", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/path-util.git", - "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", - "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "webmozart/assert": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\PathUtil\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", - "support": { - "issues": "https://github.com/webmozart/path-util/issues", - "source": "https://github.com/webmozart/path-util/tree/2.3.0" - }, - "abandoned": "symfony/filesystem", - "time": "2015-12-17T08:42:14+00:00" } ], "aliases": [], diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ac8b1cde..5f98c048 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + src diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c19d2f1d..bc90b038 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,132 +1,283 @@ - + - + $cacheControlDirectives[$regex] + + + getServer + + + + + $event + + + + + getExitCode + getSignal + + + + + InvalidConfigException + + - - IN_MODIFY - + + $paths + + + ]]> + - - $validProtocols[] - $validProtocols[] - + + PROTOCOLS = [ + SWOOLE_SOCK_TCP, + SWOOLE_SOCK_TCP6, + SWOOLE_SOCK_UDP, + SWOOLE_SOCK_UDP6, + SWOOLE_UNIX_DGRAM, + SWOOLE_UNIX_STREAM, + ] + - + $begin $begin $begin - + $firstLineSize $strlen($firstLine) - + $time - + $time $time - - $this->getRequestMessageSize(0) - $this->getResponseMessageSize(0) + + getRequestMessageSize(0)]]> + getResponseMessageSize(0)]]> - + getHeaderSize - - - '-' - '-' - - - - - marshalUriFromSapi($server, $stripXForwardedHeaders($headers)) - + + + bool + - + $middleware - - $request->server['request_uri'] + + server['request_uri']]]> - + $middleware - + $cacheControlDirectives - + $etagDirectives + + $allowedETagValidationTypes + - - $this->mappedDocRoots[$prefix][] + + mappedDocRoots[$prefix][]]]> - + $directory - + $countBytes($line) - + stream_filter_append - + asString + + + mixed + + + + + int + + + + + $serviceName + + - + $payload - + + + + + $container + $serviceName + + + + + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + assertAttributeEmpty + + + $canonicalize + $delta + $ignoreCase + $maxDepth + + + + + testExecuteIndicatesNoRunningServerWhenServerNotDetected + testExecuteIndicatesRunningServerWhenServerDetected + + + >>]]> + - - $command->killProcess - $command->killProcess - $command->waitThreshold + + killProcess]]> + killProcess]]> + waitThreshold]]> - - assertTrue - assertTrue - + + testExecuteReturnsErrorIfUnableToStopServer + testExecuteReturnsSuccessIfAbleToStopServer + testExecuteReturnsSuccessWhenServerIsNotCurrentlyRunning + + + >>]]> + + + + + set + - - $this->file + + file]]> - + + testExceptionThrownForInvalidServerMode + testExceptionThrownForInvalidSocketType + + $validTypes - - + |array, + * }>]]> + + + + + testProxiesToPsr3Methods + + + + + testReturnsPsrLoggerWhenNoNamedLoggerIsFound + testReturnsStdoutLoggerWhenOtherLoggersAreNotFound + + + + + testMiddlewareInjectsResponseContentCallbackWhenItDetectsAnAcceptEncodingItCanHandle + testResponseContentCallbackEmitsExpectedHeadersAndCompressesContent + + + + + testMiddlewareDoesNothingIfRequestMethodIsNotHead + + + + + testSendStaticResourceReturns405ResponseForUnsupportedMethodMatchingFile + + + + + testSendStaticResourceReturns405ResponseForUnsupportedMethodMatchingFile + + + + + testMiddlewareDoesNothingForAllowedMethods + testMiddlewareReturns405ResponseWithAllowHeaderAndNoContentForDisallowedMethods + + + + + testMiddlewareDoesNothingForNonOptionsRequests + - + $params - list<mixed> - + + + ]]> + + + + + instanceCallback + staticCallback + + + $payload + $payload + - \ No newline at end of file + diff --git a/psalm.xml.dist b/psalm.xml.dist index ff2beb3e..b8824521 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -5,6 +5,9 @@ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorLevel="1" errorBaseline="psalm-baseline.xml" + findUnusedCode="true" + findUnusedPsalmSuppress="true" + findUnusedBaselineEntry="true" > diff --git a/src/Command/StartCommand.php b/src/Command/StartCommand.php index 7745576a..44742d77 100644 --- a/src/Command/StartCommand.php +++ b/src/Command/StartCommand.php @@ -96,10 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $serverOptions = []; $daemonize = (bool) $input->getOption('daemonize'); - /** @psalm-suppress MixedAssignment */ $numWorkers = $input->getOption('num-workers'); - /** @psalm-suppress MixedAssignment */ $numTaskWorkers = $input->getOption('num-task-workers'); if ($daemonize) { diff --git a/src/Command/StopCommand.php b/src/Command/StopCommand.php index c53f2acc..32fc76b6 100644 --- a/src/Command/StopCommand.php +++ b/src/Command/StopCommand.php @@ -83,7 +83,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function stopServer(): bool { - [$masterPid] = $this->pidManager->read(); + $pids = $this->pidManager->read(); + if ([] === $pids) { + // QA: unreachable due to isRunning() check in calling context + return false; + } + [$masterPid] = $pids; $startTime = time(); $result = ($this->killProcess)((int) $masterPid); diff --git a/src/Event/EventDispatcher.php b/src/Event/EventDispatcher.php index b7e91b91..181a5480 100644 --- a/src/Event/EventDispatcher.php +++ b/src/Event/EventDispatcher.php @@ -25,19 +25,16 @@ public function dispatch(object $event) { $stoppable = $event instanceof StoppableEventInterface; - /** @psalm-suppress MixedMethodCall */ if ($stoppable && $event->isPropagationStopped()) { return $event; } - /** @psalm-suppress MixedAssignment */ foreach ($this->listenerProvider->getListenersForEvent($event) as $listener) { /** @psalm-suppress MixedFunctionCall */ $listener($event); if (! $stoppable) { continue; } - /** @psalm-suppress MixedMethodCall */ if (! $event->isPropagationStopped()) { continue; } diff --git a/src/Event/HotCodeReloaderWorkerStartListenerFactory.php b/src/Event/HotCodeReloaderWorkerStartListenerFactory.php index 0c402e8f..a615cbae 100644 --- a/src/Event/HotCodeReloaderWorkerStartListenerFactory.php +++ b/src/Event/HotCodeReloaderWorkerStartListenerFactory.php @@ -28,7 +28,6 @@ public function __invoke(ContainerInterface $container): HotCodeReloaderWorkerSt $config = $container->has('config') ? $container->get('config') : []; Assert::isMap($config); - /** @psalm-suppress MixedAssignment */ $config = $config['mezzio-swoole']['hot-code-reload'] ?? []; Assert::isMap($config); diff --git a/src/Event/RequestHandlerRequestListener.php b/src/Event/RequestHandlerRequestListener.php index 9779bca7..b3c29f31 100644 --- a/src/Event/RequestHandlerRequestListener.php +++ b/src/Event/RequestHandlerRequestListener.php @@ -69,23 +69,17 @@ public function __construct( ?callable $emitterFactory = null ) { // Factories are cast as Closures to ensure return type safety. - /** @psalm-suppress MixedInferredReturnType */ $this->serverRequestFactory = static fn(SwooleHttpRequest $request): ServerRequestInterface => - /** @psalm-suppress MixedReturnStatement */ $serverRequestFactory($request); - /** @psalm-suppress MixedInferredReturnType */ $this->serverRequestErrorResponseGenerator = static fn(Throwable $exception): ResponseInterface => - /** @psalm-suppress MixedReturnStatement */ $serverRequestErrorResponseGenerator($exception); if ($emitterFactory !== null) { - /** @psalm-suppress MixedInferredReturnType */ $this->emitterFactory = static fn(SwooleHttpResponse $response): SwooleEmitter => - /** @psalm-suppress MixedReturnStatement */ $emitterFactory($response); } } diff --git a/src/Event/ServerStartListener.php b/src/Event/ServerStartListener.php index 66495264..3ec05864 100644 --- a/src/Event/ServerStartListener.php +++ b/src/Event/ServerStartListener.php @@ -37,7 +37,6 @@ public function __invoke(ServerStartEvent $event): void { $server = $event->getServer(); - /** @psalm-suppress MixedArgument */ $this->pidManager->write($server->getMasterPid(), $server->getManagerPid()); // Reset CWD diff --git a/src/Event/SwooleListenerProviderFactory.php b/src/Event/SwooleListenerProviderFactory.php index ec8541e4..a2834c41 100644 --- a/src/Event/SwooleListenerProviderFactory.php +++ b/src/Event/SwooleListenerProviderFactory.php @@ -22,7 +22,6 @@ public function __invoke(ContainerInterface $container): SwooleListenerProvider $config = $container->has('config') ? $container->get('config') : []; Assert::isMap($config); - /** @psalm-suppress MixedAssignment */ $config = $config['mezzio-swoole']['swoole-http-server']['listeners'] ?? []; Assert::isMap($config); @@ -32,7 +31,6 @@ public function __invoke(ContainerInterface $container): SwooleListenerProvider Assert::stringNotEmpty($event); Assert::isList($listeners); - /** @psalm-suppress MixedAssignment */ foreach ($listeners as $listener) { Assert::true(is_string($listener) || is_callable($listener)); $provider->addListener( @@ -55,7 +53,6 @@ private function prepareListener(ContainerInterface $container, string|callable throw InvalidListenerException::forNonexistentListenerType($listener, $event); } - /** @psalm-suppress MixedAssignment */ $listener = $container->get($listener); if (! is_callable($listener)) { throw InvalidListenerException::forListenerOfEvent($listener, $event); diff --git a/src/Event/WorkerStartListener.php b/src/Event/WorkerStartListener.php index ef0f13ec..fa0081bf 100644 --- a/src/Event/WorkerStartListener.php +++ b/src/Event/WorkerStartListener.php @@ -38,7 +38,6 @@ public function __invoke(WorkerStartEvent $event): void // Reset CWD chdir($this->cwd); - /** @psalm-suppress MixedArrayAccess */ $processName = $workerId >= $server->setting['worker_num'] ? sprintf('%s-task-worker-%d', $this->processName, $workerId) : sprintf('%s-worker-%d', $this->processName, $workerId); diff --git a/src/Log/AccessLogFormatter.php b/src/Log/AccessLogFormatter.php index 1018c803..7bdf4896 100644 --- a/src/Log/AccessLogFormatter.php +++ b/src/Log/AccessLogFormatter.php @@ -109,8 +109,8 @@ private function replaceConstantDirectives( 'U' => $map->getPath(), 'v' => $map->getHost(), 'V' => $map->getServerName(), - 'I' => $map->getRequestMessageSize('-'), - 'O' => $map->getResponseMessageSize('-'), + 'I' => (string) ($map->getRequestMessageSize() ?? '-'), + 'O' => (string) ($map->getResponseMessageSize() ?? '-'), 'S' => $map->getTransferredSize(), default => '-', }, diff --git a/src/StaticResourceHandler/GzipMiddleware.php b/src/StaticResourceHandler/GzipMiddleware.php index ea580880..39847f19 100644 --- a/src/StaticResourceHandler/GzipMiddleware.php +++ b/src/StaticResourceHandler/GzipMiddleware.php @@ -95,8 +95,7 @@ function (Response $swooleResponse, string $filename) use ($compressionEncoding, $countBytes = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; $length = 0; while (! feof($handle)) { - $line = fgets($handle, 4096); - /** @psalm-suppress MixedAssignment */ + $line = fgets($handle, 4096); $length += $countBytes($line); $swooleResponse->write($line); } diff --git a/src/SwooleRequestHandlerRunner.php b/src/SwooleRequestHandlerRunner.php index b1ebb647..eef0ec6d 100644 --- a/src/SwooleRequestHandlerRunner.php +++ b/src/SwooleRequestHandlerRunner.php @@ -189,27 +189,22 @@ public function onTask(SwooleHttpServer $server, ...$args) )); } - /** @psalm-suppress MixedArgument */ $event = is_int($task) ? $this->createTaskEventFromStandardArguments($server, $task, ...$args) : $this->createTaskEventFromTaskObject($server, $task); $this->dispatcher->dispatch($event); - /** @psalm-suppress MixedAssignment */ $returnValue = $event->getReturnValue(); if (is_object($task)) { Assert::methodExists($task, 'finish'); - /** @psalm-suppress MixedArgument */ - /** @psalm-suppress MixedMethodCall */ $task->finish($returnValue); return $returnValue; } - /** @psalm-suppress MixedArgument */ $this->httpServer->finish($returnValue); return $returnValue; diff --git a/src/Task/DeferredListener.php b/src/Task/DeferredListener.php index 4f3eb9e7..91f1d805 100644 --- a/src/Task/DeferredListener.php +++ b/src/Task/DeferredListener.php @@ -34,7 +34,6 @@ public function __construct(private SwooleHttpServer $server, callable $listener public function __invoke(object $event): void { - /** @psalm-suppress InvalidArgument */ $this->server->task(new Task($this->listener, $event)); } } diff --git a/src/Task/DeferredListenerDelegator.php b/src/Task/DeferredListenerDelegator.php index 6e064050..891dadbd 100644 --- a/src/Task/DeferredListenerDelegator.php +++ b/src/Task/DeferredListenerDelegator.php @@ -32,7 +32,6 @@ final class DeferredListenerDelegator * returns it verbatim. Otherwise, it decorates it as a DeferredListener. * * @return array|object|DeferredListener - * @psalm-suppress MixedInferredReturnType */ public function __invoke( ContainerInterface $container, @@ -41,7 +40,6 @@ public function __invoke( ) { $listener = $factory(); if (! is_callable($listener)) { - /** @psalm-suppress MixedReturnStatement */ return $listener; } diff --git a/src/Task/DeferredServiceListener.php b/src/Task/DeferredServiceListener.php index 2b096d14..2b6f7dd1 100644 --- a/src/Task/DeferredServiceListener.php +++ b/src/Task/DeferredServiceListener.php @@ -29,7 +29,6 @@ public function __construct(private SwooleHttpServer $server, callable $listener public function __invoke(object $event): void { - /** @psalm-suppress InvalidArgument */ $this->server->task(new ServiceBasedTask($this->serviceName, $event)); } diff --git a/src/Task/DeferredServiceListenerDelegator.php b/src/Task/DeferredServiceListenerDelegator.php index 81631d9a..8f0535ed 100644 --- a/src/Task/DeferredServiceListenerDelegator.php +++ b/src/Task/DeferredServiceListenerDelegator.php @@ -33,7 +33,6 @@ final class DeferredServiceListenerDelegator * returns it verbatim. Otherwise, it decorates it as a DeferredServiceListener. * * @return array|object|DeferredServiceListener - * @psalm-suppress MixedInferredReturnType */ public function __invoke( ContainerInterface $container, @@ -42,7 +41,6 @@ public function __invoke( ) { $listener = $factory(); if (! is_callable($listener)) { - /** @psalm-suppress MixedReturnStatement */ return $listener; } diff --git a/src/Task/TaskEventDispatchListenerFactory.php b/src/Task/TaskEventDispatchListenerFactory.php index a1cddfcb..f8844af0 100644 --- a/src/Task/TaskEventDispatchListenerFactory.php +++ b/src/Task/TaskEventDispatchListenerFactory.php @@ -29,20 +29,17 @@ public function __invoke(ContainerInterface $container): TaskEventDispatchListen /** * @psalm-param array $config - * @psalm-suppress MixedInferredReturnType */ private function getDispatcherService(array $config, ContainerInterface $container): PsrEventDispatcherInterface { $dispatcherService = $config['mezzio-swoole']['task-dispatcher-service'] ?? EventDispatcherInterface::class; Assert::stringNotEmpty($dispatcherService); - /** @psalm-suppress MixedReturnStatement */ return $container->get($dispatcherService); } /** * @psalm-param array $config - * @psalm-suppress MixedInferredReturnType */ private function getLoggerService(array $config, ContainerInterface $container): ?LoggerInterface { @@ -54,7 +51,6 @@ private function getLoggerService(array $config, ContainerInterface $container): Assert::stringNotEmpty($loggerService); - /** @psalm-suppress MixedReturnStatement */ return $container->get($loggerService); } } diff --git a/src/Task/TaskInvokerListenerFactory.php b/src/Task/TaskInvokerListenerFactory.php index e306676c..6711a033 100644 --- a/src/Task/TaskInvokerListenerFactory.php +++ b/src/Task/TaskInvokerListenerFactory.php @@ -27,7 +27,6 @@ public function __invoke(ContainerInterface $container): TaskInvokerListener /** * @psalm-param array $config - * @psalm-suppress MixedInferredReturnType */ private function getLoggerService(array $config, ContainerInterface $container): ?LoggerInterface { @@ -39,7 +38,6 @@ private function getLoggerService(array $config, ContainerInterface $container): Assert::stringNotEmpty($loggerService); - /** @psalm-suppress MixedReturnStatement */ return $container->get($loggerService); } } diff --git a/test/AssertResponseTrait.php b/test/AssertResponseTrait.php index 97023b02..d821f559 100644 --- a/test/AssertResponseTrait.php +++ b/test/AssertResponseTrait.php @@ -21,7 +21,6 @@ trait AssertResponseTrait public function assertStatus(int $expected, StaticResourceResponse $response, string $message = ''): void { $r = new ReflectionProperty($response, 'status'); - $r->setAccessible(true); $actual = $r->getValue($response); @@ -37,7 +36,6 @@ public function assertStatus(int $expected, StaticResourceResponse $response, st public function assertHeadersEmpty(StaticResourceResponse $response, string $message = ''): void { $r = new ReflectionProperty($response, 'headers'); - $r->setAccessible(true); $headers = $r->getValue($response); @@ -57,7 +55,6 @@ public function assertHeaderExists(string $name, StaticResourceResponse $respons ); $r = new ReflectionProperty($response, 'headers'); - $r->setAccessible(true); $headers = $r->getValue($response); @@ -72,7 +69,6 @@ public function assertHeaderNotExists(string $name, StaticResourceResponse $resp ); $r = new ReflectionProperty($response, 'headers'); - $r->setAccessible(true); $headers = $r->getValue($response); @@ -88,7 +84,6 @@ public function assertHeaderSame( $this->assertHeaderExists($header, $response); $r = new ReflectionProperty($response, 'headers'); - $r->setAccessible(true); $headers = $r->getValue($response); $value = $headers[$header]; @@ -112,7 +107,6 @@ public function assertHeaderRegexp( $this->assertHeaderExists($header, $response); $r = new ReflectionProperty($response, 'headers'); - $r->setAccessible(true); $headers = $r->getValue($response); $value = $headers[$header]; @@ -132,7 +126,6 @@ public function assertShouldSendContent(StaticResourceResponse $response, string $message = $message ?: 'Failed asserting that the static resource response should send content'; $r = new ReflectionProperty($response, 'sendContent'); - $r->setAccessible(true); $value = $r->getValue($response); Assert::assertTrue($value, $message); @@ -143,7 +136,6 @@ public function assertShouldNotSendContent(StaticResourceResponse $response, str $message = $message ?: 'Failed asserting that the static resource response should not send content'; $r = new ReflectionProperty($response, 'sendContent'); - $r->setAccessible(true); $value = $r->getValue($response); Assert::assertFalse($value, $message); diff --git a/test/AttributeAssertionTrait.php b/test/AttributeAssertionTrait.php index 3cd598e1..2f2ec96b 100644 --- a/test/AttributeAssertionTrait.php +++ b/test/AttributeAssertionTrait.php @@ -26,7 +26,6 @@ trait AttributeAssertionTrait public static function assertAttributeEmpty(string $attributeName, $instance, string $message = ''): void { $r = new ReflectionProperty($instance, $attributeName); - $r->setAccessible(true); Assert::assertEmpty($r->getValue($instance), $message); } @@ -45,7 +44,6 @@ public static function assertAttributeEquals( bool $ignoreCase = false ): void { $r = new ReflectionProperty($instance, $attributeName); - $r->setAccessible(true); Assert::assertEquals($expected, $r->getValue($instance), $message); } @@ -60,7 +58,6 @@ public static function assertAttributeInstanceOf( string $message = '' ): void { $r = new ReflectionProperty($instance, $attributeName); - $r->setAccessible(true); Assert::assertInstanceOf($expected, $r->getValue($instance), $message); } @@ -75,7 +72,6 @@ public static function assertAttributeSame( string $message = '' ): void { $r = new ReflectionProperty($instance, $attributeName); - $r->setAccessible(true); Assert::assertSame($expected, $r->getValue($instance), $message); } } diff --git a/test/Command/ReflectMethodTrait.php b/test/Command/ReflectMethodTrait.php index e4270fec..0ad00077 100644 --- a/test/Command/ReflectMethodTrait.php +++ b/test/Command/ReflectMethodTrait.php @@ -1,9 +1,5 @@ setAccessible(true); - return $r; + return new ReflectionMethod($command, $method); } } diff --git a/test/Log/AccessLogFactoryTest.php b/test/Log/AccessLogFactoryTest.php index e64fde42..12768f2e 100644 --- a/test/Log/AccessLogFactoryTest.php +++ b/test/Log/AccessLogFactoryTest.php @@ -122,7 +122,6 @@ public function testUsesConfigurationToSeedGeneratedLoggerAndFormatter(): void $this->assertAttributeSame(true, 'useHostnameLookups', $logger); $r = new ReflectionProperty($logger, 'formatter'); - $r->setAccessible(true); $formatter = $r->getValue($logger); Assert::isInstanceOf($formatter, AccessLogFormatterInterface::class); diff --git a/test/Log/AccessLogFormatterTest.php b/test/Log/AccessLogFormatterTest.php index c724e952..827c02cf 100644 --- a/test/Log/AccessLogFormatterTest.php +++ b/test/Log/AccessLogFormatterTest.php @@ -51,8 +51,8 @@ public function testFormatterDelegatesToDataMapToReplacePlaceholdersInFormat(): $dataMap->method('getPath')->willReturn('/path'); // %U $dataMap->method('getHost')->willReturn('mezzio.local'); // %v $dataMap->method('getServerName')->willReturn('mezzio.local'); // %V - $dataMap->method('getRequestMessageSize')->with('-')->willReturn(78); // %I - $dataMap->method('getResponseMessageSize')->with('-')->willReturn(89); // %O + $dataMap->method('getRequestMessageSize')->with()->willReturn(78); // %I + $dataMap->method('getResponseMessageSize')->with()->willReturn(89); // %O $dataMap->method('getTransferredSize')->willReturn('123'); // %S $dataMap->method('getCookie')->with('cookie_name')->willReturn('chocolate'); // %{cookie_name}C $dataMap->method('getEnv')->with('env_name')->willReturn('php'); // %{env_name}e diff --git a/test/Log/Psr3AccessLogDecoratorTest.php b/test/Log/Psr3AccessLogDecoratorTest.php index 050facb5..815a6da2 100644 --- a/test/Log/Psr3AccessLogDecoratorTest.php +++ b/test/Log/Psr3AccessLogDecoratorTest.php @@ -54,7 +54,6 @@ protected function setUp(): void private function getPropertyForInstance(string $property, object $instance) { $r = new ReflectionProperty($instance, $property); - $r->setAccessible(true); return $r->getValue($instance); } diff --git a/test/StaticMappedResourceHandlerFactoryTest.php b/test/StaticMappedResourceHandlerFactoryTest.php index dd6b5f89..e7cc6322 100644 --- a/test/StaticMappedResourceHandlerFactoryTest.php +++ b/test/StaticMappedResourceHandlerFactoryTest.php @@ -127,7 +127,6 @@ public function testFactoryConfiguresHandlerBasedOnConfiguration(): void ); $r = new ReflectionProperty($handler, 'middleware'); - $r->setAccessible(true); $middleware = $r->getValue($handler); diff --git a/test/StaticResourceHandler/ContentTypeFilterMiddlewareTest.php b/test/StaticResourceHandler/ContentTypeFilterMiddlewareTest.php index 071ff3c4..6f209079 100644 --- a/test/StaticResourceHandler/ContentTypeFilterMiddlewareTest.php +++ b/test/StaticResourceHandler/ContentTypeFilterMiddlewareTest.php @@ -57,7 +57,6 @@ public function testMiddlewareReturnsFailureResponseIfFileNotAllowedByTypeMap(): 'txt' => 'text/plain', ]); - /** @psalm-suppress InvalidArgument */ $response = $middleware($this->request, __DIR__ . '/../image.png', $next); $this->assertTrue($response->isFailure()); diff --git a/test/StaticResourceHandler/GzipMiddlewareTest.php b/test/StaticResourceHandler/GzipMiddlewareTest.php index 07d0383e..f0d075df 100644 --- a/test/StaticResourceHandler/GzipMiddlewareTest.php +++ b/test/StaticResourceHandler/GzipMiddlewareTest.php @@ -142,7 +142,6 @@ public function testResponseContentCallbackEmitsExpectedHeadersAndCompressesCont $this->assertSame($staticResponse, $response); $r = new ReflectionProperty($response, 'responseContentCallback'); - $r->setAccessible(true); $callback = $r->getValue($response); Assert::isCallable($callback); diff --git a/test/StaticResourceHandler/MethodNotAllowedMiddlewareTest.php b/test/StaticResourceHandler/MethodNotAllowedMiddlewareTest.php index 14345767..8231b8d6 100644 --- a/test/StaticResourceHandler/MethodNotAllowedMiddlewareTest.php +++ b/test/StaticResourceHandler/MethodNotAllowedMiddlewareTest.php @@ -65,7 +65,6 @@ public function testMiddlewareDoesNothingForAllowedMethods(string $method): void $next = static fn (Request $request, string $filename): StaticResourceResponse => $response; $middleware = new MethodNotAllowedMiddleware(); - /** @psalm-suppress InvalidArgument */ $test = $middleware($this->request, '/does/not/matter', $next); $this->assertSame($response, $test); @@ -80,12 +79,11 @@ public function testMiddlewareReturns405ResponseWithAllowHeaderAndNoContentForDi $this->request->server = [ 'request_method' => $method, ]; - $next = function (Request $request, string $filename): void { + $next = function (): void { $this->fail('Should not have reached next()'); }; $middleware = new MethodNotAllowedMiddleware(); - /** @psalm-suppress InvalidArgument */ $response = $middleware($this->request, '/does/not/matter', $next); $this->assertStatus(405, $response); diff --git a/test/StaticResourceHandlerFactoryTest.php b/test/StaticResourceHandlerFactoryTest.php index 5369b008..f43cddaf 100644 --- a/test/StaticResourceHandlerFactoryTest.php +++ b/test/StaticResourceHandlerFactoryTest.php @@ -113,7 +113,6 @@ public function testFactoryConfiguresHandlerBasedOnConfiguration(): void ); $r = new ReflectionProperty($handler, 'middleware'); - $r->setAccessible(true); $middleware = $r->getValue($handler); Assert::isList($middleware); diff --git a/test/SwooleEmitterTest.php b/test/SwooleEmitterTest.php index 3196ae4d..d9dfd5cf 100644 --- a/test/SwooleEmitterTest.php +++ b/test/SwooleEmitterTest.php @@ -169,7 +169,6 @@ public function testEmitWithUnknownSizeContentBody(): void fwrite($stream, $content); rewind($stream); - /** @psalm-suppress PropertyNotSetInConstructor */ $streamWithSimulatedUnknownSize = new class ($stream) extends Stream { public function getSize(): ?int diff --git a/test/Task/DeferredListenerDelegatorTest.php b/test/Task/DeferredListenerDelegatorTest.php index 4582a6b6..ca719264 100644 --- a/test/Task/DeferredListenerDelegatorTest.php +++ b/test/Task/DeferredListenerDelegatorTest.php @@ -51,11 +51,9 @@ public function testDelegatorReturnsDeferredListenerDecoratingSwooleHttpServerAn $this->assertInstanceOf(DeferredListener::class, $deferred); $r = new ReflectionProperty($deferred, 'listener'); - $r->setAccessible(true); $this->assertSame($listener, $r->getValue($deferred)); $r = new ReflectionProperty($deferred, 'server'); - $r->setAccessible(true); $this->assertSame($server, $r->getValue($deferred)); } } diff --git a/test/Task/DeferredListenerTest.php b/test/Task/DeferredListenerTest.php index 2cb80c63..971d165e 100644 --- a/test/Task/DeferredListenerTest.php +++ b/test/Task/DeferredListenerTest.php @@ -35,13 +35,11 @@ public function testListenerQuestsTaskComposingListenerAndEventWithServer(): voi ->method('task') ->with($this->callback(static function (Task $task) use ($listener, $event): bool { $r = new ReflectionProperty($task, 'handler'); - $r->setAccessible(true); $handler = $r->getValue($task); Assert::object($handler); $r = new ReflectionProperty($task, 'payload'); - $r->setAccessible(true); $payload = $r->getValue($task); if (! is_array($payload)) { diff --git a/test/Task/DeferredServiceListenerDelegatorTest.php b/test/Task/DeferredServiceListenerDelegatorTest.php index 4d73bd81..df73c705 100644 --- a/test/Task/DeferredServiceListenerDelegatorTest.php +++ b/test/Task/DeferredServiceListenerDelegatorTest.php @@ -52,11 +52,9 @@ public function testDelegatorReturnsDeferredListenerDecoratingSwooleHttpServerAn $this->assertSame($listener, $deferred->getListener()); $r = new ReflectionProperty($deferred, 'serviceName'); - $r->setAccessible(true); $this->assertSame(CallableObject::class, $r->getValue($deferred)); $r = new ReflectionProperty($deferred, 'server'); - $r->setAccessible(true); $this->assertSame($server, $r->getValue($deferred)); } } diff --git a/test/Task/DeferredServiceListenerTest.php b/test/Task/DeferredServiceListenerTest.php index a1a0a3cb..5cbc9e9b 100644 --- a/test/Task/DeferredServiceListenerTest.php +++ b/test/Task/DeferredServiceListenerTest.php @@ -46,13 +46,11 @@ public function testInvocationQueuesServiceBasedTaskComposingServiceNameAndEvent ->method('task') ->with($this->callback(static function (ServiceBasedTask $task) use ($event): bool { $r = new ReflectionProperty($task, 'serviceName'); - $r->setAccessible(true); $serviceName = $r->getValue($task); Assert::stringNotEmpty($serviceName); $r = new ReflectionProperty($task, 'payload'); - $r->setAccessible(true); $payload = $r->getValue($task); if (! is_array($payload)) { diff --git a/test/Task/TaskEventDispatchListenerFactoryTest.php b/test/Task/TaskEventDispatchListenerFactoryTest.php index 0513d44c..3cd00292 100644 --- a/test/Task/TaskEventDispatchListenerFactoryTest.php +++ b/test/Task/TaskEventDispatchListenerFactoryTest.php @@ -22,7 +22,6 @@ class TaskEventDispatchListenerFactoryTest extends TestCase public function asssertPropertySame(mixed $expected, string $property, object $instance, string $message = ''): void { $r = new ReflectionProperty($instance, $property); - $r->setAccessible(true); $this->assertSame($expected, $r->getValue($instance), $message); } diff --git a/test/Task/TaskInvokerListenerFactoryTest.php b/test/Task/TaskInvokerListenerFactoryTest.php index fe2e170b..c06608bb 100644 --- a/test/Task/TaskInvokerListenerFactoryTest.php +++ b/test/Task/TaskInvokerListenerFactoryTest.php @@ -19,7 +19,6 @@ class TaskInvokerListenerFactoryTest extends TestCase public function assertPropertySame(mixed $expected, string $property, object $instance, string $message = ''): void { $r = new ReflectionProperty($instance, $property); - $r->setAccessible(true); $this->assertSame($expected, $r->getValue($instance), $message); } diff --git a/test/WhoopsPrettyPageHandlerDelegatorTest.php b/test/WhoopsPrettyPageHandlerDelegatorTest.php index fdb2cb8e..1a847264 100644 --- a/test/WhoopsPrettyPageHandlerDelegatorTest.php +++ b/test/WhoopsPrettyPageHandlerDelegatorTest.php @@ -25,7 +25,6 @@ protected function setUp(): void // @see https://github.com/mezzio/mezzio-skeleton/blob/master/src/MezzioInstaller/Resources/config/error-handler-whoops.php $dependencies['factories']['Mezzio\WhoopsPageHandler'] = WhoopsPageHandlerFactory::class; - /** @psalm-suppress InvalidArgument */ $this->container = new ServiceManager($dependencies); }