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

PHP Menu Source->Fix uses ignored strict_types line

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.5, 12.6
    • None
    • php - Editor
    • None

    Description

      As asked here: https://issues.apache.org/jira/browse/NETBEANS-4978

      Scenario:

      Netbeans 12.5 (old) created a bad php file with the Fix Use command, let says this one:

      <?php
      namespace \bar;
      use \foo;
      declare(strict_types=1); 
      
      class ....

      If in this file i have an other full namespace used somewhere that need to be inserted in the use lines, i use the Fix Use command.

      The problem is, in Netbeans 12.6, the Fix use command does not move the strict_types line. It will insert near the existing use line, like this one:

      <?php 
      namespace \bar; 
      use \foo; 
      use \newly\Inserted; 
      declare(strict_types=1);  

       

      Just parse the file (before class for example) and move the "declare(strict_types=1); " line at the top, whatever the file contains.

      declare(strict_types=1); MUST always be the FIRST line.

      Just reorder them properly:

      0)<?php
      1) declare(strict_types=1);
      2) namespace XXX
      3) use yyy

      Thanks

      Attachments

        Activity

          People

            junichi11 Junichi Yamamoto
            FFT Jayce
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: