Skip to content

Commit

Permalink
Merge pull request #7693 from AndrolGenhald/improve-invalid-global-do…
Browse files Browse the repository at this point in the history
…cumentation
  • Loading branch information
weirdan committed Feb 18, 2022
2 parents 2e2099e + c1077f3 commit 2d83a4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit 2d83a4b

Please sign in to comment.