]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't use newInstanceWithoutConstructor in Arcanist unit test
authorepriestley <git@epriestley.com>
Tue, 20 Jan 2015 23:39:21 +0000 (15:39 -0800)
committerepriestley <git@epriestley.com>
Tue, 20 Jan 2015 23:39:21 +0000 (15:39 -0800)
Summary: This requires PHP 5.4. Use `newv()` instead. I don't think the "without constructor" part is meaningful (or desirable). Simplify slightly.

Test Plan: `arc unit --everything`

Reviewers: hach-que, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D11450

src/lint/linter/__tests__/ArcanistLinterTestCase.php

index 40cfe37513976e1cc2753cb01b08712f13bbcf99..4785d9e73753fe47c1378ade196a113170e8763a 100644 (file)
@@ -11,20 +11,13 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
    * @return ArcanistLinter
    */
   protected final function getLinter() {
-    $matches = array();
-
-    if (!preg_match('/^(\w+Linter)TestCase$/', get_class($this), $matches)) {
-      throw new Exception(pht('Unable to infer linter class name.'));
-    }
-
-    $linter = id(new ReflectionClass($matches[1]))
-      ->newInstanceWithoutConstructor();
-
-    if (!$linter instanceof ArcanistLinter) {
+    $matches = null;
+    if (!preg_match('/^(\w+Linter)TestCase$/', get_class($this), $matches) ||
+        !is_subclass_of($matches[1], 'ArcanistLinter')) {
       throw new Exception(pht('Unable to infer linter class name.'));
     }
 
-    return $linter;
+    return newv($matches[1], array());
   }
 
   public abstract function testLinter();