Permalink
Browse files

Check whether the constant is defined before using it.

  • Loading branch information...
1 parent a29aeeb commit d97fdd7601c7f6991d455ebd686ef72a36c72788 @sebastianbergmann committed Oct 25, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 PHPUnit/Util/Test.php
View
12 PHPUnit/Util/Test.php
@@ -162,12 +162,12 @@ public static function getExpectedException($className, $methodName)
$code = $annotations['method']['expectedExceptionCode'][0];
}
- if (isset($code)) {
- if (is_numeric($code)) {
- $code = (int)$code;
- } else {
- $code = (int)constant($code);
- }
+ if (is_numeric($code)) {
+ $code = (int)$code;
+ }
+
+ else if (is_string($code) && defined($code)) {
+ $code = (int)constant($code);
}
return array(

0 comments on commit d97fdd7

Please sign in to comment.