Skip to content

Commit 960262c

Browse files
authored
Merge pull request #649 from rodrigoprimo/fix-bug-constructor-name
Generic/ConstructorName: fix minor bug
2 parents db870d6 + ad45d8a commit 960262c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,18 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
9494
return;
9595
}
9696

97-
$parentClassName = strtolower($phpcsFile->findExtendedClassName($currScope));
97+
$parentClassName = $phpcsFile->findExtendedClassName($currScope);
9898
if ($parentClassName === false) {
9999
return;
100100
}
101101

102+
$parentClassNameLc = strtolower($parentClassName);
103+
102104
$endFunctionIndex = $tokens[$stackPtr]['scope_closer'];
103105
$startIndex = $stackPtr;
104106
while (($doubleColonIndex = $phpcsFile->findNext(T_DOUBLE_COLON, $startIndex, $endFunctionIndex)) !== false) {
105107
if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING
106-
&& strtolower($tokens[($doubleColonIndex + 1)]['content']) === $parentClassName
108+
&& strtolower($tokens[($doubleColonIndex + 1)]['content']) === $parentClassNameLc
107109
) {
108110
$error = 'PHP4 style calls to parent constructors are not allowed; use "parent::__construct()" instead';
109111
$phpcsFile->addError($error, ($doubleColonIndex + 1), 'OldStyleCall');

0 commit comments

Comments
 (0)