You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
more precise Superglobals / readonlySuperglobals #8037
in psalm with vimeo/psalm#8473 recently more precise Superglobals were added.
I am thinking about doing the same for phpstan behind a readonlySuperglobals feature flag.
in tandem I would implement a new Rule which errors when code modifies one of the superglobal arrays.
(so we can "prevent" people writing types into a superglobal which don't fit the intended types)
Activity
mvorisek commentedon Jun 7, 2023
Yes, for example
$_GETcan be only string or array of strings.phpstan-bot commentedon Jun 9, 2023
@staabm After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:
Full report
Dumped type: arrayDumped type: arrayDumped type: arrayDumped type: arrayDumped type: arrayDumped type: arrayDumped type: arrayDumped type: arrayphpstan-bot commentedon Oct 12, 2024
@staabm After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
Full report
Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>Dumped type: array<mixed>westonruter commentedon Oct 27, 2026
I've opened a PR for this: phpstan/phpstan-src#6866
This would be very useful for analyzing WordPress core which uses superglobals extensively.