Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -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());
}
}

View File

@@ -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?
*

View File

@@ -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.