Check if we can read a comment.

@param  object  $comment Comment object.
@return boolean Can we read it?
355996
protected function check_read_permission( $comment ) {
		if ( ! empty( $comment->comment_post_ID ) ) {
			$post = get_post( $comment->comment_post_ID );
			if ( $post ) {
				if ( $this->check_read_post_permission( $post ) && 1 === (int) $comment->comment_approved ) {
					return true;
				}
			}
		}

		if ( 0 === get_current_user_id() ) {
			return false;
		}

		if ( empty( $comment->comment_post_ID ) && ! current_user_can( 'moderate_comments' ) ) {
			return false;
		}

		if ( ! empty( $comment->user_id ) && get_current_user_id() === (int) $comment->user_id ) {
			return true;
		}

		return current_user_can( 'edit_comment', $comment->comment_ID );
	}
793898
public function comment(string $comment = ''): Writer
    {
        $comment = trim($comment);

        if (!empty($comment)) {
            $comment = ' ' . $comment;
        }

        return $this->line(trim('#' . $comment));
    }
95084
protected function isTypeComment($commentText)
    {
        return strpos($commentText, self::TYPE_TAG) !== false || strpos($commentText, '@type') !== false;
    }
401150
protected function isCommentEnd() {
        // EOF
        if ($this->scanner->current() === false) {
            // Hit the end.
            $this->parseError("Unexpected EOF in a comment.");
            return true;
        }

        // If it doesn't start with -, not the end.
        if ($this->scanner->current() != '-') {
            return false;
        }

        // Advance one, and test for '->'
        if ($this->scanner->next() == '-' && $this->scanner->peek() == '>') {
            $this->scanner->next(); // Consume the last '>'
            return true;
        }
        // Unread '-';
        $this->scanner->unconsume(1);
        return false;
    }
1279462
public function addComment($comment)
    {
        $comment->setPaymentId($this->getPaymentId());
        $comment->save();

        $this->load($this->getPaymentId());

        return $comment;
    }
788390
public function setSubscriptionComment($comment)
    {
        if (strlen($comment) > 200) {
            throw new InvalidArgumentException("Subscription comment cannot be longer than 200 characters");
        }
        if (preg_match('/[^a-zA-Z0-9_ -]/', $comment)) {
            throw new InvalidArgumentException("Subscription comment cannot contain special characters");
        }
        $this->parameters['sub_comment'] = $comment;
    }
1074207
public function update(Comment &$comment)
    {
        $data = $comment->exportData();
        $endpoint = '/admin/comments/'.$comment->id.'.json';
        $response = $this->request(
            $endpoint, 'PUT', array(
            'comment' => $data
            )
        );
        $comment->setData($response['comment']);
    }
758009
public function getComment(int $commentId)
    {
        if ( ! $this->validateId($commentId)) {
            return false;
        }

        $result = $this->get('comments/' . $commentId);

        if (200 === $result->getStatusCode()) {
            return json_decode($result->getBody()->getContents());
        }

        return false;
    }
611179
public function updateComment(int $commentId, string $content): bool
    {
        if ('' === $content || ! $this->validateId($commentId)) {
            return false;
        }

        $data   = $this->prepareRequestData(['content' => $content]);
        $result = $this->post('comments/' . $commentId, $data);

        return 204 === $result->getStatusCode();
    }
414424
public function comment($comment = null) {
		if ($comment) {
			$this->_config['comment'] = $comment;
			return $this;
		}
		return $this->_config['comment'];
	}
517927
protected function _inResponseTo(Comment $comment)
    {
        $this->loadModel('Content.Contents');
        $this->Contents->fieldable(false);
        $content = $this->Contents->get($comment->entity_id);

        if ($content) {
            $out = __d('content', '<a href="{0}" target="_blank">{1}</a>', Router::url(['plugin' => 'Content', 'controller' => 'manage', 'action' => 'edit', $content->id]), $content->title);
            $out .= '<br />';
            $out .= __d('content', '<a href="{0}" target="_blank">{1}</a>', Router::url($content->url), 'View content');

            return $out;
        }

        return __d('content', '-- Unknow --');
    }
1136606
private static boolean isTargetComment(final String comment) {
		return comment != null
				&& comment.length() > 0
				&& (Character.isJavaIdentifierStart(comment.charAt(0)) || '#' == comment.charAt(0) || '(' == comment
						.charAt(0));
	}
38519
public static function create($comment) {
    $block_comment = new LineCommentBlockNode();
    $comment = trim($comment);
    $lines = array_map('rtrim', explode("\n", $comment));
    foreach ($lines as $line) {
      $comment_node = new CommentNode(T_COMMENT, '// ' . $line . "\n");
      $block_comment->addChild($comment_node);
    }
    return $block_comment;
  }
454567
public static function isKssBlock($comment)
    {
        $commentLines = explode("\n\n", $comment);
        $lastLine = end($commentLines);
        return preg_match('/^\s*Styleguide \w/i', $lastLine) ||
            preg_match('/^\s*No styleguide reference/i', $lastLine);
    }
739664
protected function cleanInput($comment)
    {
        $comment = trim(
            preg_replace(
                '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
                '$1',
                $comment
            )
        );

        // reg ex above is not able to remove */ from a single line docblock
        if (substr($comment, -2) == '*/') {
            $comment = trim(substr($comment, 0, -2));
        }

        // normalize strings
        $comment = str_replace(array("\r\n", "\r"), "\n", $comment);

        return $comment;
    }
639518
protected function scanComment()
    {
        if (preg_match('/^ *\/\/(-)?([^\n]*)/', $this->input, $matches)) {
            $this->consume($matches[0]);
            $token         = $this->token('comment', isset($matches[2]) ? $matches[2] : '');
            $token->buffer = '-' !== $matches[1];

            return $token;
        }
    }
358440
protected function convertAndReturn($comments)
    {
        // Create the return value
        $retval = false;
        if ($comments && is_array($comments) && count($comments)) {
            // Create the array
            $retval = array();
            foreach ($comments as $theComment) {
                // Create a new instance
                $commentInstance = new $this->className($theComment);
                // Append the instance to the return value
                array_push($retval, $commentInstance);
            }
        }
        return $retval;
    }