Browse Source

Internal: Convert all intval() calls to (int) casting (micro-optimization)

Yannick Warnier 7 years ago
parent
commit
0f758eca5b
1 changed files with 14 additions and 14 deletions
  1. 14 14
      main/inc/lib/legal.lib.php

+ 14 - 14
main/inc/lib/legal.lib.php

@@ -29,18 +29,18 @@ class LegalManager
     {
         $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
         $last = self::get_last_condition($language);
-        $type = intval($type);
+        $type = (int) $type;
         $time = time();
 
         if ($last['content'] != $content) {
-            $version = intval(self::get_last_condition_version($language));
+            $version = (int) self::get_last_condition_version($language);
             $version++;
             $params = [
                 'language_id' => $language,
                 'content' => $content,
                 'changes' => $changes,
                 'type' => $type,
-                'version' => intval($version),
+                'version' => (int) $version,
                 'date' => $time,
             ];
             Database::insert($legal_table, $params);
@@ -69,7 +69,7 @@ class LegalManager
     {
         /*
         $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $id = intval($id);
+        $id = (int) $id;
         $sql = "DELETE FROM $legal_table WHERE id = '".$id."'";
         */
     }
@@ -84,7 +84,7 @@ class LegalManager
     public static function get_last_condition_version($language)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $language = intval($language);
+        $language = (int) $language;
         $sql = "SELECT version FROM $table
                 WHERE language_id = $language
                 ORDER BY id DESC LIMIT 1 ";
@@ -107,7 +107,7 @@ class LegalManager
     public static function get_last_condition($language)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $language = intval($language);
+        $language = (int) $language;
         $sql = "SELECT * FROM $table
                 WHERE language_id = $language
                 ORDER BY version DESC
@@ -133,8 +133,8 @@ class LegalManager
     public static function hasVersion($language, $version)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $language = intval($language);
-        $version = intval($version);
+        $language = (int) $language;
+        $version = (int) $version;
 
         if (empty($language)) {
             return false;
@@ -186,7 +186,7 @@ class LegalManager
     public static function get_last_version($language)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $language = intval($language);
+        $language = (int) $language;
         $sql = "SELECT version FROM $table
                 WHERE language_id = '$language'
                 ORDER BY version DESC
@@ -258,9 +258,9 @@ class LegalManager
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
         $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
-        $from = intval($from);
-        $number_of_items = intval($number_of_items);
-        $column = intval($column);
+        $from = (int) $from;
+        $number_of_items = (int) $number_of_items;
+        $column = (int) $column;
 
         $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
                 FROM $table 
@@ -319,8 +319,8 @@ class LegalManager
     public static function get_type_of_terms_and_conditions($legal_id, $language_id)
     {
         $table = Database::get_main_table(TABLE_MAIN_LEGAL);
-        $legal_id = intval($legal_id);
-        $language_id = intval($language_id);
+        $legal_id = (int) $legal_id;
+        $language_id = (int) $language_id;
         $sql = "SELECT type FROM $table
                 WHERE id = $legal_id AND language_id = $language_id";
         $rs = Database::query($sql);