From 4407ba41342e0f633962d4fdeb7320bee4ced168 Mon Sep 17 00:00:00 2001 From: andytson-inviqa Date: Sat, 22 Nov 2025 11:05:14 +0000 Subject: [PATCH] chore: update phpstan and fix issues it caught --- composer.json | 2 +- composer.lock | 26 +++++++------------ src/Application.php | 2 +- src/Interpreter/Executors/PHP/Executor.php | 6 ++--- src/Types/Command/Command.php | 2 +- .../Harness/Repository/PackageRepository.php | 6 ++--- src/Types/Subscriber/Subscriber.php | 2 +- src/Types/Workspace/Creator.php | 4 --- src/Types/Workspace/Installer.php | 4 +-- 9 files changed, 22 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index 57a2db80..8e4b9238 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "phpunit/phpunit": "^9.5", "bamarni/composer-bin-plugin": "^1.4", "symfony/process": "^5.2", - "phpstan/phpstan": "^1.2", + "phpstan/phpstan": "^2.1", "symfony/var-dumper": "^6.2" }, "autoload": { diff --git a/composer.lock b/composer.lock index 9afdd735..ca6db9c7 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": "67289587712e907dc030733522d22224", + "content-hash": "b789b157d289e4714b010cb36576d06b", "packages": [ { "name": "composer/semver", @@ -2658,20 +2658,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.9.3", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "709999b91448d4f2bb07daffffedc889b33e461c" - }, + "version": "2.1.32", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/709999b91448d4f2bb07daffffedc889b33e461c", - "reference": "709999b91448d4f2bb07daffffedc889b33e461c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227", + "reference": "e126cad1e30a99b137b8ed75a85a676450ebb227", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -2696,8 +2691,11 @@ "static analysis" ], "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.9.3" + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { @@ -2707,13 +2705,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2022-12-13T10:28:10+00:00" + "time": "2025-11-11T15:18:17+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/Application.php b/src/Application.php index b9892d75..65b63289 100644 --- a/src/Application.php +++ b/src/Application.php @@ -9,7 +9,7 @@ class Application extends ConsoleApplication { - private const DEFAULT_VERSION = '0.2.x-dev'; + private const DEFAULT_VERSION = '0.4.x-dev'; /** @var Environment */ private $environment; diff --git a/src/Interpreter/Executors/PHP/Executor.php b/src/Interpreter/Executors/PHP/Executor.php index 1ed24ea4..48442017 100644 --- a/src/Interpreter/Executors/PHP/Executor.php +++ b/src/Interpreter/Executors/PHP/Executor.php @@ -21,10 +21,10 @@ public function exec(string $script, array $args = [], ?string $cwd = null, arra public function capture(string $script, array $args = [], ?string $cwd = null, array $env = []) { - $pos = strrpos($script, "\n") + 1; + $pos = strrpos($script, "\n"); - if ($pos !== false && $script[$pos] == '=') { - $script = substr_replace($script, 'return ', $pos, 1); + if ($pos !== false && $script[$pos + 1] == '=') { + $script = substr_replace($script, 'return ', $pos + 1, 1); } return $this->run($script, $args, $cwd, $env); diff --git a/src/Types/Command/Command.php b/src/Types/Command/Command.php index f85bcd46..3869b2e7 100644 --- a/src/Types/Command/Command.php +++ b/src/Types/Command/Command.php @@ -48,6 +48,6 @@ private function evaluateEnvironmentVariables(array $env): array private function isExpression(string $value): bool { - return is_string($value) && ($value[0] == '='); + return $value[0] == '='; } } diff --git a/src/Types/Harness/Repository/PackageRepository.php b/src/Types/Harness/Repository/PackageRepository.php index f8e5f566..e4bd1065 100644 --- a/src/Types/Harness/Repository/PackageRepository.php +++ b/src/Types/Harness/Repository/PackageRepository.php @@ -155,9 +155,9 @@ private function mustParseVersionString(string $version): array { if (preg_match(self::HARNESS_VERSION_PATTERN, $version, $match)) { return [ - isset($match['major']) && is_numeric($match['major']) ? (int) $match['major'] : 'x', - isset($match['minor']) && is_numeric($match['minor']) ? (int) $match['minor'] : 'x', - isset($match['patch']) && is_numeric($match['patch']) ? (int) $match['patch'] : 'x', + is_numeric($match['major']) ? (int) $match['major'] : 'x', + is_numeric($match['minor']) ? (int) $match['minor'] : 'x', + is_numeric($match['patch']) ? (int) $match['patch'] : 'x', ]; } diff --git a/src/Types/Subscriber/Subscriber.php b/src/Types/Subscriber/Subscriber.php index 8a3953c5..136b821b 100644 --- a/src/Types/Subscriber/Subscriber.php +++ b/src/Types/Subscriber/Subscriber.php @@ -44,6 +44,6 @@ private function evaluateEnvironmentVariables(array $env): array private function isExpression(string $value): bool { - return is_string($value) && ($value[0] == '='); + return $value[0] == '='; } } diff --git a/src/Types/Workspace/Creator.php b/src/Types/Workspace/Creator.php index c3130e5b..1fba2eee 100644 --- a/src/Types/Workspace/Creator.php +++ b/src/Types/Workspace/Creator.php @@ -53,10 +53,6 @@ private function findHarnessLayers(string $harness): array $harnessLayers = [$harness]; $harnessData = $this->parseYamlMergeStreams($this->downloadAndExtractHarnessYml($package)); - if (!is_array($harnessData)) { - throw new \Exception('Could not parse the harness\'s harness.yml file'); - } - foreach ($harnessData as $key => $value) { if (str_starts_with($key, 'harness(')) { if (isset($value['parentLayers'])) { diff --git a/src/Types/Workspace/Installer.php b/src/Types/Workspace/Installer.php index 78501ea5..10f9e981 100644 --- a/src/Types/Workspace/Installer.php +++ b/src/Types/Workspace/Installer.php @@ -197,7 +197,7 @@ private function ensureRequiredAttributesArePresent(array $required): void foreach (['standard', 'secret'] as $type) { foreach ($required[$type] ?? [] as $attribute) { - if (isset($this->attributes[$attribute]) && $this->attributes[$attribute] !== null) { + if (isset($this->attributes[$attribute])) { continue; } @@ -212,7 +212,7 @@ private function ensureRequiredAttributesArePresent(array $required): void foreach (['standard_file', 'secret_file'] as $type) { foreach ($required[$type] ?? [] as $attribute) { - if (isset($this->attributes[$attribute]) && $this->attributes[$attribute] !== null) { + if (isset($this->attributes[$attribute])) { continue; }