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
spurious error in specific combination of namespace blocks and function declaration with phpdoc type annotation #13831
I encountered a strange spurious PHPStan error in the following setting:
// Any non-global namespace block ...namespacefoo {
// ...
}
// ... followed by a global namespace block ...namespace {
// ... and a function declaration here with completed type information in phpdoc// will trigger the spurious error:/** @return list<string> */functionqux(): array { // <-- ??? `missingType.iterableValue` errorreturn [ random_bytes(16) ];
}
\PHPStan\dumpType(qux()); // ok: list<string>
}
(If you are curious: I encountered this issue in my stub file, and I’ve worked around it by reordering the namespace blocks.)
changed the title [-]spurious error in specific combination of namespace blocks and function declaration with doctype[/-][+]spurious error in specific combination of namespace blocks and function declaration with phpdoc type annotation[/+]on Nov 20, 2025
Activity
[-]spurious error in specific combination of namespace blocks and function declaration with doctype[/-][+]spurious error in specific combination of namespace blocks and function declaration with phpdoc type annotation[/+]Fix scope namespace not reset when entering global namespace block
phpstan-bot commentedon Feb 27, 2026
@claudepache After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
Dumped type: list<string>claudepache commentedon Mar 1, 2026
Was fixed by phpstan/phpstan-src#5077
github-actions commentedon Apr 2, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.