dpn517111 2017-03-23 09:15
浏览 20

我可以通过创建类冲突来扩展IDE建议吗?

If a library I use, have a class that extends 2 other classes by the use of __call(), only the main extended class gets it's methods listed in the objects suggestions.

I noticed that if I make another php file in the project, where I put a class with the same name and namespace, and let it extend the other class, the IDE don't know witch one of them I'm referring to and gives me the suggestions for both of them, that way it suggests the methods from both of the extended classes.

This works sometimes, but in some case the IDE is to smart, and somehow know that my class isn't the real one, and only shows methods from the main extendsion.

Is there a better way to tell the IDE that a class in the library have more functions that it seams? Or a way that at least works every time?

Example:

<?php // index.php
    include(__DIR__ . "/lib.php");
    $c = new c();
    echo $c->s_a();
    echo $c->s_b(); // Accepted by the IDE
    $d = new d();
    echo $d->s_a();
    echo $d->s_b(); // Not acceted by the IDE

<?php // lib.php
    class a {
        function s_a() { return "a";}
    }
    class b {
        function s_b() { return "b";}
    }
    class c extends a {
        public $b;
        function __construct() {
            $this->b = new b();
        }
        function __call($name, $arguments) {
            return call_user_func_array(array($this->b, $name), $arguments);
        }
    }
    class d extends c {}

<?php // fake.php
    class c extends b {};

For $c the IDE don't know if it should use class c from lib.php or from fake.php, so it gives be a list with the methods of both.

For $d the that is of class d that extends c, it somehow know that its class c in file lib.php, so $d->s_b() are not sugested.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大