chore: upgrade PHPStan to 2.x and fix reported errors - #74
Merged
Merged
Conversation
Upgrade phpstan/phpstan to ^2.2 and phpstan/phpstan-phpunit to ^2.0. Fix errors reported against the updated docker-php-api types and the stricter list<> inference in PHPStan 2: - Build EndpointSettings via setters (no array constructor anymore) - Drop dead nullsafe calls on execStart/containerLogs responses - Type aliases, mounts and port bindings as lists - Guard array_key_first() returning null in getFirstMappedPort() - Pass a correct depth to json_decode() in OpenSearchContainerTest - Remove redundant type checks and assertions in tests - Remove ReflectionProperty::setAccessible() calls (no-op since 8.1, deprecated in PHP 8.5) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
✅ Deploy Preview for testcontainers-php ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Older releases ship the previous EndpointSettings constructor and nullable FETCH_RESPONSE return types the code no longer targets. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades PHPStan from 1.12 to 2.2 (plus
phpstan-phpunit2.0) and fixes everything it reports at level 9.Dependency changes
phpstan/phpstan^1.8→^2.2phpstan/phpstan-phpunit^1.1→^2.0phpstan/extension-installer^1.2→^1.4beluga-php/docker-php^1.45→^1.45.7and an explicitbeluga-php/docker-php-api^7.1.45.5, since older releases still ship the oldEndpointSettingsconstructor and nullableFETCH_RESPONSEreturn typesSource fixes
EndpointSettingsno longer has an array constructor in the currentdocker-php-api, so it is now built viasetNetworkID()/setAliases(). Thealiasesandmountsproperties and the port bindings return type are typed aslist<>to match the Docker API setters.execStart/containerLogswithFETCH_RESPONSEreturn a non-null response, so the nullsafe calls and?? ''fallbacks were dead code.getFirstMappedPort()now throws instead of indexing withnullwhenarray_key_first()returns null.is_string()check.list<string>, matchingStartedTestContainer::exec().non-empty-stringforCURLOPT_URL.Test fixes
OpenSearchContainerTestpassedJSON_THROW_ON_ERRORas the depth argument ofjson_decode(); fixed to use the default depth and assert on the decoded array directly.assertNotNull()and tightened two anonymous test class return types.ReflectionProperty::setAccessible()calls, which are no-ops since PHP 8.1 and emit deprecations on PHP 8.5 that failed six unit tests.Test plan
composer run phpstan— no errors at level 9vendor/bin/phpunit tests/Unit— 33 tests passphp-cs-fixer --dry-run— clean🤖 Generated with Claude Code