Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

Commit b62c259

Browse files
committed
some update
1 parent 833e4ea commit b62c259

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/ObjectHelper.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
*/
1616
class ObjectHelper
1717
{
18-
/**
19-
* @param mixed $object An object instance
20-
* @param array $options
21-
* @return mixed
22-
*/
23-
public static function smartConfigure($object, array $options)
24-
{
25-
return self::init($object, $options);
26-
}
27-
2818
/**
2919
* 给对象设置属性值
3020
* - 会先尝试用 setter 方法设置属性
@@ -45,7 +35,7 @@ public static function init($object, array $options)
4535
// has setter
4636
if (\method_exists($object, $setter)) {
4737
$object->$setter($value);
48-
} else {
38+
} elseif (\property_exists($object, $property)) {
4939
$object->$property = $value;
5040
}
5141
}
@@ -61,7 +51,9 @@ public static function init($object, array $options)
6151
public static function configure($object, array $options)
6252
{
6353
foreach ($options as $property => $value) {
64-
$object->$property = $value;
54+
if (\property_exists($object, $property)) {
55+
$object->$property = $value;
56+
}
6557
}
6658
}
6759

0 commit comments

Comments
 (0)