summaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-25 23:06:53 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-01-26 11:35:42 +0100
commitc1e4f9f30563d5eda1718d716d631d6092cd4e28 (patch)
tree3bb7b6ef891cd80895d4c2c92252a4ccbc0c0cee /lib/private/Comments
parentfe7e726ab228e6ddde7cf1442de9d0db193334a1 (diff)
downloadnextcloud-server-c1e4f9f30563d5eda1718d716d631d6092cd4e28.tar.gz
nextcloud-server-c1e4f9f30563d5eda1718d716d631d6092cd4e28.zip
Use type casting instead of *val() method
It should be up to 6x faster Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 4357a2eb437..2b43a27b7ac 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -87,14 +87,14 @@ class Manager implements ICommentsManager {
* @return array
*/
protected function normalizeDatabaseData(array $data) {
- $data['id'] = strval($data['id']);
- $data['parent_id'] = strval($data['parent_id']);
- $data['topmost_parent_id'] = strval($data['topmost_parent_id']);
+ $data['id'] = (string)$data['id'];
+ $data['parent_id'] = (string)$data['parent_id'];
+ $data['topmost_parent_id'] = (string)$data['topmost_parent_id'];
$data['creation_timestamp'] = new \DateTime($data['creation_timestamp']);
if (!is_null($data['latest_child_timestamp'])) {
$data['latest_child_timestamp'] = new \DateTime($data['latest_child_timestamp']);
}
- $data['children_count'] = intval($data['children_count']);
+ $data['children_count'] = (int)$data['children_count'];
return $data;
}
@@ -171,7 +171,7 @@ class Manager implements ICommentsManager {
$resultStatement = $query->execute();
$data = $resultStatement->fetch(\PDO::FETCH_NUM);
$resultStatement->closeCursor();
- $children = intval($data[0]);
+ $children = (int)$data[0];
$comment = $this->get($id);
$comment->setChildrenCount($children);
@@ -207,7 +207,7 @@ class Manager implements ICommentsManager {
if (empty($id)) {
return;
}
- $this->commentsCache[strval($id)] = $comment;
+ $this->commentsCache[(string)$id] = $comment;
}
/**
@@ -216,7 +216,7 @@ class Manager implements ICommentsManager {
* @param mixed $id the comment's id
*/
protected function uncache($id) {
- $id = strval($id);
+ $id = (string)$id;
if (isset($this->commentsCache[$id])) {
unset($this->commentsCache[$id]);
}
@@ -232,7 +232,7 @@ class Manager implements ICommentsManager {
* @since 9.0.0
*/
public function get($id) {
- if (intval($id) === 0) {
+ if ((int)$id === 0) {
throw new \InvalidArgumentException('IDs must be translatable to a number in this implementation.');
}
@@ -402,7 +402,7 @@ class Manager implements ICommentsManager {
$resultStatement = $query->execute();
$data = $resultStatement->fetch(\PDO::FETCH_NUM);
$resultStatement->closeCursor();
- return intval($data[0]);
+ return (int)$data[0];
}
/**
@@ -569,7 +569,7 @@ class Manager implements ICommentsManager {
->execute();
if ($affectedRows > 0) {
- $comment->setId(strval($qb->getLastInsertId()));
+ $comment->setId((string)$qb->getLastInsertId());
$this->sendEvent(CommentsEvent::EVENT_ADD, $comment);
}