diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 337af075b..45cf3f59f 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -332,7 +332,13 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - $reflectionClass = new \ReflectionClass(get_class($obj)); + if($obj === null || + (is_object($obj) && strpos($className = get_class($obj), '\Null') !== false) + ) { + return null; + } + + $reflectionClass = new \ReflectionClass($className); $objId = self::createModel($obj, $reflectionClass); self::setObjectId($reflectionClass, $obj, $objId); @@ -378,6 +384,8 @@ class DataMapperAbstract implements DataMapperInterface $value = self::parseValue($column['type'], $id); $query->insert($column['name'])->value($value, $column['type']); + $temp = $query->toSql(); + $test = 1; break; } elseif (isset(static::$belongsTo[$propertyName]) && $column['internal'] === $propertyName) { $id = self::createBelongsTo($propertyName, $property->getValue($obj)); @@ -658,7 +666,7 @@ class DataMapperAbstract implements DataMapperInterface return $value->serialize(); } elseif ($value instanceof \JsonSerializable) { return json_encode($value->jsonSerialize()); - } elseif (is_object($value)) { + } elseif (is_object($value) && method_exists($value, 'getId')) { return $value->getId(); } elseif ($type === 'int') { return (int) $value; @@ -1266,7 +1274,7 @@ class DataMapperAbstract implements DataMapperInterface $reflectionClass = new \ReflectionClass(get_class($obj)); foreach ($result as $member => $values) { - if ($reflectionClass->hasProperty($member)) { + if (!empty($values) && $reflectionClass->hasProperty($member)) { /** @var DataMapperAbstract $mapper */ $mapper = static::$hasMany[$member]['mapper']; $reflectionProperty = $reflectionClass->getProperty($member); diff --git a/Message/Http/Request.php b/Message/Http/Request.php index a8d6f27ee..78959a11e 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -224,7 +224,7 @@ class Request extends RequestAbstract $this->hash = []; foreach ($this->path as $key => $path) { $paths = []; - for ($i = 1; $i < $key + 1; $i++) { + for ($i = 0; $i < $key + 1; $i++) { $paths[] = $this->path[$i]; } @@ -383,10 +383,10 @@ class Request extends RequestAbstract } return - (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') - || (empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') - || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') - || $_SERVER['SERVER_PORT'] == $port; + (!empty($_SERVER['HTTPS'] ?? '') && ($_SERVER['HTTPS'] ?? '') !== 'off') + || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') + || (($_SERVER['HTTP_X_FORWARDED_SSL'] ?? '') === 'on') + || ($_SERVER['SERVER_PORT'] ?? '') == $port; } /** diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index fd50637fd..82961759f 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -248,34 +248,6 @@ abstract class RequestAbstract implements MessageInterface return $this->path[$key] ?? null; } - /** - * Set request type. - * - * E.g. M_JSON - * - * @param string $type Request type - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function setType(string $type) /* : void */ - { - $this->type = $type; - } - - /** - * Get request type. - * - * @return string - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function getType() : string - { - return $this->type; - } - /** * {@inheritdoc} */ diff --git a/Router/Router.php b/Router/Router.php index ec13665aa..45e5c031a 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -148,6 +148,6 @@ class Router */ private function match(string $route, int $routeVerb, string $uri, int $remoteVerb = RouteVerb::GET) : bool { - return (bool) preg_match('~^' . $route . '$~', $uri) && ($routeVerb == RouteVerb::ANY || ($remoteVerb & $routeVerb) === $remoteVerb); + return (bool) preg_match('~^' . $route . '$~', $uri) && ($routeVerb === RouteVerb::ANY || $remoteVerb === RouteVerb::ANY || ($remoteVerb & $routeVerb) === $remoteVerb); } }