Fix PHPStan: drop dead null-coalesce in XlsxFileInterpreter::getWorksheetInfo() - #676
Conversation
phpoffice/phpspreadsheet types listWorksheetInfo() as returning
array{worksheetName: string, lastColumnLetter: string, ...} where every
key always exists and is non-nullable. The `?? null` / `?? 0` / `?? 'A'`
fallbacks introduced in #661 are therefore flagged by PHPStan (highest)
as dead code, failing static-analysis CI on 2026.2 after merge.
Co-Authored-By: Claude <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
Removes unreachable fallbacks in XLSX worksheet metadata handling to restore PHPStan compliance without changing behavior.
Changes:
- Access required worksheet metadata directly.
- Remove redundant casts and null-coalescing defaults.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |



Problem
After #661 merged, static analysis on
2026.2started failing (https://github.com/pimcore/data-importer/actions/runs/31784862881) across all PHPStan matrix jobs:PhpOffice\PhpSpreadsheet\Reader\IReader::listWorksheetInfo()is typed to always returnworksheetName,lastColumnLetter, andtotalRowsas non-nullable. The?? null/?? 0/?? 'A'fallbacks added inXlsxFileInterpreter::getWorksheetInfo()in #661 are therefore unreachable dead code, which PHPStan (highest level) flags.Fix
Drop the dead fallbacks and the now-unnecessary casts. No behavior change — these branches were never reachable.
Testing
No regression test added: this is a static-analysis-only fix with no functional change, so there is nothing to regression-test. Not verified locally (no PHP/Composer/PHPStan available in the environment this was prepared in) — CI on this PR is the verification.