• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valkyrjaio / ci-rector-php / 27730561869

18 Jun 2026 01:23AM UTC coverage: 73.723% (+73.7%) from 0.0%
27730561869

push

github

web-flow
[Rector] Fix psalm and phpstan type errors (#75)

# Description

The `RemoveNonConflictingAliasInUseStatementRector` rule produced a
combined 16 static-analysis failures (11 Psalm, 5 PHPStan) that were
blocking CI for the `ci/rector` package. The errors stemmed from
php-parser's untyped APIs — `mixed` returns from `getAttribute()`,
dynamic property access (`$node->$property`), and the base `Node` type
lacking a `$stmts` property — which the rule consumed without narrowing.

This PR fixes every issue at the source rather than suppressing them, so
both Psalm and PHPStan pass with empty baselines and 100% type
inference.

---

## Types of Changes

- [x] Improvement _(non-breaking change which improves code)_
- [ ] Bug fix _(non-breaking change which fixes an issue)_
- [ ] New feature _(non-breaking change which adds functionality)_
- [ ] Deprecation _(breaking change which removes functionality)_
- [ ] Breaking change _(fix or feature that would cause existing
functionality to change)_
- [ ] Documentation improvement

---

## Changes

-
**`src/Rector/CodingStyle/Rector/Stmt/RemoveNonConflictingAliasInUseStatementRector.php`**
— narrowed `$node` to `FileNode`/`Namespace_` to obtain a typed `$stmts`
local, resolving the `Node::$stmts` undefined-property access; guarded
`modifyComments()` with `is_array()` and a `Comment` instance check, and
coalesced `preg_replace()`'s nullable return into the `Doc` constructor;
extracted a typed `getOriginalName(Node): Name|null` helper (with an
inline `@var` for the untyped `originalName` attribute, which has no
Psalm stub); narrowed the dynamic-property array in `modifyNodes()` via
`array_filter(..., fn => $n instanceof Node)` so the loop iterates
`Node` instead of `mixed`; added the `array_filter` function import

38 of 40 new or added lines in 1 file covered. (95.0%)

1 existing line in 1 file now uncovered.

101 of 137 relevant lines covered (73.72%)

6.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.59
/src/Rector/CodingStyle/Rector/Stmt/RemoveNonConflictingAliasInUseStatementRector.php


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc