From 49203dbee1979afe6b466f626682c5e81575bd30 Mon Sep 17 00:00:00 2001 From: Filippo Fadda Date: Fri, 24 Apr 2015 20:17:27 +0200 Subject: [PATCH] fixed doc in javadoc style --- src/Converter/BBCodeConverter.php | 65 ++++++++++++++++++++++--------- src/Converter/Converter.php | 29 ++++++++------ src/Converter/HTMLConverter.php | 44 ++++++++++++++------- 3 files changed, 94 insertions(+), 44 deletions(-) diff --git a/src/Converter/BBCodeConverter.php b/src/Converter/BBCodeConverter.php index 2f27121..5df95a5 100644 --- a/src/Converter/BBCodeConverter.php +++ b/src/Converter/BBCodeConverter.php @@ -1,19 +1,24 @@ text = preg_replace_callback('%\[size=\d*\]([\W\D\w\s]*?)\[/size\]%iu', @@ -28,7 +33,9 @@ function ($matches) { } - //! @brief Removes BBCode center. + /** + * @brief Removes BBCode center. + */ protected function removeCenter() { $this->text = preg_replace_callback('%\[center\]([\W\D\w\s]*?)\[/center\]%iu', @@ -43,7 +50,9 @@ function ($matches) { } - //! @brief Replaces BBCode bold. + /** + * @brief Replaces BBCode bold. + */ protected function replaceBold() { $this->text = preg_replace_callback('%\[b\]([\W\D\w\s]*?)\[/b\]%iu', @@ -58,7 +67,9 @@ function ($matches) { } - //! @brief Replaces BBCode italic. + /** + * @brief Replaces BBCode italic. + */ protected function replaceItalic() { $this->text = preg_replace_callback('%\[i\]([\W\D\w\s]*?)\[/i\]%iu', @@ -73,7 +84,9 @@ function ($matches) { } - //! @brief Replaces BBCode underline. Hoedown support underline. + /** + * @brief Replaces BBCode underline. Hoedown support underline. + */ protected function replaceUnderline() { $this->text = preg_replace_callback('%\[u\]([\W\D\w\s]*?)\[/u\]%iu', @@ -88,7 +101,9 @@ function ($matches) { } - //! @brief Replaces BBCode strikethrough. + /** + * @brief Replaces BBCode strikethrough. + */ protected function replaceStrikethrough() { $this->text = preg_replace_callback('%\[s\]([\W\D\w\s]*?)\[/s\]%iu', @@ -103,7 +118,9 @@ function ($matches) { } - //! @brief Replaces BBCode lists. + /** + * @brief Replaces BBCode lists. + */ protected function replaceLists() { $this->text = preg_replace_callback('%\[list(?P=1)?\](?P[\W\D\w\s]*?)\[/list\]%iu', @@ -145,7 +162,9 @@ function ($matches) { } - //! @brief Replaces BBCode urls. + /** + * @brief Replaces BBCode urls. + */ protected function replaceUrls() { $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', @@ -163,7 +182,9 @@ function ($matches) { } - //! @brief Replaces BBCode images. + /** + * @brief Replaces BBCode images. + */ protected function replaceImages() { $this->text = preg_replace_callback('%\[img\s*\]\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\[/img\]%iu', @@ -181,8 +202,10 @@ function ($matches) { } - //! @brief Replaces BBCode quotes. - //! @details Thanks to Casimir et Hippolyte for helping me with this regex. + /** + * @brief Replaces BBCode quotes. + * @details Thanks to Casimir et Hippolyte for helping me with this regex. + */ protected function replaceQuotes() { // Removes the inner quotes, leaving just one level. $this->text = preg_replace('~\G(?(\[quote\b[^]]*](?>[^[]++|\[(?!/?quote)|(?1))*\[/quote])|(?[^[]++|\[(?!/?quote))+\K)|\[quote\b[^]]*]\K~', '', $this->text); @@ -200,7 +223,9 @@ function($matches) { } - //! @brief Replaces BBCode snippets. + /** + * @brief Replaces BBCode snippets. + */ protected function replaceSnippets() { $this->text = preg_replace_callback('%\[code\s*=?(?P\w*)\](?P[\W\D\w\s]*?)\[\/code\]%iu', @@ -246,7 +271,9 @@ function ($matches) { } - //! @brief Converts the provided BBCode text to an equivalent Markdown text. + /** + * @brief Converts the provided BBCode text to an equivalent Markdown text. + */ public function toMarkdown() { $this->removeCenter(); $this->removeSize(); diff --git a/src/Converter/Converter.php b/src/Converter/Converter.php index c5a409e..37186cf 100644 --- a/src/Converter/Converter.php +++ b/src/Converter/Converter.php @@ -1,24 +1,31 @@ text = $text; $this->id = (string)$id; diff --git a/src/Converter/HTMLConverter.php b/src/Converter/HTMLConverter.php index 992d5de..785a551 100644 --- a/src/Converter/HTMLConverter.php +++ b/src/Converter/HTMLConverter.php @@ -1,22 +1,28 @@ , , or [code][/code] - // if you are using BBCode markup language. + /** + * @brief Finds all code snippets inside the body, replacing them with appropriate markers. + * @details The code can be inside `
`, ``, or `[code][/code]` in case you are using BBCode
+   * markup language.
+   */
   protected function removeSnippets() {
     $pattern = '%(?P
)(?P[\W\D\w\s]*?)(?P
)|(?P)(?P[\W\D\w\s]*?)(?P)|(?P\[code=?\w*\])(?P[\W\D\w\s]*?)(?P\[/code\])%iu'; @@ -30,7 +36,9 @@ protected function removeSnippets() { } - //! @brief Restores the snippets, converting the HTML tags to BBCode tags. + /** + * @brief Restores the snippets, converting the HTML tags to BBCode tags. + */ protected function restoreSnippets() { $snippetsCount = count($this->snippets[0]); @@ -48,7 +56,9 @@ protected function restoreSnippets() { } - //! @brief Replace links. + /** + * @brief Replace links. + */ protected function replaceLinks() { $this->text = preg_replace_callback('%]+>(.+?)%iu', @@ -78,7 +88,9 @@ function ($matches) { } - //! @brief Replace images. + /** + * @brief Replace images. + */ protected function replaceImages() { $this->text = preg_replace_callback('/]+>/iu', @@ -100,7 +112,9 @@ function ($matches) { } - //! @brief Replace all other simple tags, even the lists. + /** + * @brief Replace all other simple tags, even the lists. + */ protected function replaceOtherTags() { $this->text = preg_replace_callback('%]*>%iu', @@ -183,7 +197,9 @@ function ($matches) { } - //! @brief Converts the provided HTML text into BBCode. + /** + * @brief Converts the provided HTML text into BBCode. + */ public function toBBCode() { // We don't want any HTML entities. $this->text = htmlspecialchars_decode($this->text);