Skip to content

[completion] Don't truncate union types #711

Closed

Description

@weirdan

When completing a variable typed as A|B (either from docblock or catch typehint union) phpactor only shows A in completion menu item description.

Activity

  1. dantleech commented on Jan 17, 2019

    @dantleech
    Collaborator

    👍 catch typehint union is not supported yet (but looks like it's supported by the parser) https://github.com/phpactor/worse-reflection/blob/master/lib/Core/Inference/FrameBuilder/CatchWalker.php

  2. dantleech commented on Jan 17, 2019

    @dantleech
    Collaborator

    Also in develop this seems to work:
    untitled

    Is there a specific scenario?

  3. weirdan commented on Jan 17, 2019

    @weirdan
    ContributorAuthor

    image

    phpactor completion is used through ncm2, with phpactor/ncm2-phpactor bridge

    Invoking completion directly from cli, I'm getting this:

    $  ~/.config/nvim/bundle/phpactor/bin/phpactor complete --format=json src/App/src/Q.php 141 | jq
    {
      "suggestions": [
        {
          "type": "variable",
          "name": "$v",
          "label": "$v",
          "short_description": "float",
          "class_import": null,
          "range": null,
          "info": "float"
        },
        {
          "type": "variable",
          "name": "$p",
          "label": "$p",
          "short_description": "null",
          "class_import": null,
          "range": null,
          "info": "null"
        },
        {
          "type": "variable",
          "name": "$this",
          "label": "$this",
          "short_description": "Q",
          "class_import": null,
          "range": null,
          "info": "Q"
        }
      ],
      "issues": []
    }

    So it does appear to be a problem with the phpactor itself.

    Phpactor version: dev-develop@660eb584fcf228e627c94b1894b39e7b12a69a9b

  4. weirdan commented on Jan 17, 2019

    @weirdan
    ContributorAuthor

    If I omit var name in @var annotation I do get a union (as in your example). If it's included (as it is in mine) menu only shows the first union member.

    image

    image

  5. dantleech commented on Jan 19, 2019

    @dantleech
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions