@@ -18,7 +18,7 @@ class Markdown implements MarkdownInterface {
1818 * Define the package version
1919 * @var string
2020 */
21- const MARKDOWNLIB_VERSION = "1.8.0 " ;
21+ const MARKDOWNLIB_VERSION = "1.8.1 " ;
2222
2323 /**
2424 * Simple function interface - Initialize the parser and return the result
@@ -85,25 +85,25 @@ public static function defaultTransform($text) {
8585
8686 /**
8787 * Optional filter function for URLs
88- * @var callable
88+ * @var callable|null
8989 */
9090 public $ url_filter_func = null ;
9191
9292 /**
9393 * Optional header id="" generation callback function.
94- * @var callable
94+ * @var callable|null
9595 */
9696 public $ header_id_func = null ;
9797
9898 /**
9999 * Optional function for converting code block content to HTML
100- * @var callable
100+ * @var callable|null
101101 */
102102 public $ code_block_content_func = null ;
103103
104104 /**
105105 * Optional function for converting code span content to HTML.
106- * @var callable
106+ * @var callable|null
107107 */
108108 public $ code_span_content_func = null ;
109109
@@ -767,16 +767,15 @@ protected function _doAnchors_reference_callback($matches) {
767767 * @return string
768768 */
769769 protected function _doAnchors_inline_callback ($ matches ) {
770- $ whole_match = $ matches [1 ];
771770 $ link_text = $ this ->runSpanGamut ($ matches [2 ]);
772- $ url = $ matches [3 ] == '' ? $ matches [4 ] : $ matches [3 ];
771+ $ url = $ matches [3 ] === '' ? $ matches [4 ] : $ matches [3 ];
773772 $ title =& $ matches [7 ];
774773
775774 // If the URL was of the form <s p a c e s> it got caught by the HTML
776775 // tag parser and hashed. Need to reverse the process before using
777776 // the URL.
778777 $ unhashed = $ this ->unhash ($ url );
779- if ($ unhashed != $ url )
778+ if ($ unhashed !== $ url )
780779 $ url = preg_replace ('/^<(.*)>$/ ' , '\1 ' , $ unhashed );
781780
782781 $ url = $ this ->encodeURLAttribute ($ url );
@@ -952,7 +951,7 @@ protected function _doHeaders_callback_setext($matches) {
952951 return $ matches [0 ];
953952 }
954953
955- $ level = $ matches [2 ]{ 0 } == '= ' ? 1 : 2 ;
954+ $ level = $ matches [2 ][ 0 ] == '= ' ? 1 : 2 ;
956955
957956 // ID attribute generation
958957 $ idAtt = $ this ->_generateIdFromHeaderValue ($ matches [1 ]);
@@ -1218,7 +1217,7 @@ protected function _doCodeBlocks_callback($matches) {
12181217 $ codeblock = $ matches [1 ];
12191218
12201219 $ codeblock = $ this ->outdent ($ codeblock );
1221- if ($ this ->code_block_content_func ) {
1220+ if (is_callable ( $ this ->code_block_content_func ) ) {
12221221 $ codeblock = call_user_func ($ this ->code_block_content_func , $ codeblock , "" );
12231222 } else {
12241223 $ codeblock = htmlspecialchars ($ codeblock , ENT_NOQUOTES );
@@ -1237,7 +1236,7 @@ protected function _doCodeBlocks_callback($matches) {
12371236 * @return string
12381237 */
12391238 protected function makeCodeSpan ($ code ) {
1240- if ($ this ->code_span_content_func ) {
1239+ if (is_callable ( $ this ->code_span_content_func ) ) {
12411240 $ code = call_user_func ($ this ->code_span_content_func , $ code );
12421241 } else {
12431242 $ code = htmlspecialchars (trim ($ code ), ENT_NOQUOTES );
@@ -1358,7 +1357,7 @@ protected function doItalicsAndBold($text) {
13581357 } else {
13591358 // Other closing marker: close one em or strong and
13601359 // change current token state to match the other
1361- $ token_stack [0 ] = str_repeat ($ token{ 0 } , 3 -$ token_len );
1360+ $ token_stack [0 ] = str_repeat ($ token[ 0 ] , 3 -$ token_len );
13621361 $ tag = $ token_len == 2 ? "strong " : "em " ;
13631362 $ span = $ text_stack [0 ];
13641363 $ span = $ this ->runSpanGamut ($ span );
@@ -1383,7 +1382,7 @@ protected function doItalicsAndBold($text) {
13831382 } else {
13841383 // Reached opening three-char emphasis marker. Push on token
13851384 // stack; will be handled by the special condition above.
1386- $ em = $ token{ 0 } ;
1385+ $ em = $ token[ 0 ] ;
13871386 $ strong = "$ em$ em " ;
13881387 array_unshift ($ token_stack , $ token );
13891388 array_unshift ($ text_stack , '' );
@@ -1576,11 +1575,11 @@ protected function encodeAttribute($text) {
15761575 * This function is *not* suitable for attributes enclosed in single quotes.
15771576 *
15781577 * @param string $url
1579- * @param string & $text Passed by reference
1578+ * @param string $text Passed by reference
15801579 * @return string URL
15811580 */
15821581 protected function encodeURLAttribute ($ url , &$ text = null ) {
1583- if ($ this ->url_filter_func ) {
1582+ if (is_callable ( $ this ->url_filter_func ) ) {
15841583 $ url = call_user_func ($ this ->url_filter_func , $ url );
15851584 }
15861585
@@ -1694,7 +1693,7 @@ protected function _doAutoLinks_email_callback($matches) {
16941693 * attribute special characters by Allan Odgaard.
16951694 *
16961695 * @param string $text
1697- * @param string & $tail
1696+ * @param string $tail Passed by reference
16981697 * @param integer $head_length
16991698 * @return string
17001699 */
@@ -1792,13 +1791,13 @@ protected function parseSpan($str) {
17921791 * Handle $token provided by parseSpan by determining its nature and
17931792 * returning the corresponding value that should replace it.
17941793 * @param string $token
1795- * @param string & $str
1794+ * @param string $str Passed by reference
17961795 * @return string
17971796 */
17981797 protected function handleSpanToken ($ token , &$ str ) {
1799- switch ($ token{ 0 } ) {
1798+ switch ($ token[ 0 ] ) {
18001799 case "\\" :
1801- return $ this ->hashPart ("&# " . ord ($ token{ 1 } ). "; " );
1800+ return $ this ->hashPart ("&# " . ord ($ token[ 1 ] ). "; " );
18021801 case "` " :
18031802 // Search for end marker in remaining text.
18041803 if (preg_match ('/^(.*?[^`]) ' .preg_quote ($ token ).'(?!`)(.*)$/sm ' ,
0 commit comments