* zin: support to set props with an plain object

This commit is contained in:
Hao Sun
2023-02-17 15:36:35 +08:00
parent 6e800505f1
commit 4340704e6f
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -18,6 +18,7 @@ class set
public static function __callStatic($prop, $args)
{
$value = array_shift($args);
if(is_object($value)) $value = (array)$value;
if($prop === '_' && is_array($value)) return directive('prop', $value);
return directive('prop', array($prop => $value));
}
+6 -1
View File
@@ -17,7 +17,12 @@ require_once 'wg.class.php';
function set($name, $value = NULL)
{
return directive('prop', (is_array($name) || $name instanceof props) ? $name : array($name => $value));
$props = null;
if($name instanceof props) $props = $name;
else if(is_array($name)) $props = $name;
else if(is_object($name)) $props = (array)$name;
else if(is_string($name)) $props = array($name => $value);
if($props) return directive('prop', $props);
}
function prop($name, $value = NULL)