Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 6 commits into from

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Sep 10, 2022

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:

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:

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:

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:

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:

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:

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
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
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
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
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
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 jrfnl force-pushed the PHP-8.2/account-for-true-type branch from 473de76 to 3e3620f Compare March 2, 2023 03:43
@jrfnl
Copy link
Contributor Author

jrfnl commented Mar 2, 2023

@gsherwood Could this please be earmarked for 3.8.0 ?

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#49

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the PHP-8.2/account-for-true-type branch December 2, 2023 02:12
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 8, 2023

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Release
Development

Successfully merging this pull request may close these issues.

2 participants