Skip to content

Fix PHPStan: drop dead null-coalesce in XlsxFileInterpreter::getWorksheetInfo() - #676

Merged
jcPimcore merged 1 commit into
2026.2from
fix/xlsx-worksheet-info-phpstan
Aug 14, 2026
Merged

Fix PHPStan: drop dead null-coalesce in XlsxFileInterpreter::getWorksheetInfo()#676
jcPimcore merged 1 commit into
2026.2from
fix/xlsx-worksheet-info-phpstan

Conversation

@jcPimcore

Copy link
Copy Markdown
Contributor

Problem

After #661 merged, static analysis on 2026.2 started failing (https://github.com/pimcore/data-importer/actions/runs/31784862881) across all PHPStan matrix jobs:

Offset 'worksheetName' on array{worksheetName: string, lastColumnLetter: string, lastColumnIndex: int, totalRows: int, totalColumns: int, sheetState: string} on left side of ?? always exists and is not nullable.
Offset 'totalRows' on array{...} on left side of ?? always exists and is not nullable.
Offset 'lastColumnLetter' on array{...} on left side of ?? always exists and is not nullable.

PhpOffice\PhpSpreadsheet\Reader\IReader::listWorksheetInfo() is typed to always return worksheetName, lastColumnLetter, and totalRows as non-nullable. The ?? null / ?? 0 / ?? 'A' fallbacks added in XlsxFileInterpreter::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.

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>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 08:56
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Install dependencies with Composer

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 copilot-code-review.yml file. Read the docs for details.

@jcPimcore jcPimcore self-assigned this Aug 14, 2026
@jcPimcore
jcPimcore merged commit c1c31a1 into 2026.2 Aug 14, 2026
16 of 18 checks passed
@jcPimcore
jcPimcore deleted the fix/xlsx-worksheet-info-phpstan branch August 14, 2026 09:13
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants