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

PHP - formatting of unary operators adds extra space

    XMLWordPrintableJSON

Details

    Description

      Formatting of unary operators in PHP adds extra space around operator, where it is not wanted.

      Input:

      <?php
      
      $noSpace++;
      $spaces   ++;
      $afterIndexNoSpace[ 1 ]++;
      $afterIndexSpaces[ 1 ]   ++;
      
      ++$noSpace;
      ++   $spaces;
      ++  $afterIndex[ 1 ];
      1. In PHP project properties set Formatting - Use project specific options.
      2. Language: PHP, Category: Spaces
      3. Uncheck Around Operators - Unary Operators
      4. Format code

      Actual result:

      <?php
      
      $noSpace++; // OK
      $spaces ++; // Still one space left
      $afterIndexNoSpace[ 1 ] ++; // Space is added before ++
      $afterIndexSpaces[ 1 ] ++; // Still one space left before ++
      
      ++$noSpace;
      ++$spaces;
      ++$afterIndex[ 1 ];
      

      Expected result:

      <?php
      
      $noSpace++;
      $spaces++;
      $afterIndexNoSpace[ 1 ]++;
      $afterIndexSpaces[ 1 ]++;
      
      ++$noSpace;
      ++$spaces;
      ++$afterIndex[ 1 ];
      

      Attachments

        Issue Links

          Activity

            People

              junichi11 Junichi Yamamoto
              Kacer Tomáš Procházka
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 20m
                  20m