public static function PHPUnit_Util_DeprecatedFeature_Logger::log

This is the publically accessible API for notifying the system that a deprecated feature has been used.

If it is run via a TestRunner and the test extends PHPUnit_Framework_TestCase, then this will inject the result into the test runner for display, if not, it will throw the notice to STDERR.

Parameters

string $message:

int|bool $backtraceDepth:

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/DeprecatedFeature/Logger.php, line 77

Class

PHPUnit_Util_DeprecatedFeature_Logger
Test Listener that tracks the usage of deprecated features.

Code

public static function log($message, $backtraceDepth = 2) {
  if ($backtraceDepth !== FALSE) {
    $trace = debug_backtrace(FALSE);
    if (is_int($backtraceDepth)) {
      $traceItem = $trace[$backtraceDepth];
    }
    if (!isset($traceItem['file'])) {
      $reflectionClass = new ReflectionClass($traceItem['class']);
      $traceItem['file'] = $reflectionClass
        ->getFileName();
    }
    if (!isset($traceItem['line']) && isset($traceItem['class']) && isset($traceItem['function'])) {
      if (!isset($reflectionClass)) {
        $reflectionClass = new ReflectionClass($traceItem['class']);
      }
      $method = $reflectionClass
        ->getMethod($traceItem['function']);
      $traceItem['line'] = '(between ' . $method
        ->getStartLine() . ' and ' . $method
        ->getEndLine() . ')';
    }
  }
  $deprecatedFeature = new PHPUnit_Util_DeprecatedFeature($message, $traceItem);
  if (self::$currentTest instanceof PHPUnit_Framework_TestCase) {
    $result = self::$currentTest
      ->getTestResultObject();
    $result
      ->addDeprecatedFeature($deprecatedFeature);
  }
  else {
    file_put_contents('php://stderr', $deprecatedFeature);
  }
}