Skip to content

Support inclusion returns #662

Closed
Closed

Description

@Taluu

If I require a file, and it has a return, I should be able to have a context on it.

class Foo
{
    public function getBar() { }
}
<?php
return new Foo;
<?php
$foo = require 'get_foo.php';

$foo->getBar();

This can be used with the autoloader requirement or a bootstrap file ; it would be great to have a support. :}

Currently, we have to add a /** @var Foo $foo */ on top of the require instruction. It's not that bad though. :D

Activity

  1. dantleech commented on Dec 8, 2018

    @dantleech
    Collaborator

    PR for basic support: phpactor/worse-reflection#52

    Currently it supports simple sasignment as in this example and importing the scope of the included file. Doesn't support registering any new class definitions yet.

  2. dantleech commented on Dec 8, 2018

    @dantleech
    Collaborator

    Although that is merged, it won't work until the completion library is made aware of the path of the osurce code to complete, which is quite a big change #665

  3. added a commit that references this issue on Mar 1, 2020
  4. added a commit that references this issue on May 3, 2020
  5. dantleech commented on Aug 18, 2024

    @dantleech
    Collaborator

    fwiw the basic support was removed and won't be coming back soon (imagine legacy projects and 100s of include files all being analysed and you can see why). But also closing because old.

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