modifs.mineures sans commentaires
This commit is contained in:
parent
aef0533d9b
commit
24ecb913dc
@ -59,9 +59,10 @@ class func {
|
||||
* @param bool $strict vérifier l'inexistence de la classe et l'existence de
|
||||
* la fonction (ne pas uniquement faire une vérification syntaxique)
|
||||
*/
|
||||
static function verifix_function(&$func, bool $strict=true, ?string &$reason=null): bool {
|
||||
static function verifix_function(&$func, ?array &$args=null, bool $strict=true, ?string &$reason=null): bool {
|
||||
if ($strict) $reason = null;
|
||||
if ($func instanceof ReflectionFunction) return true;
|
||||
$rargs = null;
|
||||
if (is_string($func)) {
|
||||
$c = false;
|
||||
$f = $func;
|
||||
@ -70,6 +71,7 @@ class func {
|
||||
$c = $func[0];
|
||||
if (!array_key_exists(1, $func)) return false;
|
||||
$f = $func[1];
|
||||
$rargs = array_slice($func, 2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -90,6 +92,7 @@ class func {
|
||||
}
|
||||
}
|
||||
$func = [false, $f];
|
||||
if ($rargs) $args = cl::merge($rargs, $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -98,7 +101,7 @@ class func {
|
||||
* {@link self::verifix_function()}
|
||||
*/
|
||||
static function is_function($func, bool $strict=true, ?string &$reason=null): bool {
|
||||
return self::verifix_function($func, $strict, $reason);
|
||||
return self::verifix_function($func, $args, $strict, $reason);
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@ -115,9 +118,10 @@ class func {
|
||||
* @param bool $strict vérifier l'existence de la classe (ne pas uniquement
|
||||
* faire une vérification syntaxique)
|
||||
*/
|
||||
static function verifix_class(&$func, bool $strict=true, ?string &$reason=null): bool {
|
||||
static function verifix_class(&$func, ?array &$args=null, bool $strict=true, ?string &$reason=null): bool {
|
||||
if ($strict) $reason = null;
|
||||
if ($func instanceof ReflectionClass) return true;
|
||||
$rargs = null;
|
||||
if (is_string($func)) {
|
||||
$c = $func;
|
||||
$f = false;
|
||||
@ -126,6 +130,7 @@ class func {
|
||||
$c = $func[0];
|
||||
if (!array_key_exists(1, $func)) return false;
|
||||
$f = $func[1];
|
||||
$rargs = array_slice($func, 2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -139,6 +144,7 @@ class func {
|
||||
return false;
|
||||
}
|
||||
$func = [$c, false];
|
||||
if ($rargs) $args = cl::merge($rargs, $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -147,7 +153,7 @@ class func {
|
||||
* {@link self::verifix_class()}
|
||||
*/
|
||||
static function is_class($func, bool $strict=true, ?string &$reason=null): bool {
|
||||
return self::verifix_class($func, $strict, $reason);
|
||||
return self::verifix_class($func, $args, $strict, $reason);
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@ -198,14 +204,16 @@ class func {
|
||||
* liée à une classe avant d'être utilisée
|
||||
*
|
||||
* @param bool $strict vérifier l'existence de la classe et de la méthode si
|
||||
* @param array|null &$args
|
||||
* la méthode est liée (ne pas uniquement faire une vérification syntaxique)
|
||||
*/
|
||||
static function verifix_static(&$func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
static function verifix_static(&$func, ?array &$args = null, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
if ($strict) $reason = null;
|
||||
if ($func instanceof ReflectionMethod) {
|
||||
$bound = false;
|
||||
return true;
|
||||
}
|
||||
$rargs = null;
|
||||
if (is_string($func)) {
|
||||
if (!self::_parse_c_static($func, $c, $f, $bound)) return false;
|
||||
$cf = [$c, $f];
|
||||
@ -252,6 +260,7 @@ class func {
|
||||
self::_parse_static($f);
|
||||
}
|
||||
$cf[1] = $f;
|
||||
$rargs = array_slice($func, 2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -274,6 +283,7 @@ class func {
|
||||
}
|
||||
}
|
||||
$func = $cf;
|
||||
if ($rargs) $args = cl::merge($rargs, $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -282,7 +292,7 @@ class func {
|
||||
* {@link self::verifix_static()}
|
||||
*/
|
||||
static function is_static($func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
return self::verifix_static($func, $strict, $bound, $reason);
|
||||
return self::verifix_static($func, $args, $strict, $bound, $reason);
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@ -335,12 +345,13 @@ class func {
|
||||
* @param bool $strict vérifier l'existence de la classe et de la méthode si
|
||||
* la méthode est liée (ne pas uniquement faire une vérification syntaxique)
|
||||
*/
|
||||
static function verifix_method(&$func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
static function verifix_method(&$func, ?array &$args=null, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
if ($strict) $reason = null;
|
||||
if ($func instanceof ReflectionMethod) {
|
||||
$bound = false;
|
||||
return true;
|
||||
}
|
||||
$rargs = null;
|
||||
if (is_string($func)) {
|
||||
if (!self::_parse_c_method($func, $c, $f, $bound)) return false;
|
||||
$cf = [$c, $f];
|
||||
@ -388,6 +399,7 @@ class func {
|
||||
self::_parse_method($f);
|
||||
}
|
||||
$cf[1] = $f;
|
||||
$rargs = array_slice($func, 2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -410,6 +422,7 @@ class func {
|
||||
}
|
||||
}
|
||||
$func = $cf;
|
||||
if ($rargs) $args = cl::merge($rargs, $args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -418,7 +431,7 @@ class func {
|
||||
* {@link self::verifix_method()}
|
||||
*/
|
||||
static function is_method($func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool {
|
||||
return self::verifix_method($func, $strict, $bound, $reason);
|
||||
return self::verifix_method($func, $args, $strict, $bound, $reason);
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@ -452,13 +465,13 @@ class func {
|
||||
return new self(self::TYPE_METHOD, $func, $args, false);
|
||||
}
|
||||
}
|
||||
if (self::verifix_function($func, $strict, $reason)) {
|
||||
if (self::verifix_function($func, $args, $strict, $reason)) {
|
||||
return new self(self::TYPE_FUNCTION, $func, $args, false, $reason);
|
||||
} elseif (self::verifix_class($func, $strict, $reason)) {
|
||||
} elseif (self::verifix_class($func, $args, $strict, $reason)) {
|
||||
return new self(self::TYPE_CLASS, $func, $args, false, $reason);
|
||||
} elseif (self::verifix_method($func, $strict, $bound, $reason)) {
|
||||
} elseif (self::verifix_method($func, $args, $strict, $bound, $reason)) {
|
||||
return new self(self::TYPE_METHOD, $func, $args, $bound, $reason);
|
||||
} elseif (self::verifix_static($func, $strict, $bound, $reason)) {
|
||||
} elseif (self::verifix_static($func, $args, $strict, $bound, $reason)) {
|
||||
return new self(self::TYPE_STATIC, $func, $args, $bound, $reason);
|
||||
}
|
||||
return null;
|
||||
|
@ -295,14 +295,14 @@ namespace nulib\php {
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (strict)";
|
||||
self::assertSame($verifix1, func::verifix_function($workf, true), "$msg --> verifix");
|
||||
self::assertSame($verifix1, func::verifix_function($workf, $args, true), "$msg --> verifix");
|
||||
if ($verifix1) {
|
||||
self::assertSame($func1, $workf, "$msg --> func");
|
||||
}
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (lenient)";
|
||||
self::assertSame($verifix2, func::verifix_function($workf, false), "$msg --> verifix");
|
||||
self::assertSame($verifix2, func::verifix_function($workf, $args, false), "$msg --> verifix");
|
||||
if ($verifix2) {
|
||||
self::assertSame($func2, $workf, "$msg --> func");
|
||||
}
|
||||
@ -595,7 +595,7 @@ namespace nulib\php {
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (strict)";
|
||||
self::assertSame($verifix1, func::verifix_static($workf, true, $bound), "$msg --> verifix");
|
||||
self::assertSame($verifix1, func::verifix_static($workf, $args, true, $bound), "$msg --> verifix");
|
||||
if ($verifix1) {
|
||||
self::assertSame($bound1, $bound, "$msg --> bound");
|
||||
self::assertSame($func1, $workf, "$msg --> func");
|
||||
@ -603,7 +603,7 @@ namespace nulib\php {
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (lenient)";
|
||||
self::assertSame($verifix2, func::verifix_static($workf, false, $bound), "$msg --> verifix");
|
||||
self::assertSame($verifix2, func::verifix_static($workf, $args, false, $bound), "$msg --> verifix");
|
||||
if ($verifix2) {
|
||||
self::assertSame($bound2, $bound, "$msg --> bound");
|
||||
self::assertSame($func2, $workf, "$msg --> func");
|
||||
@ -894,7 +894,7 @@ namespace nulib\php {
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (strict)";
|
||||
self::assertSame($verifix1, func::verifix_method($workf, true, $bound), "$msg --> verifix");
|
||||
self::assertSame($verifix1, func::verifix_method($workf, $args, true, $bound), "$msg --> verifix");
|
||||
if ($verifix1) {
|
||||
self::assertSame($bound1, $bound, "$msg --> bound");
|
||||
self::assertSame($func1, $workf, "$msg --> func");
|
||||
@ -902,7 +902,7 @@ namespace nulib\php {
|
||||
|
||||
$workf = $func;
|
||||
$msg = var_export($func, true)." (lenient)";
|
||||
self::assertSame($verifix2, func::verifix_method($workf, false, $bound), "$msg --> verifix");
|
||||
self::assertSame($verifix2, func::verifix_method($workf, $args, false, $bound), "$msg --> verifix");
|
||||
if ($verifix2) {
|
||||
self::assertSame($bound2, $bound, "$msg --> bound");
|
||||
self::assertSame($func2, $workf, "$msg --> func");
|
||||
|
Loading…
x
Reference in New Issue
Block a user