Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4509

PHP - code completion for function returning array

    XMLWordPrintableJSON

    Details

      Description

      NetBeans support code completion for array items when their type is specified.
      Code completion does not work for methods which have return type array in signature and specific type in @return annotation.

      In following code methods from \SplFileInfo are offered for variable $file.

      /**
       * @param \SplFileInfo[] $files
       */
      function walkFiles(array $files) {
          foreach ($files as $file) {
              $file-> // Offers methods from \SplFileInfo
          }
      }
      

      In following code is expected same behavior, but no methods are offered.

      /**
       * @return \SplFileInfo[]
       */
      function getFiles(): array { }
      
      foreach (getFiles() as $file) {
          $file-> // Does not offer methods from \SplFileInfo
      }
      

      If return type is removed from getFiles() method, then methods are offered for $file.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Kacer Tomáš Procházka
                Reporter:
                Kacer Tomáš Procházka
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h