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

Go to declaration does not work in some circumstances

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 12.6
    • None
    • php - Navigation
    • None
    • Windows 10 64-bit
      NetBeans 12.6 binaries
      PHP 7.4.27

    Description

      The issue seems appears for class file that has "use" statement that has first part of namespace and imported class file the same (MyTest in the following examples). I will describe some strange cases which happen when inclusion of such class name is used. In the following examples resolved/unresolved means class file can or cannot be navigated to in NetBeans using Ctrl-B key binding. Content of included files does not matter.

       
      1. With that contents TestHistory is not resolved:

      <?php
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      2. Adding comment in line with "use MyTest\Entity\MyTest;" makes TestStatus not resolved but others resolvable:

      <?php
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;   // test
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      3. Using "declare(strict_types=1);" makes TestOne not resolved:

      <?php
      
      declare(strict_types=1);
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      4. Placing strict types declaration right after opening php tag makes only TestTwo not resolved:

      <?php declare(strict_types=1);
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      5. Commenting strict types declaration with single comment makes any imported class after line with "use MyTest\Entity\MyTest;" not resolved:

      <?php
      
      //declare(strict_types=1);
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      6. Adding multi line comment before "use MyTest\Entity\MyTest;" also makes any imported class not resolved (but behaved differently during previous checks yielding only to some classes resolved and some not):

      <?php
      
      /**
       * 
       */
      
      declare(strict_types=1);
      
      namespace MyTest\Controller;
      
      use MyTest\Entity\MyTest;
      use MyTest\Entity\TestHistory;
      use MyTest\Entity\TestOne;
      use MyTest\Entity\TestStatus;
      use MyTest\Entity\TestTwo;
      
      class TestController
      {
      }
      

      There could be other combinations possible but I'm not gonna try every possible scenario as weird behavior is proven to be reproducible.

      Attachments

        Activity

          People

            Unassigned Unassigned
            olexpo Olexandr Ponomarenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: