original_string: public function update_discussion(discussion_entity $discussion) : ?discussion_entity {
          $discussionrecord = $this->get_legacy_factory()->to_legacy_object($discussion);
          if ($this->get_db()->update_record('forum_discussions', $discussionrecord)) {
              $records = $this->transform_db_records_to_entities([$discussionrecord]);
  
              return count($records) ? array_shift($records) : null;
          }
  
          return null;
      }
code: public function update_discussion(discussion_entity $discussion) : ?discussion_entity {
          $discussionrecord = $this->get_legacy_factory()->to_legacy_object($discussion);
          if ($this->get_db()->update_record('forum_discussions', $discussionrecord)) {
              $records = $this->transform_db_records_to_entities([$discussionrecord]);
  
              return count($records) ? array_shift($records) : null;
          }
  
          return null;
      }
code_tokens: public function update_discussion ( discussion_entity $ discussion ) : ? discussion_entity { $ discussionrecord = $ this -> get_legacy_factory ( ) -> to_legacy_object ( $ discussion ) ; if ( $ this -> get_db ( ) -> update_record ( 'forum_discussions' , $ discussionrecord ) ) { $ records = $ this -> transform_db_records_to_entities ( [ $ discussionrecord ] ) ; return count ( $ records ) ? array_shift ( $ records ) : null ; } return null ; }
docstring: Update the discussion
  
  @param discussion_entity $discussion
  @return discussion_entity|null
docstring_tokens: Update the discussion