Upgrade framework
This commit is contained in:
@@ -22,4 +22,9 @@ abstract class BaseMatcher implements Matcher
|
||||
{
|
||||
return StringDescription::toString($this);
|
||||
}
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
return call_user_func_array(array($this, 'matches'), func_get_args());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,29 @@ class IsNumeric extends IsTypeOf
|
||||
|
||||
public function matches($item)
|
||||
{
|
||||
if ($this->isHexadecimal($item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return is_numeric($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the string passed is a valid hexadecimal number.
|
||||
* This check is necessary because PHP 7 doesn't recognize hexadecimal string as numeric anymore.
|
||||
*
|
||||
* @param mixed $item
|
||||
* @return boolean
|
||||
*/
|
||||
private function isHexadecimal($item)
|
||||
{
|
||||
if (is_string($item) && preg_match('/^0x(.*)$/', $item, $matches)) {
|
||||
return ctype_xdigit($matches[1]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the value a numeric?
|
||||
*
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace Hamcrest;
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
public static function registerGlobalFunctions()
|
||||
{
|
||||
require_once __DIR__.'/../Hamcrest.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the item with an IsEqual matcher if it isn't a matcher already.
|
||||
|
||||
Reference in New Issue
Block a user