Skip to content

fix: resolve PHPStan errors blocking master CI#149

Merged
f3l1x merged 8 commits into
masterfrom
fix/ci-phpstan-errors
May 22, 2026
Merged

fix: resolve PHPStan errors blocking master CI#149
f3l1x merged 8 commits into
masterfrom
fix/ci-phpstan-errors

Conversation

@f3l1x
Copy link
Copy Markdown
Member

@f3l1x f3l1x commented May 22, 2026

Summary

  • Fix Router::resolve() returning mixed by narrowing the matched route parameter to string
  • Fix Compiler::getExtensions(TranslationProviderInterface::class) type mismatch by iterating all extensions and filtering via instanceof
  • Add .DS_Store to .gitignore

Master 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 phpstan passes locally (PHP 8.4, latest deps)
  • CI: Quality assurance
  • CI: Static analysis (phpstan)
  • CI: Static analysis (phpstan-lowest)
  • CI: Tests on PHP 8.0–8.5

f3l1x added 2 commits May 22, 2026 14:43
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.
@f3l1x f3l1x force-pushed the fix/ci-phpstan-errors branch 2 times, most recently from b078d8a to 87b28e0 Compare May 22, 2026 14:22
f3l1x added 6 commits May 22, 2026 16:27
…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.
@f3l1x f3l1x merged commit 5788c79 into master May 22, 2026
12 checks passed
@f3l1x f3l1x deleted the fix/ci-phpstan-errors branch May 22, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant