diff --git a/controllers/bookmark.php b/controllers/bookmark.php index f36456e..ba184e1 100644 --- a/controllers/bookmark.php +++ b/controllers/bookmark.php @@ -38,7 +38,7 @@ Router\get_action('bookmarks', function () { $group_id = Request\int_param('group_id', null); $feed_ids = array(); - if (! is_null($group_id)) { + if ($group_id !== null) { $feed_ids = Model\Group\get_feeds_by_group($group_id); } diff --git a/controllers/common.php b/controllers/common.php index 8af9551..0384e54 100644 --- a/controllers/common.php +++ b/controllers/common.php @@ -7,7 +7,7 @@ Router\before(function ($action) { // Select the requested database either from post param database or from the // session variable. If it fails, logout to destroy session and // 'remember me' cookie - if (! is_null(Request\value('database')) && ! Model\Database\select(Request\value('database'))) { + if (Request\value('database') !== null && ! Model\Database\select(Request\value('database'))) { Model\User\logout(); Response\redirect('?action=login'); } elseif (! empty($_SESSION['database'])) { diff --git a/controllers/history.php b/controllers/history.php index 3849cb7..aa6d167 100644 --- a/controllers/history.php +++ b/controllers/history.php @@ -8,7 +8,7 @@ Router\get_action('history', function () { $group_id = Request\int_param('group_id', null); $feed_ids = array(); - if (! is_null($group_id)) { + if ($group_id !== null) { $feed_ids = Model\Group\get_feeds_by_group($group_id); } @@ -59,7 +59,7 @@ Router\get_action('confirm-flush-history', function () { Router\get_action('flush-history', function () { $group_id = Request\int_param('group_id', null); - if (!is_null($group_id)) { + if ($group_id !== null) { Model\Item\mark_group_as_removed($group_id); } else { Model\Item\mark_all_as_removed(); diff --git a/controllers/item.php b/controllers/item.php index 46cf3f3..dfc2108 100644 --- a/controllers/item.php +++ b/controllers/item.php @@ -11,7 +11,7 @@ Router\get_action('unread', function () { $group_id = Request\int_param('group_id', null); $feed_ids = array(); - if (! is_null($group_id)) { + if ($group_id !== null) { $feed_ids = Model\Group\get_feeds_by_group($group_id); } @@ -160,7 +160,7 @@ Router\post_action('mark-item-unread', function () { Router\get_action('mark-all-read', function () { $group_id = Request\int_param('group_id', null); - if (!is_null($group_id)) { + if ($group_id !== null) { Model\Item\mark_group_as_read($group_id); } else { Model\Item\mark_all_as_read(); diff --git a/fever/index.php b/fever/index.php index fedc801..dedfe90 100644 --- a/fever/index.php +++ b/fever/index.php @@ -309,7 +309,7 @@ foreach (array_keys($_GET) as $action) { } if (! empty($_POST['mark']) && ! empty($_POST['as']) - && ! is_null(filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT, array('options' => array('default' => null, 'min_range' => -1))))) { + && filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT, array('options' => array('default' => null, 'min_range' => -1))) !== null) { if ($_POST['mark'] === 'item') { route('write_items'); } elseif ($_POST['mark'] === 'feed' && ! empty($_POST['before'])) { diff --git a/lib/Translator.php b/lib/Translator.php index 3024856..1b943b9 100644 --- a/lib/Translator.php +++ b/lib/Translator.php @@ -109,7 +109,7 @@ namespace Translator { } } - for ($i = $plural; $i >= 0; $i--) { + for ($i = $plural; $i >= 0; --$i) { if (isset($locales[$identifier][$i])) { return $locales[$identifier][$i]; } diff --git a/lib/helpers.php b/lib/helpers.php index a741472..ee8231b 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -17,7 +17,7 @@ function parse_app_version($refnames, $commithash) if ($refnames !== '$Format:%d$') { $tag = preg_replace('/\s*\(.*tag:\sv([^,]+).*\)/i', '\1', $refnames); - if (!is_null($tag) && $tag !== $refnames) { + if ($tag !== null && $tag !== $refnames) { return $tag; } } @@ -222,7 +222,7 @@ function form_hidden($name, $values = array()) function form_default_select($name, array $options, $values = array(), array $errors = array(), $class = '') { - $options = array('' => '?') + $options; + $options += array('' => '?'); return form_select($name, $options, $values, $errors, $class); } diff --git a/lib/password.php b/lib/password.php index d4972ab..a2d9530 100644 --- a/lib/password.php +++ b/lib/password.php @@ -114,9 +114,9 @@ if (!defined('PASSWORD_BCRYPT')) { } if (!$buffer_valid || strlen($buffer) < $raw_length) { $bl = strlen($buffer); - for ($i = 0; $i < $raw_length; $i++) { + for ($i = 0; $i < $raw_length; ++$i) { if ($i < $bl) { - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + $buffer[$i] ^= chr(mt_rand(0, 255)); } else { $buffer .= chr(mt_rand(0, 255)); } @@ -212,12 +212,13 @@ if (!defined('PASSWORD_BCRYPT')) { return false; } $ret = crypt($password, $hash); - if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) { + $len = strlen($ret); + if (!is_string($ret) || $len != strlen($hash) || $len <= 13) { return false; } $status = 0; - for ($i = 0; $i < strlen($ret); $i++) { + for ($i = 0; $i < $len; ++$i) { $status |= (ord($ret[$i]) ^ ord($hash[$i])); } diff --git a/models/item.php b/models/item.php index c043cdf..8ba36b6 100644 --- a/models/item.php +++ b/models/item.php @@ -244,7 +244,7 @@ function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $fee $next_item = null; $previous_item = null; - for ($i = 0, $ilen = count($items); $i < $ilen; $i++) { + for ($i = 0, $ilen = count($items); $i < $ilen; ++$i) { if ($items[$i]['id'] == $item['id']) { if ($i > 0) { $j = $i - 1; @@ -255,7 +255,7 @@ function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $fee break; } - $j--; + --$j; } } @@ -268,7 +268,7 @@ function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $fee break; } - $j++; + ++$j; } } diff --git a/scripts/sync-locales.php b/scripts/sync-locales.php index f36fc70..f3169e3 100755 --- a/scripts/sync-locales.php +++ b/scripts/sync-locales.php @@ -49,7 +49,7 @@ foreach (new DirectoryIterator('locales') as $fileInfo) { $filename = 'locales/'.$fileInfo->getFilename().'/translations.php'; - echo $fileInfo->getFilename().' ('.$filename.')'.PHP_EOL; + echo $fileInfo->getFilename(), ' (', $filename, ')', PHP_EOL; file_put_contents($filename, update_missing_locales($reference, $filename)); } diff --git a/templates/about.php b/templates/about.php index 5ce74da..bd5707a 100644 --- a/templates/about.php +++ b/templates/about.php @@ -16,7 +16,7 @@

diff --git a/templates/api.php b/templates/api.php index e5dd7d6..34a68c1 100644 --- a/templates/api.php +++ b/templates/api.php @@ -15,7 +15,7 @@

@@ -23,7 +23,7 @@

diff --git a/templates/bookmarks.php b/templates/bookmarks.php index 364e919..43e1bb8 100644 --- a/templates/bookmarks.php +++ b/templates/bookmarks.php @@ -1,4 +1,4 @@ - +

diff --git a/templates/confirm_flush_items.php b/templates/confirm_flush_items.php index c554bba..f165989 100644 --- a/templates/confirm_flush_items.php +++ b/templates/confirm_flush_items.php @@ -5,6 +5,6 @@

- - + +
\ No newline at end of file diff --git a/templates/feeds.php b/templates/feeds.php index 417f68e..0a60528 100644 --- a/templates/feeds.php +++ b/templates/feeds.php @@ -34,7 +34,7 @@ - ‎ + ‎ @@ -42,7 +42,7 @@ diff --git a/templates/history.php b/templates/history.php index 1e509c1..db748ff 100644 --- a/templates/history.php +++ b/templates/history.php @@ -18,9 +18,9 @@
diff --git a/templates/unread_items.php b/templates/unread_items.php index 36803e4..8e7aab7 100644 --- a/templates/unread_items.php +++ b/templates/unread_items.php @@ -16,10 +16,10 @@
@@ -43,7 +43,7 @@
- +
$menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction, 'group_id' => $group_id)) ?> diff --git a/tests/integration/minifluxTestCase.php b/tests/integration/minifluxTestCase.php index 68d40ba..27eb77f 100644 --- a/tests/integration/minifluxTestCase.php +++ b/tests/integration/minifluxTestCase.php @@ -108,7 +108,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase protected function getConnection() { - if (is_null(static::$databaseConnection)) { + if (static::$databaseConnection === null) { // let Miniflux setup the database require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common.php'; @@ -142,7 +142,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase protected function getDatabaseTester($dataset) { - if (is_null(static::$databaseTester)) { + if (static::$databaseTester === null) { $rdataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset); $rdataset->addSubStrReplacement('##TIMESTAMP##', substr((string)(time()-100), 0, -2)); @@ -247,7 +247,7 @@ abstract class minifluxTestCase extends PHPUnit_Extensions_Selenium2TestCase $elements = $this->elements($this->using('id')->value($id)); if (count($elements) === 1 && $elements[0]->text() == $text - || count($elements) === 0 && is_null($text)) { + || count($elements) === 0 && $text === null) { return true; } } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { diff --git a/worker.php b/worker.php index b1f2802..644a504 100644 --- a/worker.php +++ b/worker.php @@ -19,10 +19,10 @@ function check_job_left(Pheanstalk $connection, array $options) if (in_array(BEANSTALKD_QUEUE, $queues)) { $stats = $connection->statsTube(BEANSTALKD_QUEUE); - echo 'Jobs in queue: '.$stats->current_jobs_ready.PHP_EOL; + echo 'Jobs in queue: ', $stats->current_jobs_ready, PHP_EOL; (int) $stats->current_jobs_ready === 0 && exit(0); } else { - echo 'No queue'.PHP_EOL; + echo 'No queue', PHP_EOL; exit(0); } } @@ -35,7 +35,7 @@ check_job_left($connection, $options); while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) { $feed_id = $job->getData(); - echo 'Processing feed_id='.$feed_id.PHP_EOL; + echo 'Processing feed_id=', $feed_id, PHP_EOL; Model\Feed\refresh($feed_id); $connection->delete($job);