Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Util/Standards.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,26 @@ public static function isInstalledStandard($standard)
* CodeSniffer/Standards directory. Valid coding standards
* include a ruleset.xml file.
*
* @param string $standard The name of the coding standard.
* @param string|\SimpleXMLElement $standard The name of the coding standard.
*
* @return string|null
*/
public static function getInstalledStandardPath($standard)
{
$installedPaths = self::getInstalledStandardPaths();
$standard = (string) $standard;

if (strpos($standard, '.') !== false) {
return null;
}

foreach ($installedPaths as $installedPath) {
$standardPath = $installedPath.DIRECTORY_SEPARATOR.$standard;
if (file_exists($standardPath) === false && basename($installedPath) === $standard) {
if (file_exists($standardPath) === false) {
if (basename($installedPath) !== (string) $standard) {
continue;
}

$standardPath = $installedPath;
}

Expand All @@ -278,7 +288,7 @@ public static function getInstalledStandardPath($standard)
return $path;
}
}
}
}//end foreach

return null;

Expand Down