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.0 | Add support for union types #168

Merged
merged 12 commits into from
Jul 17, 2020
Merged

Commits on Jul 15, 2020

  1. Configuration menu
    Copy the full SHA
    2302d69 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2020

  1. Collections: deprecate $parameterTypeTokens in favour of parameterTyp…

    …eTokens()
    
    Deprecate the `$parameterTypeTokens` property in favour of a new `Collections::parameterTypeTokens()` method.
    
    PHPCS is expected to introduce a new `T_TYPE_UNION` token. As that token would not always be available, a property can't handle this.
    
    In anticipation of the introduction of the new token, I'm deprecating the `Collections::$parameterTypeTokens` property straight away to prevent BC breaks at a later point.
    
    Includes adding unit tests for the new method.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    8fa856b View commit details
    Browse the repository at this point in the history
  2. PHP 8.0 | Collection::parameterTypeTokens[BC](): add support for unio…

    …n types
    
    Includes adjusted unit test.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    ea70634 View commit details
    Browse the repository at this point in the history
  3. Collections: deprecate $propertyTypeTokens in favour of propertyTypeT…

    …okens()
    
    Deprecate the `$propertyTypeTokens` property in favour of a new `Collections::propertyTypeTokens()` method.
    
    PHPCS is expected to introduce a new `T_TYPE_UNION` token. As that token would not always be available, a property can't handle this.
    
    In anticipation of the introduction of the new token, I'm deprecating the `Collections::$propertyTypeTokens` property straight away to prevent BC breaks at a later point.
    
    Includes adding unit tests for the new method.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    b3f7e68 View commit details
    Browse the repository at this point in the history
  4. PHP 8.0 | Collection::propertyTypeTokens[BC](): add support for union…

    … types
    
    Includes adjusted unit test.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    27d5bed View commit details
    Browse the repository at this point in the history
  5. Collections: deprecate $returnTypeTokens in favour of returnTypeTokens()

    Deprecate the `$returnTypeTokens` property in favour of a new `Collections::returnTypeTokens()` method.
    
    PHPCS is expected to introduce a new `T_TYPE_UNION` token. As that token would not always be available, a property can't handle this.
    
    In anticipation of the introduction of the new token, I'm deprecating the `Collections::$returnTypeTokens` property straight away to prevent BC breaks at a later point.
    
    Includes adding unit tests for the new method.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    311a2d5 View commit details
    Browse the repository at this point in the history
  6. PHP 8.0 | Collection::returnTypeTokens[BC](): add support for union t…

    …ypes
    
    In addition to the other tokens needed to support union types, the `returnTypeTokens[BC]()` methods also needs the `T_ARRAY` token as the `array` keyword in union type return types is not always correctly re-tokenized to `T_STRING`.
    
    A change to the PHPCS tokenizer to mitigate this will be pulled upstream, but until that PR has been merged, `T_ARRAY` will continue to be needed.
    
    This changes the versions supported by the `returnTypeTokens()` method from "minimum PHPCS 3.5.4" to "minimum 3.3.0", which also brings the method more in line with the `parameterTypeTokens()` and the `propertyTypeTokens()` methods.
    
    Includes adjusted unit tests.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    9158cc7 View commit details
    Browse the repository at this point in the history
  7. FunctionDeclarations::getParameters(): add support for PHP 8 "union" …

    …types
    
    This commit adds support for union types to the `FunctionDeclarations::getParameters()` method.
    
    Changes along the same lines as included in this PR will also be pulled upstream to PHPCS itself. Once the upstream PR has been merged, those changes will also be applied to the `BCFile::getMethodParameters()` method.
    
    Includes extensive unit tests.
    
    Ref: https://wiki.php.net/rfc/union_types_v2
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    fb18be6 View commit details
    Browse the repository at this point in the history
  8. FunctionDeclarations::getProperties(): add tests verifying support fo…

    …r PHP 8 "union" types
    
    The commit which added union type support to the `Collections::returnTypeTokens[BC]()` methods implicitly added support for union types to the `FunctionDeclarations::getProperties()` method.
    
    This commit adds extensive unit tests to safeguard this support.
    
    The same commit also _silently_ added support for union types to the `BCFile::getMethodProperties()` method. Union types are not supported yet in PHPCS itself and until they are, the fact that the `BCFile::getMethodProperties()` method supports them should be regarded as an artefact and not as official support.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    6584ce4 View commit details
    Browse the repository at this point in the history
  9. Variables::getMemberProperties(): add tests verifying support for PHP…

    … 8 "union" types
    
    The commit which added union type support to the `Collections::propertyTypeTokens[BC]()` methods implicitly added support for union types to the `Variables::getMemberProperties()` method.
    
    This commit adds extensive unit tests to safeguard this support.
    
    The same commit also _silently_ added support for union types to the `BCFile::getMemberProperties()` method. Union types are not supported yet in PHPCS itself and until they are, the fact that the `BCFile::getMemberProperties()` method supports them should be regarded as an artefact and not as official support.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    d00a5b7 View commit details
    Browse the repository at this point in the history
  10. FunctionDeclarations::isArrowFunction(): add tests verifying support …

    …for union types
    
    Adds tests, same as wil be pulled upstream, to the tests for the `FunctionDeclarations::isArrowFunction()` and the `FunctionDeclarations::getArrowFunctionOpenClose()` methods to verify and safeguard support for arrow functions using union type declarations.
    jrfnl committed Jul 17, 2020
    Configuration menu
    Copy the full SHA
    6b3bbef View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    38ad2b0 View commit details
    Browse the repository at this point in the history