Skip to content

Support Variadic arguments #621

Closed
Closed

Description

@Taluu

With the following piece of code :

<?php

function (Foo ...$foos): void 
{
    foreach ($foos as $foo) {
    }
}

$foo is not recognized as a Foo, but unknown. And $foos is not recognized as an array of Foos, but a Foo. We have to add the /** @var Foo $foo */ in top of the foreach for that.

Having that would be great. :}

Activity

  1. dantleech commented on Dec 3, 2018

    @dantleech
    Collaborator

    Would be quite simple:

    1. The parameter is resolved here: https://github.com/phpactor/worse-reflection/blob/master/lib/Core/Inference/FrameBuilder/FunctionLikeWalker.php#L85
    2. We "just" need to add support to the SymbolContextResolver to return a symbol with type array<SomeType>
  2. dantleech commented on Dec 22, 2018

    @dantleech
    Collaborator

    Fixed in #681

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions