doujiexi1824 2017-07-11 14:31
浏览 122

Netbeans自动完成类方法

i've started a project working with Google Drive API, google libraries installed via composer, i primarly work with NetBeans IDE and i've never used object oriented PHP. I only worked with C# so i'm new to PHP. THe problem is that i got some class but autocomplete doesnt show any properties or methods of classes.

$files = $drive->files->listFiles(array())->getFiles();

OR

foreach ($files as $file){
      $res['name'] = $file->getName();
      $fileres[] = $res;
  }

It should like whisper methods getId() , getTrashed(), but it doesn't. I know that in Visual Studio this would work, but in NetBeans it doesn't. Is there any way to get autocomplete to work?

  • 写回答

1条回答 默认 最新

  • dongyou7472 2017-07-12 18:17
    关注

    The getFiles() method is documented to return Google_Service_Drive_DriveFile.

    This might be a documentation error. It is likely to return Google_Service_Drive_DriveFile[] (array of file objects) since that makes more sense... But I cannot test this right now.

    If that is indeed the case, you can hint the $file variable type like this:

    foreach ($files as $file) {
        /* @var $file Google_Service_Drive_DriveFile */
        $res['name'] = $file->getName();
        $fileres[] = $res;
    }
    

    Then you should get code-completion.

    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计