Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for InvalidGlobal to explain that it's sometimes valid #7693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/running_psalm/issues/InvalidGlobal.md
@@ -1,9 +1,13 @@
# InvalidGlobal

Emitted when there's a reference to the global keyword where it's not expected
Emitted when there's a reference to the global keyword where it's not expected.

```php
<?php

global $e;
```

If the file is included from a non-global scope this issue will have to be suppressed. See
[Config suppression](../dealing_with_code_issues/#suppressing-issues) for how to suppress this at the file or directory
level.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php
Expand Up @@ -30,7 +30,7 @@ public static function analyze(
if (!$context->collect_initializations && !$global_context) {
IssueBuffer::maybeAdd(
new InvalidGlobal(
'Cannot use global scope here',
'Cannot use global scope here (unless this file is included from a non-global scope)',
new CodeLocation($statements_analyzer, $stmt)
),
$statements_analyzer->getSource()->getSuppressedIssues()
Expand Down