Uploaded image for project: 'SonarPHP'
  1. SonarPHP
  2. SONARPHP-853

FP S1144 when anonymous nested class

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4
    • Component/s: Rules
    • Labels:
      None

      Description

      class A {
      
        private function f() { // Noncompliant
          $anonymousClass = new class(){}; // FP disappears if this line is removed
          echo "${foo->j()}";
        }
      
        private function j() {  // FP here
        }
      }
      

      Even though classes can't be nested, anonymous class can be nested. In this case we loose all the state on outer class. We should probably keep the stack of class info.

        Attachments

          Activity

            People

            Assignee:
            pierre-yves.nicolas Pierre-Yves Nicolas
            Reporter:
            elena.vilchik Elena Vilchik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: