Skip to content

Commit

Permalink
Merge pull request #686 from PHPCSStandards/feature/generator-minor-t…
Browse files Browse the repository at this point in the history
…weak

Generators/Generator: minor tweak
  • Loading branch information
jrfnl authored Nov 15, 2024
2 parents e11d8f2 + 76927ef commit 56784f1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Generators/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* in a standard.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
* @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
*/

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 56784f1

Please sign in to comment.