bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.63k stars 94 forks source link

.phpstorm.meta.php in subdirectories not found #1384

Closed sminnee closed 1 year ago

sminnee commented 4 years ago

Describe the bug In PHPStorm, a .phpstorm.meta.php file can be provided not only in the project root but in any subfolder. Notably, this means that composer packages are able to provide their own .phpstorm.meta.php file with hints for that package.

To Reproduce

Expected behavior

sminnee commented 4 years ago

If this would be too hard, is it possible to use include(), require(), or require_once() in these files?

stableford-catch commented 4 years ago

I think i'm also having the same issue, I want to load .phpstorm.meta.php config contained in the following composer packages.

If/when using phpstorm + symfony those packages are bundled into the phpstorm symfony extension.

After I add them as composer dependencies using

composer require thomas-schulz/symfony-meta --dev
composer require thomas-schulz/doctrine-phpstorm-meta --dev

I can see that the the following .phpstorm.meta.php files can be found inside the vendor/ folder.

$ find vendor -name ".phpstorm.meta.php"

vendor/thomas-schulz/doctrine-phpstorm-meta/dbal/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/annotations/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/orm/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/collections/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Psr/Log/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Monolog/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bridge/PhpUnit/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bridge/Twig/Mime/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpKernel/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Form/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpClient/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Validator/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Config/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Security/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/ExpressionLanguage/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Ldap/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/PropertyInfo/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/EventDispatcher/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Templating/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Finder/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Workflow/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/DomCrawler/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Yaml/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Mime/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/OptionsResolver/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Routing/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/CssSelector/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/VarDumper/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/DependencyInjection/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpFoundation/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Process/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Console/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/WebServerBundle/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/FrameworkBundle/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/WebProfilerBundle/.phpstorm.meta.php

As far as I can tell though the intelephense plugin isn't loading them.

vipinbose commented 2 years ago

I think i'm also having the same issue, I want to load .phpstorm.meta.php config contained in the following composer packages.

If/when using phpstorm + symfony those packages are bundled into the phpstorm symfony extension.

After I add them as composer dependencies using

composer require thomas-schulz/symfony-meta --dev
composer require thomas-schulz/doctrine-phpstorm-meta --dev

I can see that the the following .phpstorm.meta.php files can be found inside the vendor/ folder.

$ find vendor -name ".phpstorm.meta.php"

vendor/thomas-schulz/doctrine-phpstorm-meta/dbal/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/annotations/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/orm/.phpstorm.meta.php
vendor/thomas-schulz/doctrine-phpstorm-meta/collections/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Psr/Log/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Monolog/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bridge/PhpUnit/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bridge/Twig/Mime/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpKernel/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Form/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpClient/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Validator/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Config/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Security/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/ExpressionLanguage/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Ldap/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/PropertyInfo/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/EventDispatcher/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Templating/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Finder/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Workflow/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/DomCrawler/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Yaml/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Mime/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/OptionsResolver/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Routing/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/CssSelector/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/VarDumper/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/DependencyInjection/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/HttpFoundation/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Process/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Component/Console/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/WebServerBundle/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/FrameworkBundle/.phpstorm.meta.php
vendor/thomas-schulz/symfony-meta/Symfony/Bundle/WebProfilerBundle/.phpstorm.meta.php

As far as I can tell though the intelephense plugin isn't loading them.

Any solution for this

bmewburn commented 1 year ago

there are no plans to further support phpstorm metadata.

sminnee commented 1 year ago

Is there an alternative metadata format for VSCode that is able to be included in subdirectories?

bmewburn commented 1 year ago

There were 2 cases were phpstorm metadata was understood by this extension.

  1. Mapping a parameter type or type name to a return type
  2. Mapping an arbitrary parameter string value to a return type

This extension will move towards providing this all via a phpdoc type system.

Case 1 is solved by templates which were added in 1.9. A vendor can type classes, traits, interfaces, functions, methods, properties with template syntax or a user can provide a stub to override the vendor declaration. For example, using a method in the linked framework/issue, it can be annotated like so:

namespace SilverStripe\Core\Injector;
class Injector implements ContainerInterface
{
  /**
     *
     * @template T of object
     *
     * @param class-string<T> $name
     * @param mixed ...$argument arguments to pass to the constructor
     * @return T A new instance of the specified object
     */
    public function create($name, $argument = null) { }
}

case 2 will have a similar solution in a future release.

levacic commented 1 year ago

This extension will move towards providing this all via a phpdoc type system.

Does this mean that existing support for PhpStorm metadata will be removed?

bmewburn commented 1 year ago

likely in some future release

levacic commented 1 year ago

In that case, would you be able to provide some kind of guide on how users can provide stubs to override declarations for third-party dependencies? I've tried looking through the docs, but couldn't find anything.