Add support for the mixed type by kocsismate · Pull Request #5313 · php/php-src

carusogabriel

@kocsismate kocsismate changed the title [WIP] Add support for the mixed type Add support for the mixed type

Mar 29, 2020

carusogabriel

nikic

nikic

@kocsismate

nikic

nikic

@kocsismate

@nikic nikic mentioned this pull request

May 23, 2020

2 tasks

TysonAndre added a commit to TysonAndre/php-src that referenced this pull request

May 25, 2020
Fixes an edge case overlooked in
php#5313

Generators are objects, so `object` should have also been allowed in addition to
`iterable` and `Traversable`

php-pulls pushed a commit that referenced this pull request

May 26, 2020
Fixes an edge case overlooked in
#5313

Generators are objects, so `object` should have also been allowed in addition to
`iterable` and `Traversable`

Closes GH-5626

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request

Aug 23, 2020
As of PHP 8.0, `mixed` can be used as a parameter type for function declarations.

The RFC explicitly does not allow for the `mixed` type to be combined with the nullability indicator.
While in itself, that is not a cross-version compatibility issue, I have made a very conscious choice to add a check for this anyway as - while discouraged with `mixed` being a soft reserved keyword -, prior to PHP 8, a class _could_ be named `mixed`, so a `?Mixed` type hint referring to such a class could exist in code and would be a cross-version compatibility issue as since PHP 8 that will throw a "Fatal error: Mixed types cannot be nullable".

Refs:
* https://wiki.php.net/rfc/mixed_type_v2
* php/php-src#5313
* php/php-src@aec4c0f

Includes unit tests.

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request

Aug 23, 2020
As of PHP 8.0, `mixed` can be used as a return type for function declarations.

The RFC explicitly does not allow for the `mixed` type to be combined with the nullability indicator.
While in itself, that is not a cross-version compatibility issue, I have made a very conscious choice to add a check for this anyway as - while discouraged with `mixed` being a soft reserved keyword -, prior to PHP 8, a class _could_ be named `mixed`, so a `?Mixed` type hint referring to such a class could exist in code and would be a cross-version compatibility issue as since PHP 8 that will throw a "Fatal error: Mixed types cannot be nullable".

Refs:
* https://wiki.php.net/rfc/mixed_type_v2
* php/php-src#5313
* php/php-src@aec4c0f

Includes unit tests.
Includes removing the `testNoViolationsInFileOnValidVersion()` test as the sniff will now throw errors either way.

jrfnl added a commit to PHPCompatibility/PHPCompatibility that referenced this pull request

Aug 23, 2020
As of PHP 8.0, `mixed` can be used as a type for property declarations.

The RFC explicitly does not allow for the `mixed` type to be combined with the nullability indicator.
While in itself, that is not a cross-version compatibility issue, I have made a very conscious choice to add a check for this anyway as - while discouraged with `mixed` being a soft reserved keyword -, prior to PHP 8, a class _could_ be named `mixed`, so a `?Mixed` type hint referring to such a class could exist in code and would be a cross-version compatibility issue as since PHP 8 that will throw a "Fatal error: Mixed types cannot be nullable".

Refs:
* https://wiki.php.net/rfc/mixed_type_v2
* php/php-src#5313
* php/php-src@aec4c0f

Includes unit tests.

@jrfnl jrfnl mentioned this pull request

Aug 24, 2020