PHP 8.2.31
Preview: SuperfluousInterfaceNamingSniff.php Size: 1.63 KB
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/SuperfluousInterfaceNamingSniff.php

<?php declare(strict_types = 1);

namespace SlevomatCodingStandard\Sniffs\Classes;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use SlevomatCodingStandard\Helpers\ClassHelper;
use function sprintf;
use function strtolower;
use function substr;
use const T_INTERFACE;

class SuperfluousInterfaceNamingSniff implements Sniff
{

	public const CODE_SUPERFLUOUS_PREFIX = 'SuperfluousPrefix';
	public const CODE_SUPERFLUOUS_SUFFIX = 'SuperfluousSuffix';

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

	/**
	 * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
	 * @param int $interfacePointer
	 */
	public function process(File $phpcsFile, $interfacePointer): void
	{
		$interfaceName = ClassHelper::getName($phpcsFile, $interfacePointer);

		$this->checkPrefix($phpcsFile, $interfacePointer, $interfaceName);
		$this->checkSuffix($phpcsFile, $interfacePointer, $interfaceName);
	}

	private function checkPrefix(File $phpcsFile, int $interfacePointer, string $interfaceName): void
	{
		$prefix = substr($interfaceName, 0, 9);

		if (strtolower($prefix) !== 'interface') {
			return;
		}

		$phpcsFile->addError(sprintf('Superfluous prefix "%s".', $prefix), $interfacePointer, self::CODE_SUPERFLUOUS_PREFIX);
	}

	private function checkSuffix(File $phpcsFile, int $interfacePointer, string $interfaceName): void
	{
		$suffix = substr($interfaceName, -9);

		if (strtolower($suffix) !== 'interface') {
			return;
		}

		$phpcsFile->addError(sprintf('Superfluous suffix "%s".', $suffix), $interfacePointer, self::CODE_SUPERFLUOUS_SUFFIX);
	}

}

Directory Contents

Dirs: 0 × Files: 36

Name Size Perms Modified Actions
1.78 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.64 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.37 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.46 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.62 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
8.68 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
27.29 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.32 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.73 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.79 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.85 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
4.63 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.19 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.12 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.60 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.28 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.22 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
460 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
4.88 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.37 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
12.84 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.61 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.50 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
11.76 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
5.39 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.20 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
3.43 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.81 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.27 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.29 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.63 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.13 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
2.65 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
9.52 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download
306 B lrw-r--r-- 2025-09-13 08:53:30
Edit Download
1.76 KB lrw-r--r-- 2025-09-13 08:53:30
Edit Download

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