Skip to content

Narrow blanket PHPStan ignores to real fixes - #8784

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
fix-phpstan-ignores-narrow
Closed

TomasVotruba wants to merge 1 commit into
mainfrom
fix-phpstan-ignores-narrow

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Three blanket, message-only ignores in phpstan.neon suppressed errors repo-wide, masking any future real violation of the same shape. This replaces them with actual type fixes where the type is provable, and tight path-scoped ignores for the genuine residual boundaries.

class-string, string given

  • ClassNameFromObjectTypeResolver::resolve() now declares @return class-string|null (it does resolve a class name), clearing the ReflectionResolver and one AstResolver call site.
  • findDoctrineAnnotationsByClass() / findByAnnotationClass(): param relaxed class-string -> string; the body only string-compares annotation names, no reflection, so class-string was over-strict.
  • Residual sites (@api value-object ctors, getObjectClassNames() returning string[], getName() strings, one test) are now path-scoped, not repo-wide.

list vs array

  • array_values() at the three provable sites (SplitGroupedClassConstantsRector, AddReturnDocblockForCommonObjectDenominatorRector, RectorRegistry).
  • BetterTokenIterator deliberately widens the parent token param - path-scoped.

filterPolyfillPackages return

  • The method returned any symfony/polyfill-* package name but claimed array<int, PolyfillPackage::*>. Types corrected to array<int, string> across the method, property and provide(); only consumer is a strict in_array.

Net: 3 repo-wide mutes -> real fixes plus narrowly scoped residuals, so new violations elsewhere are caught again.

Note: the symplify.commandHasAsCommandAttribute errors on src/Console/Command/* are pre-existing on main (from the phpstan-rules bump), unrelated to this PR.

Replace three repo-wide message-only ignores (class-string, list vs array,
filterPolyfillPackages return) with real type fixes where provable, and
path-scoped ignores for the genuine residual boundaries:

- PolyfillPackagesProvider: honest array<int, string> return, not PolyfillPackage::*
- ClassNameFromObjectTypeResolver: @return class-string|null
- relax over-strict class-string params to string where only string-compared
- array_values() for list vs array at the three provable sites
@TomasVotruba
TomasVotruba deleted the fix-phpstan-ignores-narrow branch October 23, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant