Skip to content

Oprava PHPStan chyby instanceof.alwaysTrue u Presenter::getRequest()#1296

Merged
radimvaculik merged 1 commit into
masterfrom
fix/phpstan-instanceof-request
Jul 16, 2026
Merged

Oprava PHPStan chyby instanceof.alwaysTrue u Presenter::getRequest()#1296
radimvaculik merged 1 commit into
masterfrom
fix/phpstan-instanceof-request

Conversation

@radimvaculik

@radimvaculik radimvaculik commented Jul 14, 2026

Copy link
Copy Markdown
Member

Problem

The PHPStan CI job (which runs composer update → latest dependencies) fails on master:

Instanceof between Nette\Application\Request and Nette\Application\Request will always evaluate to true.
 src/Datagrid.php:1952  instanceof.alwaysTrue

Since nette/application v3.3.0, Presenter::getRequest() returns a non-nullable Nette\Application\Request (previously ?Request). The defensive instanceof Request guard in handleEdit() therefore becomes always-true and PHPStan reports it.

This is unrelated to any feature work — it is pure dependency drift and reproduces on a clean master (verified locally with nette/application upgraded to v3.3.0).

Fix

handleEdit() is a signal handler (handle*), so getPresenterInstance()->getRequest() is always set while it runs — it can never be null there. The instanceof Request guard was dead defensive code left over from when getRequest() was typed ?Request. It is removed, along with the now-unused use Nette\Application\Request; import.

Verification

  • make phpstan passes with nette/application v3.3.0 installed (the version CI resolves).
  • Full test suite passes (33 tests, 1 skipped — MySQL not running locally).

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.80%. Comparing base (d9144ab) to head (88e0043).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1296      +/-   ##
==========================================
+ Coverage   48.77%   48.80%   +0.03%     
==========================================
  Files          61       61              
  Lines        2901     2899       -2     
==========================================
  Hits         1415     1415              
+ Misses       1486     1484       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Presenter::getRequest() je v aktuálních verzích nette/application non-nullable a
uvnitř signal handleru není nikdy null, takže kontrola instanceof byla mrtvý kód
způsobující PHPStan chybu instanceof.alwaysTrue. Odstraněn i nepoužitý import.
@radimvaculik
radimvaculik force-pushed the fix/phpstan-instanceof-request branch from da3cc76 to 88e0043 Compare July 14, 2026 08:10
@radimvaculik
radimvaculik requested a review from f3l1x July 14, 2026 08:13
@radimvaculik
radimvaculik merged commit c3e73f4 into master Jul 16, 2026
13 checks passed
@radimvaculik
radimvaculik deleted the fix/phpstan-instanceof-request branch July 16, 2026 19:40
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.

2 participants