Page MenuHomePhabricator

ArcanistClassNameLiteralXHPASTLinterRule can produce incorrect results
Closed, ResolvedPublic

Description

On PHP 5.3, it is not possible to use self within a closure. As such, the patch suggested by ArcanistClassNameLiteralXHPASTLinterRule can be incorrect:

<?php

class SomeClass {
  public static function someMethod() {
    $closure = function() {
      SomeClass::someOtherMethod();
    };
    $closure();
  }

  public static function someOtherMethod() {
    echo __METHOD__."\n";
  }
}
<?php

class SomeClass {
  public static function someMethod() {
    $closure = function() {
      self::someOtherMethod();
    };
    $closure();
  }

  public static function someOtherMethod() {
    echo __METHOD__."\n";
  }
}