|
41 | 41 | * </properties>
|
42 | 42 | * </rule>
|
43 | 43 | * ```
|
44 |
| - * @author David Grudl |
45 | 44 | */
|
46 | 45 |
|
47 | 46 | namespace NetteCodingStandard\Sniffs\Namespaces;
|
48 | 47 |
|
49 |
| -use PHP_CodeSniffer\Sniffs\Sniff; |
50 |
| -use PHP_CodeSniffer\Files\File; |
51 | 48 | use Exception;
|
| 49 | +use PHP_CodeSniffer\Files\File; |
| 50 | +use PHP_CodeSniffer\Sniffs\Sniff; |
| 51 | +use function count, defined, in_array; |
52 | 52 |
|
53 | 53 |
|
54 | 54 | class OptimizeGlobalCallsSniff implements Sniff
|
@@ -307,7 +307,6 @@ private function isFunctionDeclaration(File $phpcsFile, int $stackPtr): bool
|
307 | 307 | }
|
308 | 308 |
|
309 | 309 |
|
310 |
| - // FIX: Re-added the missing method |
311 | 310 | private function isWithinUseStatement(int $stackPtr, array $existingUseStatements): bool
|
312 | 311 | {
|
313 | 312 | $allStatements = array_merge($existingUseStatements['functions'], $existingUseStatements['constants']);
|
@@ -606,12 +605,14 @@ private function hasNamespace(File $phpcsFile): bool
|
606 | 605 |
|
607 | 606 | private function isIgnoredConstant(string $constantName): bool
|
608 | 607 | {
|
609 |
| - $allIgnored = array_merge($this->builtInIgnoredConstants, $this->ignoredConstants); |
610 |
| - foreach ($allIgnored as $ignoredConstant) { |
611 |
| - if (strcasecmp($constantName, $ignoredConstant) === 0) { |
| 608 | + $ignored = array_merge($this->builtInIgnoredConstants, $this->ignoredConstants); |
| 609 | + foreach ($ignored as $pattern) { |
| 610 | + $regex = str_replace('\*', '.*', preg_quote($pattern, '/')); |
| 611 | + if (preg_match('/^' . $regex . '$/i', $constantName)) { |
612 | 612 | return true;
|
613 | 613 | }
|
614 | 614 | }
|
| 615 | + |
615 | 616 | return false;
|
616 | 617 | }
|
617 | 618 |
|
|
0 commit comments