]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Minor code cleanup: PHPDoc, spelling, unused variables, etc. 671/head
authorArthurHoaro <arthur@hoa.ro>
Thu, 20 Oct 2016 09:31:52 +0000 (11:31 +0200)
committerArthurHoaro <arthur@hoa.ro>
Thu, 20 Oct 2016 09:36:11 +0000 (11:36 +0200)
13 files changed:
CHANGELOG.md
application/ApplicationUtils.php
application/CachedPage.php
application/LinkUtils.php
application/NetscapeBookmarkUtils.php
application/TimeZone.php
application/Updater.php
application/Url.php
application/Utils.php
application/config/ConfigJson.php
application/config/ConfigManager.php
index.php
tests/config/ConfigJsonTest.php

index 60af7223cf35ede5d055d585ae680a3cfcfb3703..e32ef45998a256325cd88c2a252fb046b8acd41f 100644 (file)
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 - Release archives now have the same structure as GitHub-generated archives:
     - archives contain a `Shaarli` directory, itself containing sources + dependencies
     - the tarball is now gzipped
+- Minor code cleanup: PHPDoc, spelling, unused variables, etc.
 
 ### Fixed
 - Fix the server `<self>` value in Atom/RSS feeds
index e67b29021504ccada967da6dea47d191aa5f6b67..7f963e9786cc50901863789341bc802ed1e22403 100644 (file)
@@ -15,6 +15,9 @@ class ApplicationUtils
      *
      * The code is read from the raw content of the version file on the Git server.
      *
+     * @param string $url     URL to reach to get the latest version.
+     * @param int    $timeout Timeout to check the URL (in seconds).
+     *
      * @return mixed the version code from the repository if available, else 'false'
      */
     public static function getLatestGitVersionCode($url, $timeout=2)
@@ -49,6 +52,7 @@ class ApplicationUtils
      * @param int    $checkInterval  the minimum interval between update checks (in seconds
      * @param bool   $enableCheck    whether to check for new versions
      * @param bool   $isLoggedIn     whether the user is logged in
+     * @param string $branch         check update for the given branch
      *
      * @throws Exception an invalid branch has been set for update checks
      *
@@ -152,7 +156,7 @@ class ApplicationUtils
             }
         }
 
-        // Check cache and data directories are readable and writeable
+        // Check cache and data directories are readable and writable
         foreach (array(
             $conf->get('resource.thumbnails_cache'),
             $conf->get('resource.data_dir'),
@@ -167,7 +171,7 @@ class ApplicationUtils
             }
         }
 
