Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public function process(File $phpcsFile, $pointer): void
return;
}

if ($this->shortNullable !== self::YES && SniffSettingsHelper::isEnabledByPhpVersion(null, 80000) === false) {
$this->shortNullable = self::YES;
}

$tokens = $phpcsFile->getTokens();

if ($tokens[$pointer]['code'] === T_VARIABLE) {
Expand Down
4 changes: 3 additions & 1 deletion doc/type-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Sniff provides the following settings:
* `enable`: either to enable or not this sniff. By default, it is enabled for PHP versions 8.0 or higher.
* `withSpacesAroundOperators`: `yes` requires spaces around `|` and `&`, `no` requires no space around `|`and `&`. None is set by default so both are enabled.
* `withSpacesInsideParentheses`: `yes` requires spaces inside parentheses, `no` requires no spaces inside parentheses. None is set by default so both are enabled.
* `shortNullable`: `yes` requires usage of `?` for nullable type hint, `no` disallows it. None is set by default so both are enabled.
* `shortNullable`: `yes` requires usage of `?` for nullable type hint, `no` disallows it. None is set by default so both are enabled. For PHP versions below 8.0 it is set to `yes` by default.
* `nullPosition`: `first` requires `null` on first position in the type hint, `last` requires last position. None is set by default so `null` can be everywhere.

#### SlevomatCodingStandard.TypeHints.LongTypeHints 🔧
Expand Down Expand Up @@ -138,6 +138,8 @@ Sniff provides the following settings:

#### SlevomatCodingStandard.TypeHints.UnionTypeHintFormat 🔧

Deprecated: Use `SlevomatCodingStandard.TypeHints.DNFTypeHintFormat` instead

Checks format of union type hints.

Sniff provides the following settings:
Expand Down
Loading