aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Paul Yang <TeBoring@users.noreply.github.com>2018-05-10 10:52:00 -0700
committerGravatar GitHub <noreply@github.com>2018-05-10 10:52:00 -0700
commit5f7334f5f3c5015cdcaf21d456f0829486717b15 (patch)
tree673fcf181030440ee207271d0e1415164dde3010
parent5f9232b5e0f1e53ccc5deef4be10e17064852d56 (diff)
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.
-rw-r--r--php/src/Google/Protobuf/Timestamp.php10
1 files changed, 3 insertions, 7 deletions
diff --git a/php/src/Google/Protobuf/Timestamp.php b/php/src/Google/Protobuf/Timestamp.php
index 7da8e956..f2286ab4 100644
--- a/php/src/Google/Protobuf/Timestamp.php
+++ b/php/src/Google/Protobuf/Timestamp.php
@@ -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()
{