You are here

public static function Handle::register in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Assertion/Handle.php \Drupal\Component\Assertion\Handle::register()

Registers uniform assertion handling.

4 calls to Handle::register()
bootstrap.php in core/tests/bootstrap.php
Autoloader for Drupal PHPUnit testing.
DrupalKernel::bootEnvironment in core/lib/Drupal/Core/DrupalKernel.php
Setup a consistent PHP environment.
example.settings.local.php in sites/example.settings.local.php
Local development override configuration feature.
TestBase::run in core/modules/simpletest/src/TestBase.php
Run all tests in this class.

File

core/lib/Drupal/Component/Assertion/Handle.php, line 54
Contains \Drupal\Component\Assertion\Handle.

Class

Handle
Handler for runtime assertion failures.

Namespace

Drupal\Component\Assertion

Code

public static function register() {

  // Since we're using exceptions, turn error warnings off.
  assert_options(ASSERT_WARNING, FALSE);
  if (version_compare(PHP_VERSION, '7.0.0-dev') < 0) {

    // PHP 5 - create a handler to throw the exception directly.
    assert_options(ASSERT_CALLBACK, function ($file = '', $line = 0, $code = '', $message = '') {
      if (empty($message)) {
        $message = $code;
      }
      throw new \AssertionError($message, 0, NULL, $file, $line);
    });
  }
  else {

    // PHP 7 - just turn exception throwing on.
    assert_options(ASSERT_EXCEPTION, TRUE);
  }
}