PhpStorm not detecting php library namespace

徘徊边缘 提交于 2019-12-02 02:59:46

There is no way that PhpStorm will read your binary .so file (.dll on Windows) and extract PHP interfaces from there (and by "PHP interface" I mean classes/functions/constants/etc that extension offers during runtime).

Therefore you would need to do the same as all other binary php extensions would do (e.g. Phalcon's DevTools) -- make stubs files.

Stub file is a limited PHP version of your classes/methods/functions/etc with (optional) full doc but empty bodies. You can Ctrl + Click on any standard PHP class (e.g. MySQL) and see yourself how it's done in PhpStorm (IDE will open corresponding stub file in another editor tab) .. or just browse their stub repository directly (thanks @DanFromGermany for the link -- https://github.com/JetBrains/phpstorm-stubs).

An example of such stub file would be (it covers the code from your example):

<?php

namespace JS;

class Context
{
    /**
     * Evaluate your JS code
     *
     * @param string $param JS code to evaluate
     * @return mixed
     */
    public function evaluate($param) {}
}

Just place such stub files somewhere in your project (or reference any other supported way -- e.g. via PHP | Include paths) -- this code is for IDE only.


Such stub files can be used by any IDE/editor that can parse source .php files and offer classes/functions from there in code completion. Therefore it makes perfect sense to ask developers of that PHP-JS to provide such stubs automatically (just like Phalcon devs do).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!