summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott <scott@paragonie.com>2016-04-16 15:05:28 -0400
committerScott <scott@paragonie.com>2016-04-16 15:05:28 -0400
commite3753feef45113b5db7da162ac23e8cd4633df92 (patch)
tree84f381090a9fc55cbb7be76448b25b42d67a9c4e
parent934c70de256739711ca9a7499466ea0baff72cb7 (diff)
downloadrandom_compat-e3753feef45113b5db7da162ac23e8cd4633df92.zip
random_compat-e3753feef45113b5db7da162ac23e8cd4633df92.tar.gz
random_compat-e3753feef45113b5db7da162ac23e8cd4633df92.tar.bz2
Prevent inheritance corner-cases
What if a PHP 5 project defines Error? And it's a singleton, not an exception? And we need to throw a TypeError? This resolves that corner case.
-rw-r--r--lib/error_polyfill.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/error_polyfill.php b/lib/error_polyfill.php
index 57cfefd..b5257b3 100644
--- a/lib/error_polyfill.php
+++ b/lib/error_polyfill.php
@@ -35,8 +35,15 @@ if (!class_exists('Error', false)) {
}
if (!class_exists('TypeError', false)) {
- class TypeError extends Error
- {
-
+ if (is_subclass_of('Error', 'Exception')) {
+ class TypeError extends Error
+ {
+
+ }
+ } else {
+ class TypeError extends Exception
+ {
+
+ }
}
}