PHP 8.2.31
Preview: SniffSettingsHelper.php Size: 2.01 KB
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/SniffSettingsHelper.php

<?php declare(strict_types = 1);

namespace SlevomatCodingStandard\Helpers;

use PHP_CodeSniffer\Config;
use function array_filter;
use function array_map;
use function array_values;
use function is_string;
use function preg_match;
use function trim;
use const PHP_VERSION_ID;

/**
 * @internal
 */
class SniffSettingsHelper
{

	/**
	 * @param string|int $settings
	 */
	public static function normalizeInteger($settings): int
	{
		return (int) trim((string) $settings);
	}

	/**
	 * @param string|int|null $settings
	 */
	public static function normalizeNullableInteger($settings): ?int
	{
		return $settings !== null ? (int) trim((string) $settings) : null;
	}

	/**
	 * @param list<string> $settings
	 * @return list<string>
	 */
	public static function normalizeArray(array $settings): array
	{
		$settings = array_map(static fn (string $value): string => trim($value), $settings);
		$settings = array_filter($settings, static fn (string $value): bool => $value !== '');
		return array_values($settings);
	}

	/**
	 * @param array<int|string, int|string> $settings
	 * @return array<int|string, int|string>
	 */
	public static function normalizeAssociativeArray(array $settings): array
	{
		$normalizedSettings = [];
		foreach ($settings as $key => $value) {
			if (is_string($key)) {
				$key = trim($key);
			}
			if (is_string($value)) {
				$value = trim($value);
			}
			if ($key === '' || $value === '') {
				continue;
			}
			$normalizedSettings[$key] = $value;
		}

		return $normalizedSettings;
	}

	public static function isValidRegularExpression(string $expression): bool
	{
		return preg_match('~^(?:\(.*\)|\{.*\}|\[.*\])[a-z]*\z~i', $expression) !== 0
			|| preg_match('~^([^a-z\s\\\\]).*\\1[a-z]*\z~i', $expression) !== 0;
	}

	public static function isEnabledByPhpVersion(?bool $value, int $phpVersionLimit): bool
	{
		if ($value !== null) {
			return $value;
		}

		$phpVersion = Config::getConfigData('php_version') !== null ? (int) Config::getConfigData('php_version') : PHP_VERSION_ID;
		return $phpVersion >= $phpVersionLimit;
	}

}

Directory Contents

Dirs: 0 × Files: 41

Name Size Perms Modified Actions
1.11 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
8.67 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
10.15 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
6.25 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.60 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.14 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.00 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.18 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.03 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
430 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.52 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
10.20 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.03 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
7.12 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
502 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.97 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
16.55 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
7.34 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.84 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.80 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
893 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.27 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.56 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
6.39 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.32 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
15.13 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.48 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.20 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.01 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
485 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.27 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
4.97 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
12.87 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
774 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
740 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
966 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
10.67 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.53 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
7.82 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.03 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
9.28 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).