From 850b9eebefb4bea2a9f0a707214c456c781252db Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 22 Aug 2016 13:03:07 +0100 Subject: [PATCH] Issue #2787567 by alexpott: Refactor \Drupal\Component\Assertion\Handle to not break PSR-0/4 one class per file --- .../lib/Drupal/Component/Assertion/Handle.php | 42 ++----------------- .../Assertion/global_namespace_php5.php | 28 +++++++++++++ 2 files changed, 32 insertions(+), 38 deletions(-) create mode 100644 core/lib/Drupal/Component/Assertion/global_namespace_php5.php diff --git a/core/lib/Drupal/Component/Assertion/Handle.php b/core/lib/Drupal/Component/Assertion/Handle.php index dd9911e6a398..5069b6b4677e 100644 --- a/core/lib/Drupal/Component/Assertion/Handle.php +++ b/core/lib/Drupal/Component/Assertion/Handle.php @@ -1,41 +1,6 @@ file = $file; - $this->line = $line; - } - - } -} - -} - -namespace Drupal\Component\Assertion { +namespace Drupal\Component\Assertion; /** * Handler for runtime assertion failures. @@ -56,6 +21,9 @@ class Handle { assert_options(ASSERT_WARNING, FALSE); if (version_compare(PHP_VERSION, '7.0.0-dev') < 0) { + if (!class_exists('AssertionError', FALSE)) { + require __DIR__ . '/global_namespace_php5.php'; + } // PHP 5 - create a handler to throw the exception directly. assert_options(ASSERT_CALLBACK, function($file = '', $line = 0, $code = '', $message = '') { if (empty($message)) { @@ -71,5 +39,3 @@ class Handle { } } - -} diff --git a/core/lib/Drupal/Component/Assertion/global_namespace_php5.php b/core/lib/Drupal/Component/Assertion/global_namespace_php5.php new file mode 100644 index 000000000000..1b5caf46eafb --- /dev/null +++ b/core/lib/Drupal/Component/Assertion/global_namespace_php5.php @@ -0,0 +1,28 @@ +file = $file; + $this->line = $line; + } + +}