Skip to content

Commit b6e99c1

Browse files
committed
PEAR/Functions/FunctionDeclaration: minor efficiency tweak
Only call `File::getMethodProperties()` once.
1 parent 75f073b commit b6e99c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ public function process(File $phpcsFile, $stackPtr)
104104
// and the opening parenthesis.
105105
// Unfinished closures are tokenized as T_FUNCTION however, and can be excluded
106106
// by checking for the scope_opener.
107+
$methodProps = $phpcsFile->getMethodProperties($stackPtr);
107108
if ($tokens[$stackPtr]['code'] === T_FUNCTION
108-
&& (isset($tokens[$stackPtr]['scope_opener']) === true || $phpcsFile->getMethodProperties($stackPtr)['has_body'] === false)
109+
&& (isset($tokens[$stackPtr]['scope_opener']) === true || $methodProps['has_body'] === false)
109110
) {
110111
if ($tokens[($openBracket - 1)]['content'] === $phpcsFile->eolChar) {
111112
$spaces = 'newline';
@@ -125,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr)
125126
}
126127

127128
// Must be no space before semicolon in abstract/interface methods.
128-
if ($phpcsFile->getMethodProperties($stackPtr)['has_body'] === false) {
129+
if ($methodProps['has_body'] === false) {
129130
$end = $phpcsFile->findNext(T_SEMICOLON, $closeBracket);
130131
if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar) {
131132
$spaces = 'newline';

0 commit comments

Comments
 (0)