Fix update null/null objs

This commit is contained in:
Dennis Eichhorn 2017-12-02 15:41:43 +01:00
parent e556fbed49
commit 9a460a2dc7
2 changed files with 9 additions and 5 deletions

View File

@ -47,11 +47,11 @@ interface DataMapperInterface
*
* @param mixed $obj Object reference (gets filled with insert id)
*
* @return int Status
* @return mixed
*
* @since 1.0.0
*/
public static function update($obj) : int;
public static function update($obj);
/**
* Delete data.

View File

@ -346,7 +346,7 @@ class DataMapperAbstract implements DataMapperInterface
{
self::extend(__CLASS__);
if ($obj === null ||
if (!isset($obj) ||
(strpos($className = get_class($obj), '\Null') !== false && is_object($obj))
) {
return null;
@ -1152,14 +1152,18 @@ class DataMapperAbstract implements DataMapperInterface
* @param mixed $obj Object reference (gets filled with insert id)
* @param int $relations Create all relations as well
*
* @return int
* @return mixed
*
* @since 1.0.0
*/
public static function update($obj, int $relations = RelationType::ALL) : int
public static function update($obj, int $relations = RelationType::ALL)
{
self::extend(__CLASS__);
if(!isset($obj) || strpos(get_class($obj), '\Null') !== false) {
return null;
}
$reflectionClass = new \ReflectionClass($obj);
$objId = self::getObjectId($obj, $reflectionClass);
$update = true;