-        // Check configuration files are readable and writeable
+        // Check configuration files are readable and writable
         foreach (array(
             $conf->getConfigFileExt(),
             $conf->get('resource.datastore'),
index 50cfa9ac0d30add914b39ea2bd5c2a5bc0abef6c..5087d0c4b6b1fd6182fcd4564497d6531c78754b 100644 (file)
@@ -35,7 +35,7 @@ class CachedPage
     /**
      * Returns the cached version of a page, if it exists and should be cached
      *
-     * @return a cached version of the page if it exists, null otherwise
+     * @return string a cached version of the page if it exists, null otherwise
      */
     public function cachedVersion()
     {
index eeca631f566ad5ee84d1eb76cc7f20e439355a13..9d9ae3cb29f603f6a82a8125bf3cc4b8860c1183 100644 (file)
@@ -81,7 +81,7 @@ function html_extract_charset($html)
 /**
  * Count private links in given linklist.
  *
- * @param array $links Linklist.
+ * @param array|Countable $links Linklist.
  *
  * @return int Number of private links.
  */
@@ -162,6 +162,7 @@ function space2nbsp($text)
  *
  * @param string $description shaare's description.
  * @param string $redirector  if a redirector is set, use it to gerenate links.
+ * @param string $indexUrl    URL to Shaarli's index.
  *
  * @return string formatted description.
  */
index c318125466e73ca932b18e07eacfbe083e5e41f6..d6840d37862d2463f84f54212f5614cdf28385f3 100644 (file)
@@ -86,7 +86,7 @@ class NetscapeBookmarkUtils
      * Imports Web bookmarks from an uploaded Netscape bookmark dump
      *
      * @param array  $post      Server $_POST parameters
-     * @param array  $file      Server $_FILES parameters
+     * @param array  $files     Server $_FILES parameters
      * @param LinkDB $linkDb    Loaded LinkDB instance
      * @param string $pagecache Page cache
      *
index 26f2232d45c1a5961d45380acf52de0beafd5b70..36a8fb122ada91a1832f25944895f8aeca599288 100644 (file)
@@ -7,9 +7,9 @@
  * Example: preselect Europe/Paris
  *  list($htmlform, $js) = generateTimeZoneForm('Europe/Paris');
  *
- * @param string $preselected_timezone preselected timezone (optional)
+ * @param string $preselectedTimezone preselected timezone (optional)
  *
- * @return an array containing the generated HTML form and Javascript code
+ * @return array containing the generated HTML form and Javascript code
  **/
 function generateTimeZoneForm($preselectedTimezone='')
 {
@@ -27,10 +27,6 @@ function generateTimeZoneForm($preselectedTimezone='')
         $pcity = substr($preselectedTimezone, $spos+1);
     }
 
-    // Display config form:
-    $timezoneForm = '';
-    $timezoneJs = '';
-
     // The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires'
     // We split the list in continents/cities.
     $continents = array();
@@ -97,7 +93,7 @@ function generateTimeZoneForm($preselectedTimezone='')
  * @param string $continent the timezone continent
  * @param string $city      the timezone city
  *
- * @return whether continent/city is a valid timezone
+ * @return bool whether continent/city is a valid timezone
  */
 function isTimeZoneValid($continent, $city)
 {
index b6cbc56c4b2834a2c05b5cc7a7a4b554add554fa..90913235ca8e528d22d8103288971a787fcf08ef 100644 (file)
@@ -37,7 +37,7 @@ class Updater
      *
      * @param array         $doneUpdates Updates which are already done.
      * @param LinkDB        $linkDB      LinkDB instance.
-     * @oaram ConfigManager $conf        Configuration Manager instance.
+     * @param ConfigManager $conf        Configuration Manager instance.
      * @param boolean       $isLoggedIn  True if the user is logged in.
      */
     public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
index c166ff6ef03f6023c2bf895279f8eb8940736ba9..c5c7dd187bbc0d1f1f3d7aff97bbb4cfc375bb61 100644 (file)
@@ -62,21 +62,7 @@ function add_trailing_slash($url)
 {
     return $url . (!endsWith($url, '/') ? '/' : '');
 }
-/**
- * Converts an URL with an IDN host to a ASCII one.
- *
- * @param string $url Input URL.
- *
- * @return string converted URL.
- */
-function url_with_idn_to_ascii($url)
-{
-    $parts = parse_url($url);
-    $parts['host'] = idn_to_ascii($parts['host']);
 
-    $httpUrl = new \http\Url($parts);
-    return $httpUrl->toString();
-}
 /**
  * URL representation and cleanup utilities
  *
index 7d7eaffdb71b86abe8b56b879fcbb968a7fb511e..0166ee2ac0e132035af72e132a50ceb4368933e7 100644 (file)
@@ -32,6 +32,10 @@ function logm($logFile, $clientIp, $message)
  *
  *  In Shaarli, they are used as a tinyurl-like link to individual entries,
  *  e.g. smallHash('20111006_131924') --> yZH23w
+ *
+ * @param string $text Create a hash from this text.
+ *
+ * @return string generated small hash.
  */
 function smallHash($text)
 {
@@ -106,7 +110,9 @@ function unescape($str)
 }
 
 /**
- * Link sanitization before templating
+ * Sanitize link before rendering.
+ *
+ * @param array $link Link to escape.
  */
 function sanitizeLink(&$link)
 {
index d07fefee5c2968292eba37c240861d8eb2bf43dc..30007eb4cfd550fc106d7ace97fca00545519cff 100644 (file)
@@ -21,7 +21,7 @@ class ConfigJson implements ConfigIO
         $data = json_decode($data, true);
         if ($data === null) {
             $error = json_last_error();
-            throw new Exception('An error occured while parsing JSON file: error code #'. $error);
+            throw new Exception('An error occurred while parsing JSON file: error code #'. $error);
         }
         return $data;
     }
index ff41772a73153d7c3bb1d477e58d2586c5a5cf93..f5f753f8fb55853688824327cb19ea5669dcead8 100644 (file)
@@ -37,6 +37,8 @@ class ConfigManager
 
     /**
      * Constructor.
+     *
+     * @param string $configFile Configuration file path without extension.
      */
     public function __construct($configFile = 'data/config')
     {
index f7e73bde956c161d043d627361b92d7ca6eed519..6d712aee08e61601b961dc5e8125b42e544777fe 100644 (file)
--- a/index.php
+++ b/index.php
@@ -606,8 +606,6 @@ function showDailyRSS($conf) {
         $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day);  // Absolute URL of the corresponding "Daily" page.
 
         // Build the HTML body of this RSS entry.
-        $html = '';
-        $href = '';
         $links = array();
 
         // We pre-format some fields for proper output.
@@ -833,7 +831,7 @@ function renderPage($conf, $pluginManager)
         // Get only links which have a thumbnail.
         foreach($links as $link)
         {
-            $permalink='?'.escape(smallhash($link['linkdate']));
+            $permalink='?'.escape(smallHash($link['linkdate']));
             $thumb=lazyThumbnail($conf, $link['url'],$permalink);
             if ($thumb!='') // Only output links which have a thumbnail.
             {
@@ -867,7 +865,7 @@ function renderPage($conf, $pluginManager)
             $maxcount = max($maxcount, $value);
         }
 
-        // Sort tags alphabetically: case insensitive, support locale if avalaible.
+        // Sort tags alphabetically: case insensitive, support locale if available.
         uksort($tags, function($a, $b) {
             // Collator is part of PHP intl.
             if (class_exists('Collator')) {
@@ -1670,8 +1668,6 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         $next_page_url = '?page=' . ($page-1) . $searchtermUrl . $searchtagsUrl;
     }
 
-    $token = isLoggedIn() ? getToken($conf) : '';
-
     // Fill all template fields.
     $data = array(
         'previous_page_url' => $previous_page_url,
index 99c88820ca43abb66920d19fef1617d7d18e377a..07f6ab49db64953499ab5eb5125eeaf197837ffe 100644 (file)
@@ -41,7 +41,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
      * Read a non existent config file -> empty array.
      *
      * @expectedException Exception
-     * @expectedExceptionMessage An error occured while parsing JSON file: error code #4
+     * @expectedExceptionMessage An error occurred while parsing JSON file: error code #4
      */
     public function testReadInvalidJson()
     {