Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #143 from mlively/issue/142
Browse files Browse the repository at this point in the history
Fix call to is_a to be compatible with php <= 5.3.9
  • Loading branch information
mlively committed May 5, 2014
2 parents 954cfbc + b76280f commit 917a5d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: php

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
Expand Down
15 changes: 13 additions & 2 deletions src/Phake.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,21 @@ public static function initAnnotations($obj)
*/
public static function assertValidMock($mock)
{
if (!$mock instanceof Phake_IMock && !is_a($mock, 'Phake_IMock', true))
if ($mock instanceof Phake_IMock)
{
return;
}

if (is_string($mock) && class_exists($mock, false))
{
throw new InvalidArgumentException("Received '" . (is_object($mock) ? get_class($mock) : $mock) . "' Expected an instance of Phake_IMock or the name of a class that implements Phake_IMock");
$reflClass = new ReflectionClass($mock);
if ($reflClass->implementsInterface('Phake_IMock'))
{
return;
}
}

throw new InvalidArgumentException("Received '" . (is_object($mock) ? get_class($mock) : $mock) . "' Expected an instance of Phake_IMock or the name of a class that implements Phake_IMock");
}

/**
Expand Down

0 comments on commit 917a5d1

Please sign in to comment.