Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
- php-version: '8.2'
dependencies: highest
allowed-to-fail: true
variant: 'squizlabs/php_codesniffer:"dev-master"'
variant: 'squizlabs/php_codesniffer:"4.x-dev"'
- php-version: '8.3'
dependencies: highest
allowed-to-fail: true
variant: 'squizlabs/php_codesniffer:"dev-master"'
variant: 'squizlabs/php_codesniffer:"4.x-dev"'
- php-version: '8.4'
dependencies: highest
allowed-to-fail: true
variant: 'squizlabs/php_codesniffer:"dev-master"'
variant: 'squizlabs/php_codesniffer:"4.x-dev"'

steps:
- name: Checkout
Expand All @@ -58,6 +58,7 @@ jobs:
composer-options: "--prefer-dist --prefer-stable"

- name: Validate composer
if: matrix.variant == 'normal'
run: composer validate --strict --no-check-lock

- name: Check Code Style
Expand Down
25 changes: 25 additions & 0 deletions Swivl/Helpers/Common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Swivl\Helpers;

use PHP_CodeSniffer\Util\Common as SnifferCommon;

final class Common extends SnifferCommon
{
/**
* @var string[]
*/
public const SHORT_SCALAR_TYPES = ['int', 'bool'];

/**
* {@inheritDoc}
*/
public static function suggestType(string $varType)
{
if (in_array($varType, self::SHORT_SCALAR_TYPES, true)) {
return $varType;
}

return parent::suggestType($varType);
}
}
9 changes: 0 additions & 9 deletions Swivl/Helpers/TypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class TypeHelper
'traversable' => true,
];

private const SHORT_SCALAR_TYPES = ['int', 'bool'];

public static function isTypeTraversable(string $mixedType): bool
{
foreach (explode('|', self::normalizeType($mixedType)) as $type) {
Expand All @@ -33,13 +31,6 @@ public static function isTypeTraversable(string $mixedType): bool
return false;
}

public static function allowShortScalarTypes(): void
{
if ($missedScalarTypes = array_diff(self::SHORT_SCALAR_TYPES, Common::$allowedTypes)) {
Common::$allowedTypes = array_merge(Common::$allowedTypes, $missedScalarTypes);
}
}

public static function normalizeType(string $mixedType): string
{
if ($mixedType !== '' && $mixedType[0] === '?') {
Expand Down
7 changes: 0 additions & 7 deletions Swivl/Sniffs/Classes/FullyQualifiedClassNameUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ class FullyQualifiedClassNameUsageSniff implements Sniff
*/
protected $checkedPos = [];

/**
* A list of tokenizers this sniff supports.
*
* @var array
*/
public $supportedTokenizers = ['PHP'];

/**
* Returns an array of tokens this test wants to listen for.
*
Expand Down
7 changes: 0 additions & 7 deletions Swivl/Sniffs/Commenting/FullyQualifiedClassNameUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
*/
class FullyQualifiedClassNameUsageSniff implements Sniff
{
/**
* A list of tokenizers this sniff supports.
*
* @var array
*/
public $supportedTokenizers = ['PHP'];

/**
* Returns an array of tokens this test wants to listen for.
*
Expand Down
Loading