fix: resolve PHPStan errors blocking master CI#149
Merged
Conversation
PHPStan reported the method as returning mixed because the matched route parameter is unconstrained. Cast to string when present so the declared ?string return type holds.
Nette\DI\Compiler::getExtensions() is typed to accept only class-string<CompilerExtension>, while TranslationProviderInterface is a standalone interface that implementers happen to mix in. The call is correct at runtime (instanceof check), so suppress the static-analysis error via @var + @phpstan-ignore-line.
b078d8a to
87b28e0
Compare
…s->config Replace stdClass-based config with an array-shape type declared via @phpstan-type and cast schemas to arrays. Resolves ~32 mixed-access errors at PHPStan level max without introducing a DTO class. Also updates two ignore patterns whose wording changed ("Fetching class constant class of" -> "Access to constant on") in recent phpstan-nette.
Both Doctrine and NetteDatabase loaders previously trusted PHPDoc @var hints on mixed values coming back from the database/ORM. Validate id and message types explicitly so the array<string> return contract is enforced and PHPStan can see it.
- LocaleResolver: validate getByType() result against ResolverInterface so resolve() is callable and returns a string. - DI/Helpers::unwrapEntity: drop the @var that widened the union beyond Statement::getEntity()'s actual return type. - Latte TranslatorExtension translate filter: shift the message off the variadic args and verify it is string|Stringable before delegating.
…ey generator type translate() accepts a variadic mixed parameter list to support both Symfony and the legacy Nette ITranslator argument order. Validate the shuffled arguments explicitly so $domain/$locale reach trans() and getCatalogue() as proper string|null, and rewrite the translate-key generator PHPDoc so the property/return clearly mean a non-null Generator-returning callable.
phpstan-lowest pulls older phpstan-nette where: - the deprecated-constant access reads "Fetching class constant class of deprecated interface" rather than "Access to constant on"; - Nette\Utils\Finder iteration yields mixed rather than FileInfo. Update the lowest config patterns to accept both old wordings, tolerate version-skewed unmatched ignores, and add an instanceof SplFileInfo guard inside the Finder loop (with a matching no-op ignore in phpstan.neon because it is always-true on the current Finder type). Also move the @var on Helpers::unwrapEntity to immediately precede the $entity assignment so SlevomatCodingStandard's InlineDocCommentDeclaration sniff accepts it, and narrow it to class-string|null so it stays a subtype of Statement::getEntity()'s native return type.
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
Router::resolve()returningmixedby narrowing the matched route parameter tostringCompiler::getExtensions(TranslationProviderInterface::class)type mismatch by iterating all extensions and filtering viainstanceof.DS_Storeto.gitignoreMaster CI has been failing on the scheduled run since at least 2026-04-13 with 3 PHPStan errors at level max. These changes clear them while preserving runtime behaviour.
Test plan
make phpstanpasses locally (PHP 8.4, latest deps)