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

FunctionsAnalyzer - fix isGlobalFunctionCall #3910

Merged
merged 1 commit into from Jul 20, 2018
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
3 changes: 2 additions & 1 deletion src/Tokenizer/Analyzer/FunctionsAnalyzer.php
Expand Up @@ -14,6 +14,7 @@

use PhpCsFixer\Tokenizer\Analyzer\Analysis\ArgumentAnalysis;
use PhpCsFixer\Tokenizer\Analyzer\Analysis\TypeAnalysis;
use PhpCsFixer\Tokenizer\CT;
use PhpCsFixer\Tokenizer\Tokens;

/**
Expand All @@ -40,7 +41,7 @@ public function isGlobalFunctionCall(Tokens $tokens, $index)

$nextIndex = $tokens->getNextMeaningfulToken($index);

return !$tokens[$prevIndex]->isGivenKind([T_DOUBLE_COLON, T_FUNCTION, T_NEW, T_OBJECT_OPERATOR, T_STRING])
return !$tokens[$prevIndex]->isGivenKind([T_DOUBLE_COLON, T_FUNCTION, CT::T_NAMESPACE_OPERATOR, T_NEW, T_OBJECT_OPERATOR, CT::T_RETURN_REF, T_STRING])
&& $tokens[$nextIndex]->equals('(');
}

Expand Down
12 changes: 11 additions & 1 deletion tests/Tokenizer/Analyzer/FunctionsAnalyzerTest.php
Expand Up @@ -97,7 +97,17 @@ public function provideIsGlobalFunctionCallCases()
],
[
false,
'<?php function foo() {};',
'<?php function foo() {}',
3,
],
[
false,
'<?php function & foo() {}',
5,
],
[
false,
'<?php namespace\foo("bar");',
3,
],
];
Expand Down