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 |    * @param bool $strict vérifier l'inexistence de la classe et l'existence de | ||||||
|    * la fonction (ne pas uniquement faire une vérification syntaxique) |    * 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 ($strict) $reason = null; | ||||||
|     if ($func instanceof ReflectionFunction) return true; |     if ($func instanceof ReflectionFunction) return true; | ||||||
|  |     $rargs = null; | ||||||
|     if (is_string($func)) { |     if (is_string($func)) { | ||||||
|       $c = false; |       $c = false; | ||||||
|       $f = $func; |       $f = $func; | ||||||
| @ -70,6 +71,7 @@ class func { | |||||||
|       $c = $func[0]; |       $c = $func[0]; | ||||||
|       if (!array_key_exists(1, $func)) return false; |       if (!array_key_exists(1, $func)) return false; | ||||||
|       $f = $func[1]; |       $f = $func[1]; | ||||||
|  |       $rargs = array_slice($func, 2); | ||||||
|     } else { |     } else { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @ -90,6 +92,7 @@ class func { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     $func = [false, $f]; |     $func = [false, $f]; | ||||||
|  |     if ($rargs) $args = cl::merge($rargs, $args); | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -98,7 +101,7 @@ class func { | |||||||
|    * {@link self::verifix_function()} |    * {@link self::verifix_function()} | ||||||
|    */ |    */ | ||||||
|   static function is_function($func, bool $strict=true, ?string &$reason=null): bool { |   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 |    * @param bool $strict vérifier l'existence de la classe (ne pas uniquement | ||||||
|    * faire une vérification syntaxique) |    * 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 ($strict) $reason = null; | ||||||
|     if ($func instanceof ReflectionClass) return true; |     if ($func instanceof ReflectionClass) return true; | ||||||
|  |     $rargs = null; | ||||||
|     if (is_string($func)) { |     if (is_string($func)) { | ||||||
|       $c = $func; |       $c = $func; | ||||||
|       $f = false; |       $f = false; | ||||||
| @ -126,6 +130,7 @@ class func { | |||||||
|       $c = $func[0]; |       $c = $func[0]; | ||||||
|       if (!array_key_exists(1, $func)) return false; |       if (!array_key_exists(1, $func)) return false; | ||||||
|       $f = $func[1]; |       $f = $func[1]; | ||||||
|  |       $rargs = array_slice($func, 2); | ||||||
|     } else { |     } else { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @ -139,6 +144,7 @@ class func { | |||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|     $func = [$c, false]; |     $func = [$c, false]; | ||||||
|  |     if ($rargs) $args = cl::merge($rargs, $args); | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -147,7 +153,7 @@ class func { | |||||||
|    * {@link self::verifix_class()} |    * {@link self::verifix_class()} | ||||||
|    */ |    */ | ||||||
|   static function is_class($func, bool $strict=true, ?string &$reason=null): bool { |   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 |    * 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 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) |    * 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 ($strict) $reason = null; | ||||||
|     if ($func instanceof ReflectionMethod) { |     if ($func instanceof ReflectionMethod) { | ||||||
|       $bound = false; |       $bound = false; | ||||||
|       return true; |       return true; | ||||||
|     } |     } | ||||||
|  |     $rargs = null; | ||||||
|     if (is_string($func)) { |     if (is_string($func)) { | ||||||
|       if (!self::_parse_c_static($func, $c, $f, $bound)) return false; |       if (!self::_parse_c_static($func, $c, $f, $bound)) return false; | ||||||
|       $cf = [$c, $f]; |       $cf = [$c, $f]; | ||||||
| @ -252,6 +260,7 @@ class func { | |||||||
|         self::_parse_static($f); |         self::_parse_static($f); | ||||||
|       } |       } | ||||||
|       $cf[1] = $f; |       $cf[1] = $f; | ||||||
|  |       $rargs = array_slice($func, 2); | ||||||
|     } else { |     } else { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @ -274,6 +283,7 @@ class func { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     $func = $cf; |     $func = $cf; | ||||||
|  |     if ($rargs) $args = cl::merge($rargs, $args); | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -282,7 +292,7 @@ class func { | |||||||
|    * {@link self::verifix_static()} |    * {@link self::verifix_static()} | ||||||
|    */ |    */ | ||||||
|   static function is_static($func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool { |   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 |    * @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) |    * 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 ($strict) $reason = null; | ||||||
|     if ($func instanceof ReflectionMethod) { |     if ($func instanceof ReflectionMethod) { | ||||||
|       $bound = false; |       $bound = false; | ||||||
|       return true; |       return true; | ||||||
|     } |     } | ||||||
|  |     $rargs = null; | ||||||
|     if (is_string($func)) { |     if (is_string($func)) { | ||||||
|       if (!self::_parse_c_method($func, $c, $f, $bound)) return false; |       if (!self::_parse_c_method($func, $c, $f, $bound)) return false; | ||||||
|       $cf = [$c, $f]; |       $cf = [$c, $f]; | ||||||
| @ -388,6 +399,7 @@ class func { | |||||||
|         self::_parse_method($f); |         self::_parse_method($f); | ||||||
|       } |       } | ||||||
|       $cf[1] = $f; |       $cf[1] = $f; | ||||||
|  |       $rargs = array_slice($func, 2); | ||||||
|     } else { |     } else { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @ -410,6 +422,7 @@ class func { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     $func = $cf; |     $func = $cf; | ||||||
|  |     if ($rargs) $args = cl::merge($rargs, $args); | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -418,7 +431,7 @@ class func { | |||||||
|    * {@link self::verifix_method()} |    * {@link self::verifix_method()} | ||||||
|    */ |    */ | ||||||
|   static function is_method($func, bool $strict=true, ?bool &$bound=null, ?string &$reason=null): bool { |   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); |         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); |       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); |       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); |       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 new self(self::TYPE_STATIC, $func, $args, $bound, $reason); | ||||||
|     } |     } | ||||||
|     return null; |     return null; | ||||||
|  | |||||||
| @ -295,14 +295,14 @@ namespace nulib\php { | |||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (strict)"; |         $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) { |         if ($verifix1) { | ||||||
|           self::assertSame($func1, $workf, "$msg --> func"); |           self::assertSame($func1, $workf, "$msg --> func"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (lenient)"; |         $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) { |         if ($verifix2) { | ||||||
|           self::assertSame($func2, $workf, "$msg --> func"); |           self::assertSame($func2, $workf, "$msg --> func"); | ||||||
|         } |         } | ||||||
| @ -595,7 +595,7 @@ namespace nulib\php { | |||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (strict)"; |         $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) { |         if ($verifix1) { | ||||||
|           self::assertSame($bound1, $bound, "$msg --> bound"); |           self::assertSame($bound1, $bound, "$msg --> bound"); | ||||||
|           self::assertSame($func1, $workf, "$msg --> func"); |           self::assertSame($func1, $workf, "$msg --> func"); | ||||||
| @ -603,7 +603,7 @@ namespace nulib\php { | |||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (lenient)"; |         $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) { |         if ($verifix2) { | ||||||
|           self::assertSame($bound2, $bound, "$msg --> bound"); |           self::assertSame($bound2, $bound, "$msg --> bound"); | ||||||
|           self::assertSame($func2, $workf, "$msg --> func"); |           self::assertSame($func2, $workf, "$msg --> func"); | ||||||
| @ -894,7 +894,7 @@ namespace nulib\php { | |||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (strict)"; |         $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) { |         if ($verifix1) { | ||||||
|           self::assertSame($bound1, $bound, "$msg --> bound"); |           self::assertSame($bound1, $bound, "$msg --> bound"); | ||||||
|           self::assertSame($func1, $workf, "$msg --> func"); |           self::assertSame($func1, $workf, "$msg --> func"); | ||||||
| @ -902,7 +902,7 @@ namespace nulib\php { | |||||||
| 
 | 
 | ||||||
|         $workf = $func; |         $workf = $func; | ||||||
|         $msg = var_export($func, true)." (lenient)"; |         $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) { |         if ($verifix2) { | ||||||
|           self::assertSame($bound2, $bound, "$msg --> bound"); |           self::assertSame($bound2, $bound, "$msg --> bound"); | ||||||
|           self::assertSame($func2, $workf, "$msg --> func"); |           self::assertSame($func2, $workf, "$msg --> func"); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user