PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

PHP 8.2 | Tokenizer, File, sniffs: account for new `true` type

Open jrfnl opened this issue 3 years ago • 0 comments

PHP 8.2 | Tokenizer/PHP: allow for true in union types

Previously, false and null were already allowed in union types. As of PHP 8.2, true has been added to the supported types in PHP and can also be used in union types. Also see: https://3v4l.org/ZpfID

This commit adjusts the Tokenizer to correctly retokenize the T_BITWISE_OR character to T_UNION_TYPE when true is included in a union type.

Includes unit tests.

Refs:

  • https://wiki.php.net/rfc/true-type

PHP 8.2 | File::getMethodProperties(): allow for true in types

As of PHP 8.2, true, false and null will be allowed as stand-alone types. true can now also be used in union types (was already allowed for false and null). The true and the false types are allowed to be nullable, the null type is not (but that's not the concern of this method). Also see: https://3v4l.org/ZpfID

This commit adjusts the File::getMethodProperties() method to take true into account. false and null were already handled due to these previously already being allowed in union types.

Includes unit tests.

Refs:

  • https://wiki.php.net/rfc/null-false-standalone-types
  • https://wiki.php.net/rfc/true-type

PHP 8.2 | File::getMethodParameters(): allow for true in types

As of PHP 8.2, true, false and null will be allowed as stand-alone types. true can now also be used in union types (was already allowed for false and null). The true and the false types are allowed to be nullable, the null type is not (but that's not the concern of this method). Also see: https://3v4l.org/ZpfID

This commit adjusts the File::getMethodParameters() method to take true into account. false and null were already handled due to these previously already being allowed in union types.

Includes unit tests.

Refs:

  • https://wiki.php.net/rfc/null-false-standalone-types
  • https://wiki.php.net/rfc/true-type

PHP 8.2 | File::getMemberProperties(): allow for true in types

As of PHP 8.2, true, false and null will be allowed as stand-alone types. true can now also be used in union types (was already allowed for false and null). The true and the false types are allowed to be nullable, the null type is not (but that's not the concern of this method). Also see: https://3v4l.org/ZpfID

This commit adjusts the File::getMemberProperties() method to take true into account. false and null were already handled due to these previously already being allowed in union types.

Includes unit tests.

Includes minor touch up of some pre-existing tests.

Refs:

  • https://wiki.php.net/rfc/null-false-standalone-types
  • https://wiki.php.net/rfc/true-type

PHP 8.2 | Generic/LowerCaseType: allow for stand-alone true/false/null

As of PHP 8.2, true, false and null will be allowed as stand-alone types. The true and the false types are allowed to be nullable, the null type is not (but that's not the concern of the sniff). Also see: https://3v4l.org/ZpfID

This commit adjusts the sniff to take true into account. false and null were already handled due to these previously already being allowed in union types.

Includes unit tests.

Refs:

  • https://wiki.php.net/rfc/null-false-standalone-types
  • https://wiki.php.net/rfc/true-type

PHP 8.2 | PSR12/NullableTypeDeclaration: allow for nullable true/false]

As of PHP 8.2, true, false and null will be allowed as stand-alone types. The true and the false types are allowed to be nullable, the null type is not (but that's not the concern of the sniff). Also see: https://3v4l.org/ZpfID

This adjusts the sniff to take these new types into account.

Includes unit tests.

Refs:

  • https://wiki.php.net/rfc/null-false-standalone-types
  • https://wiki.php.net/rfc/true-type

jrfnl avatar Sep 10 '22 07:09 jrfnl