Unverified Commit 5f7334f5 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Avoid direct check of class name (#4601)

* Avoid direct check of class name

So that subclasses are also ok

* Use type hint in function signature.
parent 5f9232b5
......@@ -159,14 +159,10 @@ class Timestamp extends \Google\Protobuf\Internal\Message
/**
* Converts PHP DateTime to Timestamp.
*
* @param DateTime $datetime
* @param \DateTime $datetime
*/
public function fromDateTime($datetime)
public function fromDateTime(\DateTime $datetime)
{
if (get_class($datetime) !== \DateTime::class) {
trigger_error("Given parameter is not a DateTime.",
E_USER_ERROR);
}
$this->seconds = $datetime->format('U');
$this->nanos = 0;
}
......@@ -174,7 +170,7 @@ class Timestamp extends \Google\Protobuf\Internal\Message
/**
* Converts Timestamp to PHP DateTime. Nano second is ignored.
*
* @return DateTime $datetime
* @return \DateTime $datetime
*/
public function toDateTime()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment