PHP 8.2.31
Preview: DisallowPartiallyKeyedSniff.php Size: 1008 B
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Arrays/DisallowPartiallyKeyedSniff.php

<?php declare(strict_types = 1);

namespace SlevomatCodingStandard\Sniffs\Arrays;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use SlevomatCodingStandard\Helpers\ArrayHelper;
use SlevomatCodingStandard\Helpers\TokenHelper;

class DisallowPartiallyKeyedSniff implements Sniff
{

	public const CODE_DISALLOWED_PARTIALLY_KEYED = 'DisallowedPartiallyKeyed';

	/**
	 * @return array<int, (int|string)>
	 */
	public function register(): array
	{
		return TokenHelper::ARRAY_TOKEN_CODES;
	}

	/**
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
	 * @param int $stackPointer
	 */
	public function process(File $phpcsFile, $stackPointer): void
	{
		$keyValues = ArrayHelper::parse($phpcsFile, $stackPointer);

		if (!ArrayHelper::isKeyed($keyValues)) {
			return;
		}

		if (ArrayHelper::isKeyedAll($keyValues)) {
			return;
		}

		$phpcsFile->addError('Partially keyed array disallowed.', $stackPointer, self::CODE_DISALLOWED_PARTIALLY_KEYED);
	}

}

Directory Contents

Dirs: 0 × Files: 7

Name Size Perms Modified Actions
2.19 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.85 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
8.10 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1008 B 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
6.77 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.14 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download

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