-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Predefine the find/replace values as these don't change within the loop. * Only call `str_replace()` once with arrays for find/replace.
- Loading branch information
Showing
1 changed file
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
* in a standard. | ||
* | ||
* @author Greg Sherwood <[email protected]> | ||
* @author Juliette Reinders Folmer <[email protected]> | ||
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) | ||
* @copyright 2024 PHPCSStandards and contributors | ||
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | ||
*/ | ||
|
||
|
@@ -46,14 +48,18 @@ public function __construct(Ruleset $ruleset) | |
{ | ||
$this->ruleset = $ruleset; | ||
|
||
$find = [ | ||
DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, | ||
'Sniff.php', | ||
]; | ||
$replace = [ | ||
DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, | ||
'Standard.xml', | ||
]; | ||
|
||
foreach ($ruleset->sniffs as $className => $sniffClass) { | ||
$file = Autoload::getLoadedFileName($className); | ||
$docFile = str_replace( | ||
DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR, | ||
DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR, | ||
$file | ||
); | ||
$docFile = str_replace('Sniff.php', 'Standard.xml', $docFile); | ||
$docFile = str_replace($find, $replace, $file); | ||
|
||
if (is_file($docFile) === true) { | ||
$this->docFiles[] = $docFile; | ||
|