From 606cd333a2723611b367b1e15a055e561884dc24 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:46:04 +0100
Subject: [PATCH 01/13] Fixed wrapping of comment lines to 80 characters.

---
 flag.install                                       |  3 +-
 flag.module                                        | 35 ++++++++++++++--------
 flag.rules.inc                                     |  9 ++++--
 flag_bookmark/flag_bookmark.install                |  3 +-
 includes/flag.export.inc                           |  3 +-
 includes/flag/flag_flag.inc                        | 23 ++++++++------
 .../flag_plugin_argument_validate_flaggability.inc |  6 ++--
 tests/flag.test                                    |  6 ++--
 theme/flag.tpl.php                                 | 27 ++++++++++-------
 9 files changed, 72 insertions(+), 43 deletions(-)

diff --git a/flag.install b/flag.install
index 1932e4d..8db6d95 100644
--- a/flag.install
+++ b/flag.install
@@ -671,7 +671,8 @@ function flag_update_7306() {
     }
 
     // Update show_on_comment and show_on_entity properties to use new view
-    // mode settings. Since the old logic was to show on all view modes, do that.
+    // mode settings. Since the old logic was to show on all view modes, do
+    // that.
     if (!empty($flag->show_on_entity) || !empty($flag->show_on_comment)) {
       if ($entity_info = entity_get_info($flag->entity_type)) {
         foreach ($entity_info['view modes'] as $view_mode => $value) {
diff --git a/flag.module b/flag.module
index ca06c2c..204b60d 100644
--- a/flag.module
+++ b/flag.module
@@ -160,14 +160,15 @@ function flagging_save($flagging) {
 // @todo: flag_reset_flag():
 // - it should delete the flaggings.
 // - (it has other issues; see http://drupal.org/node/894992.)
-// - (is problematic: it might not be possible to delete all data in a single page request.)
+// - (is problematic: it might not be possible to delete all data in a single
+//   page request.)
 
 // @todo: Discuss: Note that almost all functions/identifiers dealing with
 // flaggings *aren't* prefixed by "flag_". For example:
-//  - The menu argument is %flagging, not %flag_flagging.
-//  - The entity type is "flagging", not "flag_flagging".
-// On the one hand this succinct version is readable and nice. On the other hand, it isn't
-// very "correct".
+// - The menu argument is %flagging, not %flag_flagging.
+// - The entity type is "flagging", not "flag_flagging".
+// On the one hand this succinct version is readable and nice. On the other
+// hand, it isn't very "correct".
 
 /**
  * Implements hook_entity_query_alter().
@@ -918,9 +919,10 @@ function flag_contextual_links_view_alter(&$element, $items) {
 
       list($entity_id) = entity_extract_ids($entity_type, $entity);
       if (!$flag->access($entity_id) && (!$flag->is_flagged($entity_id) || !$flag->access($entity_id, 'flag'))) {
-        // User has no permission to use this flag or flag does not apply to this
-        // object. The link is not skipped if the user has "flag" access but
-        // not "unflag" access (this way the unflag denied message is shown).
+        // User has no permission to use this flag or flag does not apply to
+        // this object. The link is not skipped if the user has "flag" access
+        // but not "unflag" access (this way the unflag denied message is
+        // shown).
         continue;
       }
 
@@ -1360,7 +1362,8 @@ function flag_flag_trigger($action, $flag, $entity_id, $account, $flagging) {
 
   // Generic "all flags" actions.
   foreach (trigger_get_assigned_actions('flag_' . $action)  as $aid => $action_info) {
-    // The 'if ($aid)' is a safeguard against http://drupal.org/node/271460#comment-886564
+    // The 'if ($aid)' is a safeguard against
+    // http://drupal.org/node/271460#comment-886564
     if ($aid) {
       actions_do($aid, $object, $context);
     }
@@ -1629,7 +1632,8 @@ function template_preprocess_flag(&$variables) {
       $variables['message_classes_array'][] = 'flag-' . $variables['status'] . '-message';
       $variables['message_text'] = $flag->get_label($inverse_action . '_message', $entity_id);
       $variables['flag_classes_array'][] = $variables['status'];
-      // By default we make our JS code remove, after a few seconds, only success messages.
+      // By default we make our JS code remove, after a few seconds, only
+      // success messages.
       $variables['message_classes_array'][] = 'flag-auto-remove';
     }
   }
@@ -1919,7 +1923,8 @@ function flag_get_flags($entity_type = NULL, $content_subtype = NULL, $account =
         // Ensure overridden flags are associated with their parent module.
         $flags[$name]->module = $default_flag->module;
 
-        // Update the flag with any properties that are "locked" by the code version.
+        // Update the flag with any properties that are "locked" by the code
+        // version.
         if (isset($default_flag->locked)) {
           $flags[$name]->locked = $default_flag->locked;
           foreach ($default_flag->locked as $property) {
@@ -2067,11 +2072,15 @@ function flag_get_flag_flagging_data($flag_name) {
  * @return
  *   If returning a single item's flags (that is, when $entity_id isn't NULL),
  *   an array of the structure
- *   [flag_name] => (flagging_id => [flagging_id], uid => [uid], entity_id => [entity_id], timestamp => [timestamp], ...)
+ *   [flag_name] => (
+ *     flagging_id => [flagging_id],
+ *     uid => [uid],
+ *     entity_id => [entity_id],
+ *     timestamp => [timestamp],
+ *     ...)
  *
  *   If returning all items' flags, an array of arrays for each flag:
  *   [flag_name] => [entity_id] => Object from above.
- *
  */
 function flag_get_user_flags($entity_type, $entity_id = NULL, $uid = NULL, $sid = NULL) {
   $flagged_content = &drupal_static(__FUNCTION__);
diff --git a/flag.rules.inc b/flag.rules.inc
index d3d047e..c159e3f 100644
--- a/flag.rules.inc
+++ b/flag.rules.inc
@@ -375,7 +375,8 @@ function flag_rules_action_info() {
       'access callback' => 'flag_rules_integration_access',
     );
   }
-  // For backward compatibility sake. This was the original name of the 'fetch node by user'.
+  // For backward compatibility sake. This was the original name of the
+  // 'fetch node by user'.
   $items['flag_fetch_entity_by_user'] = $items['flag_fetch_node_by_user'];
   $items['flag_fetch_entity_by_user']['label'] .= ' '. t('(Legacy)');
   return $items;
@@ -473,7 +474,8 @@ function flag_rules_get_flag_types() {
 }
 
 /**
- * Base action implementation: Fetch count of flags for a particular entity type.
+ * Base action implementation: Fetch count of flags for a particular entity
+ * type.
  *
  * During a flagging, the current flagging will be included in the count.
  * During an unflagging, the current flagging being removed will not yet have
@@ -570,7 +572,8 @@ function flag_rules_condition_info() {
 }
 
 /**
- * Options list callback for the operator parameter of the flagging threshold condition.
+ * Options list callback for the operator parameter of the flagging threshold
+ * condition.
  */
 function flag_rules_condition_threshold_operator_options() {
   return array(
diff --git a/flag_bookmark/flag_bookmark.install b/flag_bookmark/flag_bookmark.install
index 284784a..959e774 100644
--- a/flag_bookmark/flag_bookmark.install
+++ b/flag_bookmark/flag_bookmark.install
@@ -53,7 +53,8 @@ function flag_bookmark_enable() {
 }
 
 /**
- * Returns some node types to which the demonstration 'bookmarks' flag will apply.
+ * Returns some node types to which the demonstration 'bookmarks' flag will
+ * apply.
  */
 function _flag_bookmark_install_get_suggested_node_types() {
   $preferred = array('article', 'story', 'forum', 'blog');
diff --git a/includes/flag.export.inc b/includes/flag.export.inc
index 539899c..cf1721c 100644
--- a/includes/flag.export.inc
+++ b/includes/flag.export.inc
@@ -364,7 +364,8 @@ class FlagUpdate_3 {
     }
 
     // Update show_on_comment and show_on_entity properties to use new view
-    // mode settings. Since the old logic was to show on all view modes, do that.
+    // mode settings. Since the old logic was to show on all view modes, do
+    // that.
     if (!empty($flag->show_on_entity) || !empty($flag->show_on_comment)) {
       if ($entity_info = entity_get_info($flag->entity_type)) {
         foreach ($entity_info['view modes'] as $view_mode => $value) {
diff --git a/includes/flag/flag_flag.inc b/includes/flag/flag_flag.inc
index 44e7a7a..dfbed19 100644
--- a/includes/flag/flag_flag.inc
+++ b/includes/flag/flag_flag.inc
@@ -8,7 +8,8 @@
  */
 
 /**
- * This abstract class represents a flag, or, in Views 2 terminology, "a handler".
+ * This abstract class represents a flag, or, in Views 2 terminology,
+ * "a handler".
  *
  * This is the base class for all flag implementations. Notable derived
  * classes are flag_node and flag_comment.
@@ -29,8 +30,8 @@
  * - flag_flag::factory_by_array(), creates a flag handler from a configuration
  *   array. This is used by flag_get_default_flags() and the flag import form.
  * - flag_flag::factory_by_entity_type(), creates an empty flag handler for the
- *   given entity type. This is used when a new or dummy flag handler is required
- *   and there is no configuration yet.
+ *   given entity type. This is used when a new or dummy flag handler is
+ *   required and there is no configuration yet.
  *
  * The factory methods in turn all call the low-level function
  * flag_create_handler(), which obtains the correct handler for the flag, or if
@@ -94,7 +95,8 @@ class flag_flag {
   );
 
   /**
-   * An associative array containing textual errors that may be created during validation.
+   * An associative array containing textual errors that may be created during
+   * validation.
    *
    * The array keys should reflect the type of error being set. At this time,
    * the only "special" behavior related to the array keys is that
@@ -135,7 +137,8 @@ class flag_flag {
     }
 
     if (!empty($row->type)) {
-      // The loop loading from the database should further populate this property.
+      // The loop loading from the database should further populate this
+      // property.
       $flag->types[] = $row->type;
     }
 
@@ -189,7 +192,8 @@ class flag_flag {
       'unflag_long' => '',
       'unflag_message' => '',
       'unflag_denied_text' => '',
-      // The link type used by the flag, as defined in hook_flag_link_type_info().
+      // The link type used by the flag, as defined in
+      // hook_flag_link_type_info().
       'link_type' => 'toggle',
       'weight' => 0,
     );
@@ -245,7 +249,8 @@ class flag_flag {
    */
   function form_input($form_values) {
     // Load the form fields indiscriminately unto the flag (we don't care about
-    // stray FormAPI fields because we aren't touching unknown properties anyway.
+    // stray FormAPI fields because we aren't touching unknown properties
+    // anyway).
     foreach ($form_values as $field => $value) {
       $this->$field = $value;
     }
@@ -1511,8 +1516,8 @@ class flag_flag {
    * @param $variables = array()
    *  An array of further variables to pass to theme('flag'). For the full list
    *  of parameters, see flag.tpl.php. Of particular interest:
-   *  - after_flagging: Set to TRUE if this flag link is being displayed as the result
-   *    of a flagging action.
+   *  - after_flagging: Set to TRUE if this flag link is being displayed as the
+   *    result of a flagging action.
    *  - errors: An array of error messages.
    *
    * @return
diff --git a/includes/views/flag_plugin_argument_validate_flaggability.inc b/includes/views/flag_plugin_argument_validate_flaggability.inc
index f653412..91cff39 100644
--- a/includes/views/flag_plugin_argument_validate_flaggability.inc
+++ b/includes/views/flag_plugin_argument_validate_flaggability.inc
@@ -130,7 +130,8 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
     if ($flag_name == '*relationship*') {
       // Pick the first flag mentioned in the relationships.
       foreach ($this->view->relationship as $id => $handler) {
-        // Note: we can't do $handler->field, because the relationship handler's init() may overwrite it.
+        // Note: we can't do $handler->field, because the relationship handler's
+        // init() may overwrite it.
         if (strpos($handler->options['field'], 'flag') !== FALSE && !empty($handler->options['flag'])) {
           $flag = flag_get_flag($handler->options['flag']);
           if ($flag && $flag->entity_type == $this->flag_type) {
@@ -198,7 +199,8 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   function test_flagged($ids, $flag) {
-    // view_break_phrase() is guaranteed to return only integers, so this is SQL safe.
+    // view_break_phrase() is guaranteed to return only integers, so this is SQL
+    // safe.
     $flattened_ids = implode(',', $ids);
     return $this->_test_by_sql("SELECT entity_id FROM {flag_counts} WHERE fid = :fid AND entity_id IN ($flattened_ids) AND count > 0", array(':fid' => $flag->fid));
   }
diff --git a/tests/flag.test b/tests/flag.test
index 589e036..18aac4e 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -1002,7 +1002,8 @@ class FlagHookFlagAccessTestCase extends FlagTestCaseBase {
   }
 
   /**
-   * Verifies that the user sees the flag if a module returns TRUE (Allow) to override default access check.
+   * Verifies that the user sees the flag if a module returns TRUE (Allow) to
+   * override default access check.
    */
   function testFlagAccessAllowOverride() {
     variable_set('FlagHookFlagAccessTestCaseMode', 'allow');
@@ -1026,7 +1027,8 @@ class FlagHookFlagAccessTestCase extends FlagTestCaseBase {
   }
 
   /**
-   * Verifies that the user does not see the flag if a module returns FALSE (Deny).
+   * Verifies that the user does not see the flag if a module returns FALSE
+   * (Deny).
    */
   function testFlagAccessDeny() {
     variable_set('FlagHookFlagAccessTestCaseMode', 'deny');
diff --git a/theme/flag.tpl.php b/theme/flag.tpl.php
index 60a3113..3ef95aa 100644
--- a/theme/flag.tpl.php
+++ b/theme/flag.tpl.php
@@ -2,28 +2,33 @@
 
 /**
  * @file
- * Default theme implementation to display a flag link, and a message after the action
- * is carried out.
+ * Default theme implementation to display a flag link, and a message after the
+ * action is carried out.
  *
  * Available variables:
  *
  * - $flag: The flag object itself. You will only need to use it when the
  *   following variables don't suffice.
- * - $flag_name_css: The flag name, with all "_" replaced with "-". For use in 'class'
- *   attributes.
- * - $flag_classes: A space-separated list of CSS classes that should be applied to the link.
+ * - $flag_name_css: The flag name, with all "_" replaced with "-". For use in
+ *   'class' attributes.
+ * - $flag_classes: A space-separated list of CSS classes that should be applied
+ *   to the link.
  *
- * - $action: The action the link is about to carry out, either "flag" or "unflag".
+ * - $action: The action the link is about to carry out, either "flag" or
+ *   "unflag".
  * - $status: The status of the item; either "flagged" or "unflagged".
  *
  * - $link_href: The URL for the flag link.
  * - $link_text: The text to show for the link.
  * - $link_title: The title attribute for the link.
  *
- * - $message_text: The long message to show after a flag action has been carried out.
- * - $message_classes: A space-separated list of CSS classes that should be applied to
+ * - $message_text: The long message to show after a flag action has been
+ *   carried out.
+ * - $message_classes: A space-separated list of CSS classes that should be
+ *   applied to
  *   the message.
- * - $after_flagging: This template is called for the link both before and after being
+ * - $after_flagging: This template is called for the link both before and after
+ *   being
  *   flagged. If displaying to the user immediately after flagging, this value
  *   will be boolean TRUE. This is usually used in conjunction with immedate
  *   JavaScript-based toggling of flags.
@@ -35,8 +40,8 @@
  * - flag--name.tpl.php
  * - flag--link-type.tpl.php
  *
- * NOTE: This template spaces out the <span> tags for clarity only. When doing some
- * advanced theming you may have to remove all the whitespace.
+ * NOTE: This template spaces out the <span> tags for clarity only. When doing
+ * some advanced theming you may have to remove all the whitespace.
  */
 ?>
 <?php if ($needs_wrapping_element): ?>
-- 
1.8.4


From cf8e277d855721c7206c356f3410c9d68b390d28 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:46:35 +0100
Subject: [PATCH 02/13] Fixed formatting of single-line comments.

---
 flag.module                                        | 12 ++++++++----
 includes/flag.export.inc                           |  3 ++-
 includes/views/flag_handler_argument_entity_id.inc |  3 ++-
 includes/views/flag_handler_field_ops.inc          | 12 ++++++++----
 4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/flag.module b/flag.module
index 204b60d..a7adea9 100644
--- a/flag.module
+++ b/flag.module
@@ -183,7 +183,8 @@ function flag_entity_query_alter(EntityFieldQuery $query) {
 
   // Alter only flagging queries with bundle conditions.
   if (isset($conditions['entity_type']) && $conditions['entity_type']['value'] == 'flagging' && isset($conditions['bundle'])) {
-    $query->addTag('flagging_flag_names'); // Add tag to alter query.
+    // Add tag to alter query.
+    $query->addTag('flagging_flag_names');
     // Make value and operator of the bundle condition accessible
     // in hook_query_TAG_alter.
     $query->addMetaData('flag_name_value', $conditions['bundle']['value']);
@@ -254,7 +255,8 @@ function flag_menu() {
   );
 
   $items[FLAG_ADMIN_PATH . '/manage/%flag'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('flag_form', FLAG_ADMIN_PATH_START + 1),
     'access callback' => 'user_access',
@@ -266,7 +268,8 @@ function flag_menu() {
     'title arguments' => array(FLAG_ADMIN_PATH_START + 1),
   );
   $items[FLAG_ADMIN_PATH . '/manage/%flag/edit'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'title' => 'Edit flag',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
@@ -290,7 +293,8 @@ function flag_menu() {
     'type' => MENU_CALLBACK,
   );
   $items[FLAG_ADMIN_PATH . '/manage/%flag/update'] = array(
-    'load arguments' => array(TRUE), // Allow for disabled flags.
+    // Allow for disabled flags.
+    'load arguments' => array(TRUE),
     'title' => 'Update',
     'page callback' => 'flag_update_page',
     'page arguments' => array(FLAG_ADMIN_PATH_START + 1),
diff --git a/includes/flag.export.inc b/includes/flag.export.inc
index cf1721c..7bb1e7d 100644
--- a/includes/flag.export.inc
+++ b/includes/flag.export.inc
@@ -15,7 +15,8 @@
  *   in hook_flag_default_flags().
  */
 function flag_export_flags($flags = array(), $module = '', $indent = '') {
-  module_load_include('inc', 'features', 'features.export'); // For features_var_export() (optional).
+  // For features_var_export() (optional).
+  module_load_include('inc', 'features', 'features.export');
   $output = $indent . '$flags = array();' . "\n";
   foreach ($flags as $item) {
     if (is_object($item)) {
diff --git a/includes/views/flag_handler_argument_entity_id.inc b/includes/views/flag_handler_argument_entity_id.inc
index f5d3b1a..d3e8ab7 100644
--- a/includes/views/flag_handler_argument_entity_id.inc
+++ b/includes/views/flag_handler_argument_entity_id.inc
@@ -27,7 +27,8 @@ class flag_handler_argument_entity_id extends views_handler_argument_numeric {
    */
   function title_query() {
     if (!($flag = $this->get_flag())) {
-      return array(); // Error message is printed by get_flag().
+      // Error message is printed by get_flag().
+      return array();
     }
     $views_info = $flag->get_views_info();
 
diff --git a/includes/views/flag_handler_field_ops.inc b/includes/views/flag_handler_field_ops.inc
index 58830f1..125af26 100644
--- a/includes/views/flag_handler_field_ops.inc
+++ b/includes/views/flag_handler_field_ops.inc
@@ -35,7 +35,8 @@ class flag_handler_field_ops extends views_handler_field {
   function get_parent_relationship() {
     $parent = $this->view->relationship[$this->options['relationship']]->options['relationship'];
     if (!$parent || $parent == 'none') {
-      return NULL; // Base query table.
+      // Base query table.
+      return NULL;
     }
     else {
       return $this->view->relationship[$parent]->alias;
@@ -66,7 +67,8 @@ class flag_handler_field_ops extends views_handler_field {
    */
   function query() {
     if (!($flag = $this->get_flag())) {
-      return; // Error message is printed in render().
+      // Error message is printed in render().
+      return;
     }
     $info = $flag->get_views_info();
     $parent = $this->get_parent_relationship();
@@ -128,7 +130,8 @@ class flag_handler_field_ops extends views_handler_field {
    */
   function pre_render(&$values) {
     if (!($flag = $this->get_flag())) {
-      return; // Error message is printed in render().
+      // Error message is printed in render().
+      return;
     }
 
     $ids = array();
@@ -144,7 +147,8 @@ class flag_handler_field_ops extends views_handler_field {
 
   function render($values) {
     if (!($flag = $this->get_flag())) {
-      return t('Missing flag'); // get_flag() itself will print a more detailed message.
+      // get_flag() itself will print a more detailed message.
+      return t('Missing flag');
     }
 
     $entity_id = $values->{$this->aliases['entity_id']};
-- 
1.8.4


From c493e95b02b029ee76692b251d874c9ccf48e9b5 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:45:58 +0100
Subject: [PATCH 03/13] Fixed array formatting: split over multiple lines,
 terminal commas.

---
 flag.install                                   | 68 +++++++++++++++++++++-----
 flag.module                                    | 11 ++++-
 flag.rules.inc                                 |  6 +--
 includes/flag.actions.inc                      |  2 +-
 includes/flag.admin.inc                        | 21 ++++++--
 includes/views/flag_handler_filter_flagged.inc |  6 ++-
 tests/flag.test                                | 23 +++++++--
 7 files changed, 112 insertions(+), 25 deletions(-)

diff --git a/flag.install b/flag.install
index 8db6d95..5e2063a 100644
--- a/flag.install
+++ b/flag.install
@@ -113,7 +113,7 @@ function flag_schema() {
         'not null' => TRUE,
         'default' => 0,
         'disp-size' => 11,
-      )
+      ),
     ),
     'primary key' => array('flagging_id'),
     'unique keys' => array(
@@ -121,7 +121,12 @@ function flag_schema() {
     ),
     'indexes' => array(
       'entity_type_uid_sid' => array('entity_type', 'uid', 'sid'),
-      'entity_type_entity_id_uid_sid' => array('entity_type', 'entity_id', 'uid', 'sid'),
+      'entity_type_entity_id_uid_sid' => array(
+        'entity_type',
+        'entity_id',
+        'uid',
+        'sid',
+      ),
       'entity_id_fid' => array('entity_id', 'fid'),
     ),
   );
@@ -190,7 +195,7 @@ function flag_schema() {
         'not null' => TRUE,
         'default' => 0,
         'disp-size' => 11,
-      )
+      ),
     ),
     'primary key' => array('fid', 'entity_id'),
     'indexes' => array(
@@ -296,7 +301,11 @@ function flag_update_6200() {
 function flag_update_6201() {
   // Remove "content type" from one key, see http://drupal.org/node/612602.
   db_drop_unique_key('flag_content', 'fid_content_type_content_id_uid');
-  db_add_unique_key('flag_content', 'fid_content_id_uid', array('fid', 'content_id', 'uid'));
+  db_add_unique_key('flag_content', 'fid_content_id_uid', array(
+    'fid',
+    'content_id',
+    'uid',
+  ));
 
   // Add a count index, see http://drupal.org/node/489610.
   db_add_index('flag_counts', 'count', array('count'));
@@ -311,11 +320,25 @@ function flag_update_6202() {
   db_drop_index('flag_content', 'content_type_uid');
 
   // Add the column.
-  db_add_field('flag_content', 'sid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field('flag_content', 'sid', array(
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+    'default' => 0,
+  ));
 
   // Re-add the removed keys.
-  db_add_unique_key('flag_content', 'fid_content_id_uid_sid', array('fid', 'content_id', 'uid', 'sid'));
-  db_add_index('flag_content', 'content_type_uid_sid', array('content_type', 'uid', 'sid'));
+  db_add_unique_key('flag_content', 'fid_content_id_uid_sid', array(
+    'fid',
+    'content_id',
+    'uid',
+    'sid',
+  ));
+  db_add_index('flag_content', 'content_type_uid_sid', array(
+    'content_type',
+    'uid',
+    'sid',
+  ));
 }
 
 /**
@@ -357,14 +380,25 @@ function flag_update_6206() {
     db_drop_unique_key('flag_content', 'content_type_content_id_uid_sid');
   }
 
-  db_add_index('flag_content', 'content_type_content_id_uid_sid', array('content_type', 'content_id', 'uid', 'sid'));
+  db_add_index('flag_content', 'content_type_content_id_uid_sid', array(
+    'content_type',
+    'content_id',
+    'uid',
+    'sid',
+  ));
 }
 
 /**
  * Adds column last_updated to flag_counts table.
  */
 function flag_update_6207() {
-  db_add_field('flag_counts', 'last_updated', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-size' => 11), array('indexes' => array('last_updated' => array('last_updated'))));
+  db_add_field('flag_counts', 'last_updated', array(
+    'type' => 'int',
+    'unsigned' => TRUE,
+    'not null' => TRUE,
+    'default' => 0,
+    'disp-size' => 11),
+    array('indexes' => array('last_updated' => array('last_updated'))));
 }
 
 /**
@@ -482,7 +516,12 @@ function flag_update_7303() {
       ),
       'indexes' => array(
         'entity_type_uid_sid' => array('entity_type', 'uid', 'sid'),
-        'entity_type_content_id_uid_sid' => array('entity_type', 'content_id', 'uid', 'sid'),
+        'entity_type_content_id_uid_sid' => array(
+          'entity_type',
+          'content_id',
+          'uid',
+          'sid',
+        ),
         'content_id_fid' => array('content_id', 'fid'),
       ),
     )
@@ -510,7 +549,12 @@ function flag_update_7303() {
         'fid_entity_id_uid_sid' => array('fid', 'entity_id', 'uid', 'sid'),
       ),
       'indexes' => array(
-        'entity_type_entity_id_uid_sid' => array('entity_type', 'entity_id', 'uid', 'sid'),
+        'entity_type_entity_id_uid_sid' => array(
+          'entity_type',
+          'entity_id',
+          'uid',
+          'sid',
+        ),
         'entity_id_fid' => array('entity_id', 'fid'),
       ),
     )
@@ -569,7 +613,7 @@ function flag_update_7304() {
       'indexes' => array(
         'fid_entity_type' => array('fid', 'entity_type'),
         'entity_type_content_id' => array('entity_type', 'content_id'),
-      )
+      ),
     )
   );
 
diff --git a/flag.module b/flag.module
index a7adea9..52ae162 100644
--- a/flag.module
+++ b/flag.module
@@ -667,7 +667,7 @@ function flag_field_extra_fields() {
         $extra[$flag->entity_type][$bundle_name]['form']['flag'] = array(
           'label' => t('Flags'),
           'description' => t('Checkboxes for toggling flags'),
-          'weight' => 10
+          'weight' => 10,
         );
       }
 
@@ -1902,7 +1902,14 @@ function flag_get_flags($entity_type = NULL, $content_subtype = NULL, $account =
     $query = db_select('flag', 'f');
     $query->leftJoin('flag_types', 'fn', 'fn.fid = f.fid');
     $result = $query
-      ->fields('f', array('fid', 'entity_type', 'name', 'title', 'global', 'options'))
+      ->fields('f', array(
+        'fid',
+        'entity_type',
+        'name',
+        'title',
+        'global',
+        'options',
+      ))
       ->fields('fn', array('type'))
       ->execute();
     foreach ($result as $row) {
diff --git a/flag.rules.inc b/flag.rules.inc
index c159e3f..4212b9a 100644
--- a/flag.rules.inc
+++ b/flag.rules.inc
@@ -81,7 +81,7 @@ class FlagRulesUIClass extends RulesDataUI implements RulesDataDirectInputFormIn
       '#required' => empty($info['optional']),
       '#multiple' => FALSE,
       '#default_value' => $settings[$name],
-      '#empty' => t('There is no suiting flag available.')
+      '#empty' => t('There is no suiting flag available.'),
     );
     return $form;
   }
@@ -515,7 +515,7 @@ function flag_rules_condition_info() {
             'type' => 'flag',
             'label' => t('Flag'),
             'flag_type' => $type,
-            'description' => t('The flag to check for.')
+            'description' => t('The flag to check for.'),
           ),
           $type => array(
             'type' => $type,
@@ -551,7 +551,7 @@ function flag_rules_condition_info() {
             'type' => 'flag',
             'label' => t('Flag'),
             'flag_type' => $type,
-            'description' => t('The flag to check for.')
+            'description' => t('The flag to check for.'),
           ),
           $type => array(
             'type' => $type,
diff --git a/includes/flag.actions.inc b/includes/flag.actions.inc
index f414431..c920971 100644
--- a/includes/flag.actions.inc
+++ b/includes/flag.actions.inc
@@ -15,7 +15,7 @@ function flag_trigger_info() {
         'label' => t('Object has been flagged with any flag'),
       ),
       'flag_unflag' => array(
-        'label' => t('Object has been unflagged with any flag')
+        'label' => t('Object has been unflagged with any flag'),
       ),
     ),
   );
diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
index 190ceb7..51078c9 100644
--- a/includes/flag.admin.inc
+++ b/includes/flag.admin.inc
@@ -116,7 +116,13 @@ function theme_flag_admin_listing($variables) {
   if (count($flags) > 1) {
     $header[] = t('Weight');
   }
-  $header = array_merge($header, array(t('Flag type'), t('Roles'), t('Entity bundles'), t('Global?'), t('Operations')));
+  $header = array_merge($header, array(
+    t('Flag type'),
+    t('Roles'),
+    t('Entity bundles'),
+    t('Global?'),
+    t('Operations'),
+  ));
   $output .= theme('table', array(
     'header' => $header,
     'rows' => $rows,
@@ -142,7 +148,11 @@ function theme_flag_admin_listing_disabled($variables) {
       $ops = array();
       if (!$flag->is_compatible()) {
         $flag_updates_needed = TRUE;
-        $ops['flags_update'] = array('title' => '<strong>' . t('update code') . '</strong>', 'href' => $flag->admin_path('update'), 'html' => TRUE);
+        $ops['flags_update'] = array(
+          'title' => '<strong>' . t('update code') . '</strong>',
+          'href' => $flag->admin_path('update'),
+          'html' => TRUE,
+        );
       }
       else {
         $ops['flags_enable'] = array('title' => t('enable'), 'href' => $flag->admin_path('edit'));
@@ -163,7 +173,12 @@ function theme_flag_admin_listing_disabled($variables) {
   }
 
   if (!empty($rows)) {
-    $header = array(t('Disabled Flags'), t('Module'), t('Flag type'), t('Operations'));
+    $header = array(
+      t('Disabled Flags'),
+      t('Module'),
+      t('Flag type'),
+      t('Operations'),
+    );
     $output .= theme('table', array('header' => $header, 'rows' => $rows));
   }
 
diff --git a/includes/views/flag_handler_filter_flagged.inc b/includes/views/flag_handler_filter_flagged.inc
index d22c40b..494859f 100644
--- a/includes/views/flag_handler_filter_flagged.inc
+++ b/includes/views/flag_handler_filter_flagged.inc
@@ -21,7 +21,11 @@ class flag_handler_filter_flagged extends views_handler_filter_boolean_operator
     parent::options_form($form, $form_state);
     $form['value']['#type'] = 'radios';
     $form['value']['#title'] = t('Status');
-    $form['value']['#options'] = array(1 => t('Flagged'), 0 => t('Not flagged'), 'All' => t('All'));
+    $form['value']['#options'] = array(
+      1 => t('Flagged'),
+      0 => t('Not flagged'),
+      'All' => t('All'),
+    );
     $form['value']['#default_value'] = empty($this->options['value']) ? '0' : $this->options['value'];
     $form['value']['#description'] = '<p>' . t('This filter is only needed if the relationship used has the "Include only flagged content" option <strong>unchecked</strong>. Otherwise, this filter is useless, because all records are already limited to flagged content.') . '</p><p>' . t('By choosing <em>Not flagged</em>, it is possible to create a list of content <a href="@unflagged-url">that is specifically not flagged</a>.', array('@unflagged-url' => 'http://drupal.org/node/299335')) . '</p>';
   }
diff --git a/tests/flag.test b/tests/flag.test
index 18aac4e..4122b2b 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -277,7 +277,13 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $saved = $edit;
     $saved['roles'] = array('flag' => array(2), 'unflag' => array(2));
     $saved['types'] = array('page');
-    $saved['show_in_links'] = array('full' => 0, 'teaser' => 0, 'rss' => 0, 'search_index' => 0, 'search_result' => 0);
+    $saved['show_in_links'] = array(
+      'full' => 0,
+      'teaser' => 0,
+      'rss' => 0,
+      'search_index' => 0,
+      'search_result' => 0,
+    );
     unset($saved['roles[flag][2]'], $saved['roles[unflag][2]'], $saved['types[article]'], $saved['types[page]'], $saved['show_in_links[full]'], $saved['show_in_links[teaser]'], $saved['show_in_links[rss]'], $saved['show_in_links[search_index]'], $saved['show_in_links[search_result]']);
 
     $this->drupalPost(FLAG_ADMIN_PATH . '/add/node', $edit, t('Save flag'));
@@ -331,7 +337,13 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $saved = $edit;
     $saved['roles'] = array('flag' => array(2), 'unflag' => array(2));
     $saved['types'] = array('article');
-    $saved['show_in_links'] = array('full' => TRUE, 'teaser' => TRUE, 'rss' => 0, 'search_index' => 0, 'search_result' => 0);
+    $saved['show_in_links'] = array(
+      'full' => TRUE,
+      'teaser' => TRUE,
+      'rss' => 0,
+      'search_index' => 0,
+      'search_result' => 0,
+    );
     unset($saved['roles[flag][2]'], $saved['roles[unflag][2]'], $saved['types[article]'], $saved['types[page]'], $saved['show_in_links[full]'], $saved['show_in_links[teaser]'], $saved['show_in_links[rss]'], $saved['show_in_links[search_index]'], $saved['show_in_links[search_result]']);
 
     $this->drupalPost(FLAG_ADMIN_PATH . '/manage/' . $flag->name, $edit, t('Save flag'));
@@ -1101,7 +1113,12 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
     $this->flag3 = $this->createFlag($flag_data);
 
     // Create test user who can flag and unflag.
-    $this->flag_unflag_user = $this->drupalCreateUser(array('flag test_flag_1', 'unflag test_flag_1', 'flag test_flag_2', 'unflag test_flag_2'));
+    $this->flag_unflag_user = $this->drupalCreateUser(array(
+      'flag test_flag_1',
+      'unflag test_flag_1',
+      'flag test_flag_2',
+      'unflag test_flag_2',
+    ));
     $this->drupalLogin($this->flag_unflag_user);
 
   }
-- 
1.8.4


From 3a2ec3008a15748c3945be9d873f8559de25b27a Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:47:49 +0100
Subject: [PATCH 04/13] Fixed missing object instantiation parentheses.

---
 flag.module              | 4 ++--
 includes/flag.export.inc | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/flag.module b/flag.module
index 52ae162..fddedfa 100644
--- a/flag.module
+++ b/flag.module
@@ -577,10 +577,10 @@ function flag_get_types() {
 function flag_create_handler($entity_type) {
   $definition = flag_fetch_definition($entity_type);
   if (isset($definition) && class_exists($definition['handler'])) {
-    $handler = new $definition['handler'];
+    $handler = new $definition['handler']();
   }
   else {
-    $handler = new flag_broken;
+    $handler = new flag_broken();
   }
   $handler->entity_type = $entity_type;
   $handler->construct();
diff --git a/includes/flag.export.inc b/includes/flag.export.inc
index 7bb1e7d..64f7f46 100644
--- a/includes/flag.export.inc
+++ b/includes/flag.export.inc
@@ -270,7 +270,7 @@ function flag_update_export(&$flag) {
     if (substr($class, 0, 11) == 'FlagUpdate_') {
       // @todo: change this to work with the static class when we drop support
       // for PHP 5.2: see commit d5b517.
-      $update_handler = new $class;
+      $update_handler = new $class();
       // Cast to string, as decimals as array keys seem to be rounded down to
       // ints, WTF PHP?
       $version = (string) $update_handler->old_api_version;
-- 
1.8.4


From 8e7dbb292e784c2ed4a22e4fe67701e22483b1af Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:48:19 +0100
Subject: [PATCH 05/13] Fixed spacing around operators.

---
 flag.module         |  2 +-
 flag.rules.inc      |  8 ++++----
 flag_actions.module | 12 ++++++------
 tests/flag.test     |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/flag.module b/flag.module
index fddedfa..ff40904 100644
--- a/flag.module
+++ b/flag.module
@@ -930,7 +930,7 @@ function flag_contextual_links_view_alter(&$element, $items) {
         continue;
       }
 
-      $element['#links']['flag-'. $name] = array(
+      $element['#links']['flag-' . $name] = array(
         'title' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id),
         'html' => TRUE,
       );
diff --git a/flag.rules.inc b/flag.rules.inc
index 4212b9a..60abc45 100644
--- a/flag.rules.inc
+++ b/flag.rules.inc
@@ -378,7 +378,7 @@ function flag_rules_action_info() {
   // For backward compatibility sake. This was the original name of the
   // 'fetch node by user'.
   $items['flag_fetch_entity_by_user'] = $items['flag_fetch_node_by_user'];
-  $items['flag_fetch_entity_by_user']['label'] .= ' '. t('(Legacy)');
+  $items['flag_fetch_entity_by_user']['label'] .= ' ' . t('(Legacy)');
   return $items;
 }
 
@@ -595,10 +595,10 @@ function flag_rules_condition_threshold($flag, $entity, $number, $operator = '='
   $count = $flag->get_count($flag->get_entity_id($entity));
 
   switch ($operator) {
-    case '>' : return $count >  $number;
+    case '>': return $count > $number;
     case '>=': return $count >= $number;
-    case '=' : return $count == $number;
-    case '<' : return $count <  $number;
+    case '=': return $count == $number;
+    case '<': return $count < $number;
     case '<=': return $count <= $number;
   }
 }
diff --git a/flag_actions.module b/flag_actions.module
index f4c3aed..6ab5222 100644
--- a/flag_actions.module
+++ b/flag_actions.module
@@ -379,7 +379,7 @@ function theme_flag_actions_add_form($variables) {
   $fieldset = array(
     '#type' => 'fieldset',
     '#title' => t('Add a new flag action'),
-    '#children' => '<div class="container-inline">'. drupal_render($form['flag']) . drupal_render($form['submit']) .'</div>',
+    '#children' => '<div class="container-inline">' . drupal_render($form['flag']) . drupal_render($form['submit']) . '</div>',
     '#parents' => array('add_action'),
     '#attributes' => array(),
     '#groups' => array('add_action' => array()),
@@ -422,7 +422,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
 
   $form['new'] = array(
     '#type' => 'value',
-    '#value' => isset($callback) ? FALSE: TRUE,
+    '#value' => isset($callback) ? FALSE : TRUE,
   );
 
   if (!isset($callback)) {
@@ -430,7 +430,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
 
     $actions = $flag->get_valid_actions();
     $options = array();
-    foreach($actions as $key => $action) {
+    foreach ($actions as $key => $action) {
       $options[$key] = $action['label'];
     }
 
@@ -449,7 +449,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
   elseif (!isset($action)) {
     $actions = $flag->get_valid_actions();
-    $action = (object)$actions[$callback];
+    $action = (object) $actions[$callback];
     $action->parameters = array();
     $action->event = 'flag';
     $action->threshold = 10;
@@ -512,7 +512,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
 
   // Merge in the standard flag action form.
-  $action_form = $callback .'_form';
+  $action_form = $callback . '_form';
   $edit = array();
   if (function_exists($action_form)) {
     $edit += $action->parameters;
@@ -524,7 +524,7 @@ function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL)
   }
 
   // Add a few customizations to existing flag actions.
-  $flag_actions_form = 'flag_actions_'. $callback .'_form';
+  $flag_actions_form = 'flag_actions_' . $callback . '_form';
   if (function_exists($flag_actions_form)) {
     $flag_actions_form($form, $flag, $edit);
   }
diff --git a/tests/flag.test b/tests/flag.test
index 4122b2b..2234195 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -305,7 +305,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
     $permissions = user_role_permissions(user_roles());
     foreach ($saved['roles'] as $action => $rids) {
       foreach ($rids as $rid) {
-        $permission_string = "$action ". $saved['name'];
+        $permission_string = "$action " . $saved['name'];
         $this->assertTrue(isset($permissions[$rid][$permission_string]), t('Permission %perm set for flag.', array(
           '%perm' => $permission_string,
         )));
@@ -370,7 +370,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
 
     foreach ($saved['roles'] as $action => $rids) {
       foreach ($rids as $rid) {
-        $permission_string = "$action ". $saved['name'];
+        $permission_string = "$action " . $saved['name'];
         $this->assertTrue(isset($permissions[$rid][$permission_string]), t('Permission %perm set for flag.', array(
           '%perm' => $permission_string,
         )));
-- 
1.8.4


From e3cd3104ee8850cbd20f6d0b1bdb40785173b090 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:49:04 +0100
Subject: [PATCH 06/13] Fixed formatting of documentation @see tags.

---
 flag.api.php | 2 +-
 flag.module  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/flag.api.php b/flag.api.php
index a37805d..5b93bb3 100644
--- a/flag.api.php
+++ b/flag.api.php
@@ -93,7 +93,7 @@ function hook_flag_default_flags() {
 /**
  * Allow modules to alter a flag when it is initially loaded.
  *
- * @see flag_get_flags().
+ * @see flag_get_flags()
  */
 function hook_flag_alter(&$flag) {
 
diff --git a/flag.module b/flag.module
index ff40904..e0b9aa5 100644
--- a/flag.module
+++ b/flag.module
@@ -735,7 +735,7 @@ function flag_form_node_type_form_alter(&$form, &$form_state, $form_id) {
  * Warning: will not work on entity types that are not fieldable, as this relies
  * on a field module hook.
  *
- * @see flag_field_attach_submit().
+ * @see flag_field_attach_submit()
  */
 function flag_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
   list($id) = entity_extract_ids($entity_type, $entity);
@@ -844,7 +844,7 @@ function flag_field_attach_form($entity_type, $entity, &$form, &$form_state, $la
 /**
  * Implements hook_field_attach_submit().
  *
- * @see flag_field_attach_form().
+ * @see flag_field_attach_form()
  */
 function flag_field_attach_submit($entity_type, $entity, $form, &$form_state) {
   // This is invoked for each flag_field_attach_form(), but possibly more than
@@ -882,7 +882,7 @@ function flag_field_attach_update($entity_type, $entity) {
 /**
  * Shared saving routine between flag_field_attach_insert/update().
  *
- * @see flag_field_attach_form().
+ * @see flag_field_attach_form()
  */
 function flag_field_attach_save($entity_type, $entity) {
   list($id) = entity_extract_ids($entity_type, $entity);
-- 
1.8.4


From c7d8a72b04bee819833fe2f575c90c817dab5744 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:50:03 +0100
Subject: [PATCH 07/13] Fixed indentation errors.

---
 flag.module                         |  2 +-
 flag_bookmark/flag_bookmark.install | 36 ++++++++++++++++++------------------
 includes/flag.admin.inc             | 22 +++++++++++-----------
 includes/flag/flag_flag.inc         | 24 ++++++++++++------------
 tests/flag.test                     |  6 +++---
 5 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/flag.module b/flag.module
index e0b9aa5..c0bd920 100644
--- a/flag.module
+++ b/flag.module
@@ -987,7 +987,7 @@ function flag_entity_view($entity, $type, $view_mode, $langcode) {
     // The pseudofield output.
     if ($flag->show_as_field) {
       $entity->content['flag_' . $flag->name] = array(
-       '#markup' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id, array('needs_wrapping_element' => TRUE)),
+        '#markup' => $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id, array('needs_wrapping_element' => TRUE)),
       );
     }
   }
diff --git a/flag_bookmark/flag_bookmark.install b/flag_bookmark/flag_bookmark.install
index 959e774..79f9ed1 100644
--- a/flag_bookmark/flag_bookmark.install
+++ b/flag_bookmark/flag_bookmark.install
@@ -21,24 +21,24 @@ function flag_bookmark_enable() {
     // flag is overwritten or re-created.
     $flag = flag_flag::factory_by_entity_type('node');
     $configuration = array(
-        'name' => 'bookmarks',
-        'global' => 0,
-        'show_in_links' => array(
-          'full' => 1,
-          'teaser' => 1,
-        ),
-        'show_on_form' => 1,
-        // The following UI labels aren't wrapped in t() because they are written
-        // to the DB in English. They are passed to t() later, thus allowing for
-        // multilingual sites.
-        'title' => 'Bookmarks',
-        'flag_short' => 'Bookmark this',
-        'flag_long' => 'Add this post to your bookmarks',
-        'flag_message' => 'This post has been added to your bookmarks',
-        'unflag_short' => 'Unbookmark this',
-        'unflag_long' => 'Remove this post from your bookmarks',
-        'unflag_message' => 'This post has been removed from your bookmarks',
-        'types' => _flag_bookmark_install_get_suggested_node_types(),
+      'name' => 'bookmarks',
+      'global' => 0,
+      'show_in_links' => array(
+        'full' => 1,
+        'teaser' => 1,
+      ),
+      'show_on_form' => 1,
+      // The following UI labels aren't wrapped in t() because they are written
+      // to the DB in English. They are passed to t() later, thus allowing for
+      // multilingual sites.
+      'title' => 'Bookmarks',
+      'flag_short' => 'Bookmark this',
+      'flag_long' => 'Add this post to your bookmarks',
+      'flag_message' => 'This post has been added to your bookmarks',
+      'unflag_short' => 'Unbookmark this',
+      'unflag_long' => 'Remove this post from your bookmarks',
+      'unflag_message' => 'This post has been removed from your bookmarks',
+      'types' => _flag_bookmark_install_get_suggested_node_types(),
     );
     $flag->form_input($configuration);
     $flag->save();
diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
index 51078c9..7759cf2 100644
--- a/includes/flag.admin.inc
+++ b/includes/flag.admin.inc
@@ -394,17 +394,17 @@ function flag_form($form, &$form_state, $flag) {
     '#title' => t('Token replacement'),
     '#type' => 'fieldset',
     '#description' =>
-      '<p>' . t('The above six texts may contain any of the tokens listed below. For example, <em>"Flag link text"</em> could be entered as:') . '</p>' .
-      theme('item_list', array(
-        'items' => array(
-          t('Add &lt;em&gt;[node:title]&lt;/em&gt; to your favorites'),
-          t('Add this [node:type] to your favorites'),
-          t('Vote for this proposal ([node:flag-vote-count] people have already done so)'),
-        ),
-        'attributes' => array('class' => 'token-examples'),
-      )) .
-      '<p>' . t('These tokens will be replaced with the appropriate fields from the node (or user, or comment).') . '</p>' .
-      theme('flag_tokens_browser', array('types' => $flag->get_labels_token_types())),
+    '<p>' . t('The above six texts may contain any of the tokens listed below. For example, <em>"Flag link text"</em> could be entered as:') . '</p>' .
+    theme('item_list', array(
+      'items' => array(
+        t('Add &lt;em&gt;[node:title]&lt;/em&gt; to your favorites'),
+        t('Add this [node:type] to your favorites'),
+        t('Vote for this proposal ([node:flag-vote-count] people have already done so)'),
+      ),
+      'attributes' => array('class' => 'token-examples'),
+    )) .
+    '<p>' . t('These tokens will be replaced with the appropriate fields from the node (or user, or comment).') . '</p>' .
+    theme('flag_tokens_browser', array('types' => $flag->get_labels_token_types())),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
diff --git a/includes/flag/flag_flag.inc b/includes/flag/flag_flag.inc
index dfbed19..10a610f 100644
--- a/includes/flag/flag_flag.inc
+++ b/includes/flag/flag_flag.inc
@@ -631,18 +631,18 @@ class flag_flag {
    *   TRUE if the flag is enabled for this type and subtype.
    */
   function access_entity_enabled($entity_type, $content_subtype = NULL) {
-   $entity_type_matches = ($this->entity_type == $entity_type);
-   $sub_type_matches = FALSE;
-   if (!isset($content_subtype) || !count($this->types)) {
-     // Subtype automatically matches if we're not asked about it,
-     // or if the flag applies to all subtypes.
-     $sub_type_matches = TRUE;
-   }
-   else {
-     $sub_type_matches = in_array($content_subtype, $this->types);
-   }
-   return $entity_type_matches && $sub_type_matches;
- }
+    $entity_type_matches = ($this->entity_type == $entity_type);
+    $sub_type_matches = FALSE;
+    if (!isset($content_subtype) || !count($this->types)) {
+      // Subtype automatically matches if we're not asked about it,
+      // or if the flag applies to all subtypes.
+      $sub_type_matches = TRUE;
+    }
+    else {
+      $sub_type_matches = in_array($content_subtype, $this->types);
+    }
+    return $entity_type_matches && $sub_type_matches;
+  }
 
   /**
    * Determine whether the flag should show a flag link in entity links.
diff --git a/tests/flag.test b/tests/flag.test
index 2234195..eb001e6 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -1064,7 +1064,7 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
    * Implements getInfo().
    */
   public static function getInfo() {
-     return array(
+    return array(
       'name' => 'Entity Field Query',
       'description' => 'Entity Field Query for flagging entities.',
       'group' => 'Flag',
@@ -1127,7 +1127,7 @@ class FlagEntityFieldQueryTestCase extends FlagTestCaseBase {
    * Test use of EntityFieldQuery with flagging entities.
    */
   function testEntityFieldQuery() {
-     $node_settings = array(
+    $node_settings = array(
       'title' => $this->randomName(),
       'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(32)))),
       'uid' => 1,
@@ -1169,7 +1169,7 @@ class FlagHookInvocationsTestCase extends FlagTestCaseBase {
    * Implements getInfo().
    */
   public static function getInfo() {
-     return array(
+    return array(
       'name' => 'Hook invocations',
       'description' => 'Invocation of flag and entity hooks and rules during flagging and unflagging.',
       'group' => 'Flag',
-- 
1.8.4


From af0cd625fd4e1170c92ce080a7f9ccd0e78e7d09 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:45:04 +0100
Subject: [PATCH 08/13] Fixed stray spaces.

---
 flag.api.php                                       |  8 ++++----
 flag.module                                        | 10 +++++-----
 includes/flag.admin.inc                            |  8 ++++----
 plugins/access/flag_is_flagged/flag_is_flagged.inc |  2 +-
 tests/flag_hook_test/flag_hook_test.module         |  6 +++---
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/flag.api.php b/flag.api.php
index 5b93bb3..36f4138 100644
--- a/flag.api.php
+++ b/flag.api.php
@@ -58,11 +58,11 @@ function hook_flag_type_info_alter(&$definitions) {
  */
 function hook_flag_default_flags() {
   $flags = array();
-  $flags['bookmarks'] = array (
+  $flags['bookmarks'] = array(
     'entity_type' => 'node',
     'title' => 'Bookmarks',
     'global' => FALSE,
-    'types' => array (
+    'types' => array(
       0 => 'article',
       1 => 'blog',
     ),
@@ -75,7 +75,7 @@ function hook_flag_default_flags() {
     'unflag_denied_text' => '',
     'link_type' => 'toggle',
     'weight' => 0,
-    'show_in_links' => array (
+    'show_in_links' => array(
       'full' => TRUE,
       'token' => FALSE,
     ),
@@ -183,7 +183,7 @@ function hook_flag_validate($action, $flag, $entity_id, $account, $skip_permissi
       $count = count($flags[$flag->name]);
       if ($count >= 2) {
         // Users may flag only 2 nodes with this flag.
-        return(array('access-denied' => t('You may only flag 2 nodes with the test flag.')));
+        return (array('access-denied' => t('You may only flag 2 nodes with the test flag.')));
       }
     }
   }
diff --git a/flag.module b/flag.module
index c0bd920..beb0c90 100644
--- a/flag.module
+++ b/flag.module
@@ -1365,7 +1365,7 @@ function flag_flag_trigger($action, $flag, $entity_id, $account, $flagging) {
   $object = $flag->fetch_entity($entity_id);
 
   // Generic "all flags" actions.
-  foreach (trigger_get_assigned_actions('flag_' . $action)  as $aid => $action_info) {
+  foreach (trigger_get_assigned_actions('flag_' . $action) as $aid => $action_info) {
     // The 'if ($aid)' is a safeguard against
     // http://drupal.org/node/271460#comment-886564
     if ($aid) {
@@ -1733,7 +1733,7 @@ function flag_get_entity_flag_counts($flag, $entity_type) {
       ->countQuery()
       ->execute()
       ->fetchField();
-    $counts[$flag->name][$entity_type] =  $result;
+    $counts[$flag->name][$entity_type] = $result;
   }
 
   return $counts[$flag->name][$entity_type];
@@ -2270,7 +2270,7 @@ function flag_trim_flag($flag, $account, $cutoff_size, $trim_newest, $permission
     $query->orderBy('timestamp', 'ASC');
   }
   else {
-    $query->orderBy('timestamp', 'DESC') ;
+    $query->orderBy('timestamp', 'DESC');
   }
 
   // Execute the query
@@ -2309,7 +2309,7 @@ function flag_reset_flag($flag, $entity_id = NULL) {
   }
   module_invoke_all('flag_reset', $flag, $entity_id, $rows);
 
-  $query = db_delete('flagging')->condition('fid' , $flag->fid);
+  $query = db_delete('flagging')->condition('fid', $flag->fid);
   // Update the flag_counts table.
   $count_query = db_delete('flag_counts')->condition('fid', $flag->fid);
   if ($entity_id) {
@@ -2628,6 +2628,6 @@ function flag_properties_get_flagging_users($entity, array $options, $name, $ent
  * @ingroup callbacks
  */
 function flag_properties_get_user_sid($entity, array $options, $name, $entity_type, $property_info) {
-  $sid =  flag_get_sid($entity->uid, FALSE);
+  $sid = flag_get_sid($entity->uid, FALSE);
   return $sid;
 }
diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
index 7759cf2..3ed0e26 100644
--- a/includes/flag.admin.inc
+++ b/includes/flag.admin.inc
@@ -77,10 +77,10 @@ function theme_flag_admin_listing($variables) {
 
   foreach ($flags as $flag) {
     $ops = array(
-      'flags_edit' =>  array('title' => t('edit'), 'href' => $flag->admin_path('edit')),
-      'flags_fields' =>  array('title' => t('manage fields'), 'href' => $flag->admin_path('fields')),
-      'flags_delete' =>  array('title' => t('delete'), 'href' => $flag->admin_path('delete')),
-      'flags_export' =>  array('title' => t('export'), 'href' => $flag->admin_path('export')),
+      'flags_edit' => array('title' => t('edit'), 'href' => $flag->admin_path('edit')),
+      'flags_fields' => array('title' => t('manage fields'), 'href' => $flag->admin_path('fields')),
+      'flags_delete' => array('title' => t('delete'), 'href' => $flag->admin_path('delete')),
+      'flags_export' => array('title' => t('export'), 'href' => $flag->admin_path('export')),
     );
     if (!module_exists('field_ui')) {
       unset($ops['flags_fields']);
diff --git a/plugins/access/flag_is_flagged/flag_is_flagged.inc b/plugins/access/flag_is_flagged/flag_is_flagged.inc
index 720e612..42243ce 100644
--- a/plugins/access/flag_is_flagged/flag_is_flagged.inc
+++ b/plugins/access/flag_is_flagged/flag_is_flagged.inc
@@ -31,7 +31,7 @@ function flag_flag_is_flagged_access_get_children($plugin, $parent) {
 
   foreach ($entities as $entity_type => $info) {
     if (entity_type_supports($entity_type, 'view')) {
-      $plugin['title'] =  t('@entity_type is flagged', array('@entity_type' => $info['label']));
+      $plugin['title'] = t('@entity_type is flagged', array('@entity_type' => $info['label']));
       $plugin['keyword'] = $entity_type;
       $plugin['name'] = $parent . ':' . $entity_type;
       $plugin['required context'] = new ctools_context_required(t('Entity'), $entity_type);
diff --git a/tests/flag_hook_test/flag_hook_test.module b/tests/flag_hook_test/flag_hook_test.module
index 688f801..732af51 100644
--- a/tests/flag_hook_test/flag_hook_test.module
+++ b/tests/flag_hook_test/flag_hook_test.module
@@ -106,11 +106,11 @@ function flag_hook_test_entity_delete($entity, $type) {
  */
 function flag_hook_test_flag_default_flags() {
   $flags = array();
-  $flags['flag_hook_test_flag'] = array (
+  $flags['flag_hook_test_flag'] = array(
     'entity_type' => 'node',
     'title' => 'Test Flag',
     'global' => FALSE,
-    'types' => array (
+    'types' => array(
       0 => 'article',
     ),
     'flag_short' => 'Flag this',
@@ -122,7 +122,7 @@ function flag_hook_test_flag_default_flags() {
     'unflag_denied_text' => 'You may not unflag this item',
     'link_type' => 'normal',
     'weight' => 0,
-    'show_in_links' => array (
+    'show_in_links' => array(
       'full' => TRUE,
       'teaser' => TRUE,
     ),
-- 
1.8.4


From 74394bbe0ff6f22f1480ee9977d10c33ea1c1c77 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 22:26:16 +0100
Subject: [PATCH 09/13] Fixed typos in comments.

---
 flag.module                                                   | 2 +-
 includes/views/flag_plugin_argument_validate_flaggability.inc | 2 +-
 plugins/access/flag_is_flagged/flag_is_flagged.inc            | 2 +-
 tests/flag.test                                               | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flag.module b/flag.module
index beb0c90..8bcfb8b 100644
--- a/flag.module
+++ b/flag.module
@@ -2273,7 +2273,7 @@ function flag_trim_flag($flag, $account, $cutoff_size, $trim_newest, $permission
     $query->orderBy('timestamp', 'DESC');
   }
 
-  // Execute the query
+  // Execute the query.
   $result = $query->execute();
 
   $i = 1;
diff --git a/includes/views/flag_plugin_argument_validate_flaggability.inc b/includes/views/flag_plugin_argument_validate_flaggability.inc
index 91cff39..607931b 100644
--- a/includes/views/flag_plugin_argument_validate_flaggability.inc
+++ b/includes/views/flag_plugin_argument_validate_flaggability.inc
@@ -208,7 +208,7 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   function test_flagged_by_current_user($ids, $flag) {
     global $user;
     if (!$user->uid) {
-      // Anonymous user
+      // Anonymous user.
       return array();
     }
     $flattened_ids = implode(',', $ids);
diff --git a/plugins/access/flag_is_flagged/flag_is_flagged.inc b/plugins/access/flag_is_flagged/flag_is_flagged.inc
index 42243ce..0f6e043 100644
--- a/plugins/access/flag_is_flagged/flag_is_flagged.inc
+++ b/plugins/access/flag_is_flagged/flag_is_flagged.inc
@@ -103,7 +103,7 @@ function flag_flag_is_flagged_access_check($conf, $context) {
 }
 
 /**
- * Provide a summary description based upon the specified context
+ * Provide a summary description based upon the specified context.
  */
 function flag_flag_is_flagged_access_summary($conf, $context) {
   $flag = flag_get_flag($conf['flag_name']);
diff --git a/tests/flag.test b/tests/flag.test
index eb001e6..0f21865 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -235,7 +235,7 @@ class FlagAdminTestCase extends FlagTestCaseBase {
   function setUp() {
     parent::setUp('flag');
 
-    // Create and login user
+    // Create and login user.
     $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer flags'));
     $this->drupalLogin($admin_user);
   }
@@ -451,7 +451,7 @@ class FlagAccessFormTestCase extends FlagTestCaseBase {
 
     $this->drupalGet('node/add/article');
 
-    // Check that the flag form element cannot be seen
+    // Check that the flag form element cannot be seen.
     $this->assertNoText('Flag this item', t('Flag form element was not found.'));
 
     // Have the user create a node.
-- 
1.8.4


From fd6e3bacca84a7b85eda0e88cddddebfb825eadf Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:54:15 +0100
Subject: [PATCH 10/13] Fixed formatting errors in documentation.

---
 flag.info.inc                                                 |  3 ++-
 flag_actions.module                                           |  1 -
 includes/flag.cookie_storage.inc                              |  2 +-
 includes/flag/flag_comment.inc                                |  2 +-
 includes/flag/flag_entity.inc                                 |  2 +-
 includes/flag/flag_flag.inc                                   | 11 ++++++-----
 includes/flag/flag_node.inc                                   |  3 ++-
 includes/flag/flag_user.inc                                   |  2 +-
 includes/views/flag_handler_sort_flagged.inc                  |  3 ++-
 includes/views/flag_plugin_argument_validate_flaggability.inc | 10 ++++++----
 10 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/flag.info.inc b/flag.info.inc
index 69bbb5c..890e624 100644
--- a/flag.info.inc
+++ b/flag.info.inc
@@ -1,7 +1,8 @@
 <?php
 
 /**
- * @file Contains Entity API property information.
+ * @file
+ * Contains Entity API property information.
  */
 
 /**
diff --git a/flag_actions.module b/flag_actions.module
index 6ab5222..4870e61 100644
--- a/flag_actions.module
+++ b/flag_actions.module
@@ -397,7 +397,6 @@ function theme_flag_actions_add_form($variables) {
  *   If editing an action, an action ID must be passed in.
  * @param $flag_name
  *   If adding a new action to a flag, a flag name must be specified.
- *
  */
 function flag_actions_form($form, &$form_state, $aid = NULL, $flag_name = NULL) {
   // This is a multistep form. Get the callback value if set and continue.
diff --git a/includes/flag.cookie_storage.inc b/includes/flag.cookie_storage.inc
index 856f582..07a3dfe 100644
--- a/includes/flag.cookie_storage.inc
+++ b/includes/flag.cookie_storage.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the FlagCookieStorage class.
+ * Contains the FlagCookieStorage class.
  */
 
 /**
diff --git a/includes/flag/flag_comment.inc b/includes/flag/flag_comment.inc
index 58b15fc..7056023 100644
--- a/includes/flag/flag_comment.inc
+++ b/includes/flag/flag_comment.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_comment class.
+ * Contains the flag_comment class.
  */
 
 /**
diff --git a/includes/flag/flag_entity.inc b/includes/flag/flag_entity.inc
index e1ded1f..db3029b 100644
--- a/includes/flag/flag_entity.inc
+++ b/includes/flag/flag_entity.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_entity class.
+ * Contains the flag_entity class.
  */
 
 /**
diff --git a/includes/flag/flag_flag.inc b/includes/flag/flag_flag.inc
index 10a610f..4ecc347 100644
--- a/includes/flag/flag_flag.inc
+++ b/includes/flag/flag_flag.inc
@@ -2,9 +2,9 @@
 
 /**
  * @file
- *  Contains the flag_flag class.
- *  Flag type classes use an object oriented style inspired by that
- *  of Views 2.
+ * Contains the flag_flag class.
+ * Flag type classes use an object oriented style inspired by that
+ * of Views 2.
  */
 
 /**
@@ -1048,7 +1048,7 @@ class flag_flag {
    *   The amount of counts to increasing. Defaults to 1.
    *
    * @private
-  */
+   */
   function _increase_count($entity_id, $number = 1) {
     db_merge('flag_counts')
       ->key(array(
@@ -1081,7 +1081,7 @@ class flag_flag {
    *   The amount of counts to decrease. Defaults to 1.
    *
    * @private
-  */
+   */
   function _decrease_count($entity_id, $number = 1) {
     // Delete rows with count 0, for data consistency and space-saving.
     // Done before the db_update() to prevent out-of-bounds errors on "count".
@@ -1169,6 +1169,7 @@ class flag_flag {
    * @param $entity_id
    *   The ID in whose context to interpret tokens. If not given, only global
    *   tokens will be substituted.
+   *
    * @return
    *   The processed label.
    */
diff --git a/includes/flag/flag_node.inc b/includes/flag/flag_node.inc
index 0b04d02..005c756 100644
--- a/includes/flag/flag_node.inc
+++ b/includes/flag/flag_node.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_node class.
+ * Contains the flag_node class.
  */
 
 /**
@@ -89,6 +89,7 @@ class flag_node extends flag_entity {
    *
    * @param $entity_id
    *   The nid for the content.
+   *
    * @return
    *   The tnid if available, the nid otherwise.
    */
diff --git a/includes/flag/flag_user.inc b/includes/flag/flag_user.inc
index 72dc201..7ebbe6f 100644
--- a/includes/flag/flag_user.inc
+++ b/includes/flag/flag_user.inc
@@ -2,7 +2,7 @@
 
 /**
  * @file
- *   Contains the flag_user class.
+ * Contains the flag_user class.
  */
 
 /**
diff --git a/includes/views/flag_handler_sort_flagged.inc b/includes/views/flag_handler_sort_flagged.inc
index 63c2787..54fdd37 100644
--- a/includes/views/flag_handler_sort_flagged.inc
+++ b/includes/views/flag_handler_sort_flagged.inc
@@ -14,7 +14,8 @@ class flag_handler_sort_flagged extends views_handler_sort {
 
   /**
    * Provide a list of options for the default sort form.
-   * Should be overridden by classes that don't override sort_form
+   *
+   * Should be overridden by classes that don't override sort_form.
    */
   function sort_options() {
     return array(
diff --git a/includes/views/flag_plugin_argument_validate_flaggability.inc b/includes/views/flag_plugin_argument_validate_flaggability.inc
index 607931b..dd2a313 100644
--- a/includes/views/flag_plugin_argument_validate_flaggability.inc
+++ b/includes/views/flag_plugin_argument_validate_flaggability.inc
@@ -66,8 +66,9 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   /**
-   * Returns form #options for the flags. Returns empty array if no flags were
-   * found.
+   * Returns form #options for the flags.
+   *
+   * Returns empty array if no flags were found.
    */
   function flags_options() {
     $flags = flag_get_flags($this->flag_type);
@@ -96,8 +97,9 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
   }
 
   /**
-   * Declares all tests. This scheme makes it easy for derived classes to add
-   * and remove tests.
+   * Declares all tests.
+   *
+   * This scheme makes it easy for derived classes to add and remove tests.
    */
   function tests_info($which = NULL) {
     return array(
-- 
1.8.4


From 73f5b3a0f5be022c8573c0a8fb49b4fb4fe4bc5a Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 21:52:38 +0100
Subject: [PATCH 11/13] Fixed antique PHP code style and semi-deprecated
 functions.

---
 flag.module                                        | 2 +-
 flag_bookmark/flag_bookmark.install                | 2 +-
 includes/flag/flag_flag.inc                        | 2 +-
 includes/views/flag_handler_argument_entity_id.inc | 2 +-
 tests/flag.test                                    | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flag.module b/flag.module
index 8bcfb8b..36079da 100644
--- a/flag.module
+++ b/flag.module
@@ -1566,7 +1566,7 @@ function template_preprocess_flag(&$variables) {
   $flag =& $variables['flag'];
   $action = $variables['action'];
   $entity_id = $variables['entity_id'];
-  $errors = join('<br />', $variables['errors']);
+  $errors = implode('<br />', $variables['errors']);
   $flag_css_name = str_replace('_', '-', $flag->name);
 
   // Generate the link URL.
diff --git a/flag_bookmark/flag_bookmark.install b/flag_bookmark/flag_bookmark.install
index 79f9ed1..378967a 100644
--- a/flag_bookmark/flag_bookmark.install
+++ b/flag_bookmark/flag_bookmark.install
@@ -13,7 +13,7 @@
  */
 function flag_bookmark_enable() {
   // Load the flag API in case we want to use it when enabling.
-  include_once(drupal_get_path('module', 'flag') . '/flag.module');
+  include_once drupal_get_path('module', 'flag') . '/flag.module';
 
   if (!flag_get_flags()) {
     // Install a demonstration flag only if no flag exists. This is to prevent
diff --git a/includes/flag/flag_flag.inc b/includes/flag/flag_flag.inc
index 4ecc347..4931276 100644
--- a/includes/flag/flag_flag.inc
+++ b/includes/flag/flag_flag.inc
@@ -105,7 +105,7 @@ class flag_flag {
    *
    * @var array
    */
-  var $errors = array();
+  public $errors = array();
 
   /**
    * Creates a flag from a database row. Returns it.
diff --git a/includes/views/flag_handler_argument_entity_id.inc b/includes/views/flag_handler_argument_entity_id.inc
index d3e8ab7..21ccf8a 100644
--- a/includes/views/flag_handler_argument_entity_id.inc
+++ b/includes/views/flag_handler_argument_entity_id.inc
@@ -33,7 +33,7 @@ class flag_handler_argument_entity_id extends views_handler_argument_numeric {
     $views_info = $flag->get_views_info();
 
     $titles = array();
-    $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
+    $placeholders = implode(', ', array_fill(0, count($this->value), '%d'));
 
     $result = db_select($views_info['views table'], 'o')
       ->fields('o', array($views_info['title field']))
diff --git a/tests/flag.test b/tests/flag.test
index 0f21865..b1b6000 100644
--- a/tests/flag.test
+++ b/tests/flag.test
@@ -216,7 +216,7 @@ class FlagFlaggingCRUDTestCase extends FlagTestCaseBase {
  * Test Flag admin UI.
  */
 class FlagAdminTestCase extends FlagTestCaseBase {
-  var $_flag = FALSE;
+  public $_flag = FALSE;
 
   /**
    * Implements getInfo().
-- 
1.8.4


From 1442145c97ae81bd0c0564c994530a3d354d1166 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Tue, 22 Apr 2014 22:44:40 +0100
Subject: [PATCH 12/13] Fixed surplus whitespace at end of files.

---
 flag_bookmark/flag_bookmark.install                           | 1 -
 includes/views/flag_handler_relationships.inc                 | 1 -
 includes/views/flag_plugin_argument_validate_flaggability.inc | 1 -
 3 files changed, 3 deletions(-)

diff --git a/flag_bookmark/flag_bookmark.install b/flag_bookmark/flag_bookmark.install
index 378967a..6264612 100644
--- a/flag_bookmark/flag_bookmark.install
+++ b/flag_bookmark/flag_bookmark.install
@@ -65,4 +65,3 @@ function _flag_bookmark_install_get_suggested_node_types() {
   }
   return $existing;
 }
-
diff --git a/includes/views/flag_handler_relationships.inc b/includes/views/flag_handler_relationships.inc
index 9a7c964..0ee05fc 100644
--- a/includes/views/flag_handler_relationships.inc
+++ b/includes/views/flag_handler_relationships.inc
@@ -264,4 +264,3 @@ class flag_handler_relationship_user_content extends flag_handler_relationship {
     parent::query();
   }
 }
-
diff --git a/includes/views/flag_plugin_argument_validate_flaggability.inc b/includes/views/flag_plugin_argument_validate_flaggability.inc
index dd2a313..7cd5269 100644
--- a/includes/views/flag_plugin_argument_validate_flaggability.inc
+++ b/includes/views/flag_plugin_argument_validate_flaggability.inc
@@ -227,4 +227,3 @@ class flag_plugin_argument_validate_flaggability extends views_plugin_argument_v
     return $passed;
   }
 }
-
-- 
1.8.4


From 685f31302a13e64974bf0e826228b5e6a5b06386 Mon Sep 17 00:00:00 2001
From: Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Wed, 23 Apr 2014 22:13:44 +0100
Subject: [PATCH 13/13] Added blank line after each switch() case.

---
 flag.module                           | 2 ++
 flag.tokens.inc                       | 6 ++++++
 includes/views/flag.views_convert.inc | 5 +++++
 3 files changed, 13 insertions(+)

diff --git a/flag.module b/flag.module
index 36079da..3078b4b 100644
--- a/flag.module
+++ b/flag.module
@@ -421,9 +421,11 @@ function flag_help($path, $arg) {
     case FLAG_ADMIN_PATH:
       $output = '<p>' . t('This page lists all the <em>flags</em> that are currently defined on this system.') . '</p>';
       return $output;
+
     case FLAG_ADMIN_PATH . '/add':
       $output = '<p>' . t('Select the type of flag to create. An individual flag can only affect one type of object. This cannot be changed once the flag is created.') . '</p>';
       return $output;
+
     case FLAG_ADMIN_PATH . '/manage/%/fields':
       // Get the existing link types that provide a flagging form.
       $link_types = flag_get_link_types();
diff --git a/flag.tokens.inc b/flag.tokens.inc
index cae4d88..77a06c5 100644
--- a/flag.tokens.inc
+++ b/flag.tokens.inc
@@ -123,6 +123,7 @@ function flag_tokens($type, $tokens, array $data = array(), array $options = arr
         case 'name':
           $replacements[$original] = $sanitize ? check_plain($flag->name) : $flag->name;
           break;
+
         case 'title':
           $replacements[$original] = $sanitize ? check_plain($flag->get_title()) : $flag->get_title();
           break;
@@ -149,18 +150,23 @@ function flag_tokens($type, $tokens, array $data = array(), array $options = arr
         case 'action':
           $replacements[$original] = $action->action;
           break;
+
         case 'entity-url':
           $replacements[$original] = $sanitize ? check_url($action->entity_url) : $action->entity_url;
           break;
+
         case 'entity-title':
           $replacements[$original] = $sanitize ? check_plain($action->entity_title) : $action->entity_title;
           break;
+
         case 'entity-type':
           $replacements[$original] = $action->entity_type;
           break;
+
         case 'entity-id':
           $replacements[$original] = $action->entity_id;
           break;
+
         case 'count':
           $replacements[$original] = $action->count;
           break;
diff --git a/includes/views/flag.views_convert.inc b/includes/views/flag.views_convert.inc
index ed8910d..206d5ca 100644
--- a/includes/views/flag.views_convert.inc
+++ b/includes/views/flag.views_convert.inc
@@ -57,6 +57,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           $new_rel = 'flag_content_rel';
           $flag_content_rel_user = 'current';
           break;
+
         case 'count':
           $new_field = array(
             'label' => $field['label'],
@@ -67,6 +68,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           );
           $new_rel = 'flag_counts_rel';
           break;
+
         case 'name':
           $new_field = array(
             'label' => $field['label'],
@@ -95,6 +97,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           // Remove the old filter.
           $view->set_item('default', $type, $id, NULL);
           break;
+
         case 'timestamp':
           $new_field = array(
             'operator' => $field['operator'],
@@ -109,6 +112,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           $new_rel = 'flag_content_rel';
           drupal_set_message(t('Flag is not able to convert the <em>Flagged time</em> filter. It\'s value is currently empty, but needs to be populated to work properly.'), 'warning');
           break;
+
         case 'count':
           $new_field = array(
             'operator' => $field['operator'],
@@ -151,6 +155,7 @@ function flag_views_convert($display, $type, &$view, $field, $id) {
           );
           $new_rel = 'flag_counts_rel';
           break;
+
         case 'timestamp':
           $new_field = array(
             'order' => $field['sortorder'],
-- 
1.8.4

