REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.96 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/src/Validation/RectorConfigValidator.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\Validation; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Exception\ShouldNotHappenException; final class RectorConfigValidator { /** * @param string[] $rectorClasses */ public static function ensureNoDuplicatedClasses(array $rectorClasses) : void { $duplicatedRectorClasses = self::resolveDuplicatedValues($rectorClasses); if ($duplicatedRectorClasses === []) { return; } throw new ShouldNotHappenException('Following rules are registered twice: ' . \implode(', ', $duplicatedRectorClasses)); } /** * @param mixed[] $skip */ public static function ensureRectorRulesExist(array $skip) : void { $nonExistingRules = []; $skippedRectorRules = []; foreach ($skip as $key => $value) { if (self::isRectorClassValue($key)) { if (\class_exists($key)) { $skippedRectorRules[] = $key; } else { $nonExistingRules[] = $key; } continue; } if (!self::isRectorClassValue($value)) { continue; } if (\class_exists($value)) { $skippedRectorRules[] = $value; continue; } $nonExistingRules[] = $value; } SimpleParameterProvider::addParameter(Option::SKIPPED_RECTOR_RULES, $skippedRectorRules); if ($nonExistingRules === []) { return; } $nonExistingRulesString = ''; foreach ($nonExistingRules as $nonExistingRule) { $nonExistingRulesString .= ' * ' . $nonExistingRule . \PHP_EOL; } throw new ShouldNotHappenException('These rules from "$rectorConfig->skip()" does not exist - remove them or fix their names:' . \PHP_EOL . $nonExistingRulesString); } /** * @param mixed $value */ private static function isRectorClassValue($value) : bool { // only validate string if (!\is_string($value)) { return \false; } // not regex path if (\strpos($value, '*') !== \false) { return \false; } // not if no Rector suffix if (\substr_compare($value, 'Rector', -\strlen('Rector')) !== 0) { return \false; } // not directory if (\is_dir($value)) { return \false; } // not file return !\is_file($value); } /** * @param string[] $values * @return string[] */ private static function resolveDuplicatedValues(array $values) : array { $counted = \array_count_values($values); $duplicates = []; foreach ($counted as $value => $count) { if ($count > 1) { $duplicates[] = $value; } } return \array_unique($duplicates); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 2
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
RectorAssert.php
2.68 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RectorConfigValidator.php
2.96 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).