Skip to content

Commit

Permalink
Prevent inheritance corner-cases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
paragonie-scott committed Apr 16, 2016
1 parent 934c70d commit e3753fe
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/error_polyfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ class Error extends Exception
}

if (!class_exists('TypeError', false)) {
class TypeError extends Error
{

if (is_subclass_of('Error', 'Exception')) {
class TypeError extends Error
{

}
} else {
class TypeError extends Exception
{

}
}
}

0 comments on commit e3753fe

Please sign in to comment.