@@ -1122,6 +1122,10 @@ discard block |
||
1122 | 1122 | |
1123 | 1123 | var $list_level = 0; |
1124 | 1124 | |
1125 | + /** |
|
1126 | + * @param string $list_str |
|
1127 | + * @param string $marker_any_re |
|
1128 | + */ |
|
1125 | 1129 | function processListItems($list_str, $marker_any_re) |
1126 | 1130 | { |
1127 | 1131 | # |
@@ -1234,6 +1238,9 @@ discard block |
||
1234 | 1238 | return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
1235 | 1239 | } |
1236 | 1240 | |
1241 | + /** |
|
1242 | + * @param string $code |
|
1243 | + */ |
|
1237 | 1244 | function makeCodeSpan($code) |
1238 | 1245 | { |
1239 | 1246 | # |
@@ -1751,6 +1758,9 @@ discard block |
||
1751 | 1758 | # hanlde UTF-8 if the default function does not exist. |
1752 | 1759 | var $utf8_strlen = 'mb_strlen'; |
1753 | 1760 | |
1761 | + /** |
|
1762 | + * @param string $text |
|
1763 | + */ |
|
1754 | 1764 | function detab($text) |
1755 | 1765 | { |
1756 | 1766 | # |
@@ -2340,6 +2350,11 @@ discard block |
||
2340 | 2350 | return array($parsed, $text); |
2341 | 2351 | } |
2342 | 2352 | |
2353 | + /** |
|
2354 | + * @param string $text |
|
2355 | + * @param string $hash_method |
|
2356 | + * @param boolean $md_attr |
|
2357 | + */ |
|
2343 | 2358 | function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) |
2344 | 2359 | { |
2345 | 2360 | # |
@@ -3078,6 +3093,9 @@ discard block |
||
3078 | 3093 | return $this->hashBlock($result) . "\n\n"; |
3079 | 3094 | } |
3080 | 3095 | |
3096 | + /** |
|
3097 | + * @return string |
|
3098 | + */ |
|
3081 | 3099 | function processDefListItems($list_str) |
3082 | 3100 | { |
3083 | 3101 | # |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | # |
59 | 59 | # Setup static parser variable. |
60 | 60 | static $parser; |
61 | - if (!isset($parser)) { |
|
61 | + if ( ! isset($parser)) { |
|
62 | 62 | $parser_class = MARKDOWN_PARSER_CLASS; |
63 | 63 | $parser = new $parser_class; |
64 | 64 | } |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | function mdwp_MarkdownPost($text) |
109 | 109 | { |
110 | 110 | static $parser; |
111 | - if (!$parser) { |
|
111 | + if ( ! $parser) { |
|
112 | 112 | $parser_class = MARKDOWN_PARSER_CLASS; |
113 | 113 | $parser = new $parser_class; |
114 | 114 | } |
115 | 115 | if (is_single() || is_page() || is_feed()) { |
116 | 116 | $parser->fn_id_prefix = ""; |
117 | 117 | } else { |
118 | - $parser->fn_id_prefix = get_the_ID() . "."; |
|
118 | + $parser->fn_id_prefix = get_the_ID()."."; |
|
119 | 119 | } |
120 | 120 | return $parser->transform($text); |
121 | 121 | } |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | add_filter('get_comment_excerpt', 'mdwp_strip_p', 7); |
137 | 137 | |
138 | 138 | global $mdwp_hidden_tags, $mdwp_placeholders; |
139 | - $mdwp_hidden_tags = explode( |
|
139 | + $mdwp_hidden_tags = explode( |
|
140 | 140 | ' ', |
141 | 141 | '<p> </p> <pre> </pre> <ol> </ol> <ul> </ul> <li> </li>' |
142 | 142 | ); |
143 | 143 | $mdwp_placeholders = explode( |
144 | 144 | ' ', |
145 | 145 | str_rot13( |
146 | - 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR ' . |
|
146 | + 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR '. |
|
147 | 147 | 'ML5IjmbRol ulANi1NsGY J7zRLJqPul liA8ctl16T K9nhooUHli' |
148 | 148 | ) |
149 | 149 | ); |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | |
152 | 152 | function mdwp_add_p($text) |
153 | 153 | { |
154 | - if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) { |
|
155 | - $text = '<p>' . $text . '</p>'; |
|
154 | + if ( ! preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) { |
|
155 | + $text = '<p>'.$text.'</p>'; |
|
156 | 156 | $text = preg_replace('{\n{2,}}', "</p>\n\n<p>", $text); |
157 | 157 | } |
158 | 158 | return $text; |
@@ -279,14 +279,14 @@ discard block |
||
279 | 279 | $this->prepareItalicsAndBold(); |
280 | 280 | |
281 | 281 | $this->nested_brackets_re = |
282 | - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth) . |
|
282 | + str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). |
|
283 | 283 | str_repeat('\])*', $this->nested_brackets_depth); |
284 | 284 | |
285 | 285 | $this->nested_url_parenthesis_re = |
286 | - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth) . |
|
286 | + str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). |
|
287 | 287 | str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); |
288 | 288 | |
289 | - $this->escape_chars_re = '[' . preg_quote($this->escape_chars) . ']'; |
|
289 | + $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; |
|
290 | 290 | |
291 | 291 | # Sort document, block, and span gamut in ascendent priority order. |
292 | 292 | asort($this->document_gamut); |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | $this->teardown(); |
368 | 368 | |
369 | - return $text . "\n"; |
|
369 | + return $text."\n"; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | var $document_gamut = array( |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | # Link defs are in the form: ^[id]: url "optional title" |
387 | 387 | $text = preg_replace_callback( |
388 | 388 | '{ |
389 | - ^[ ]{0,' . $less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
389 | + ^[ ]{0,' . $less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
390 | 390 | [ ]* |
391 | 391 | \n? # maybe *one* newline |
392 | 392 | [ ]* |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $link_id = strtolower($matches[1]); |
419 | 419 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
420 | 420 | $this->urls[$link_id] = $url; |
421 | - $this->titles[$link_id] =& $matches[4]; |
|
421 | + $this->titles[$link_id] = & $matches[4]; |
|
422 | 422 | return ''; # String that will replace the block |
423 | 423 | } |
424 | 424 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | # * List "b" is made of tags which are always block-level; |
445 | 445 | # |
446 | 446 | $block_tags_a_re = 'ins|del'; |
447 | - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|' . |
|
448 | - 'script|noscript|form|fieldset|iframe|math|svg|' . |
|
449 | - 'article|section|nav|aside|hgroup|header|footer|' . |
|
447 | + $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. |
|
448 | + 'script|noscript|form|fieldset|iframe|math|svg|'. |
|
449 | + 'article|section|nav|aside|hgroup|header|footer|'. |
|
450 | 450 | 'figure'; |
451 | 451 | |
452 | 452 | # Regular expression for the content of a block tag. |
@@ -465,21 +465,21 @@ discard block |
||
465 | 465 | )* |
466 | 466 | )? |
467 | 467 | '; |
468 | - $content = |
|
468 | + $content = |
|
469 | 469 | str_repeat( |
470 | 470 | ' |
471 | 471 | (?> |
472 | 472 | [^<]+ # content without tag |
473 | 473 | | |
474 | 474 | <\2 # nested opening tag |
475 | - ' . $attr . ' # attributes |
|
475 | + ' . $attr.' # attributes |
|
476 | 476 | (?> |
477 | 477 | /> |
478 | 478 | | |
479 | 479 | >', |
480 | 480 | $nested_tags_level |
481 | - ) . # end of opening tag |
|
482 | - '.*?' . # last level nested tag content |
|
481 | + ).# end of opening tag |
|
482 | + '.*?'.# last level nested tag content |
|
483 | 483 | str_repeat( |
484 | 484 | ' |
485 | 485 | </\2\s*> # closing nested tag |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | )*', |
491 | 491 | $nested_tags_level |
492 | 492 | ); |
493 | - $content2 = str_replace('\2', '\3', $content); |
|
493 | + $content2 = str_replace('\2', '\3', $content); |
|
494 | 494 | |
495 | 495 | # First, look for nested blocks, e.g.: |
496 | 496 | # <div> |
@@ -515,20 +515,20 @@ discard block |
||
515 | 515 | # Match from `\n<tag>` to `</tag>\n`, handling nested tags |
516 | 516 | # in between. |
517 | 517 | |
518 | - [ ]{0,' . $less_than_tab . '} |
|
519 | - <(' . $block_tags_b_re . ')# start tag = $2 |
|
520 | - ' . $attr . '> # attributes followed by > and \n |
|
521 | - ' . $content . ' # content, support nesting |
|
518 | + [ ]{0,' . $less_than_tab.'} |
|
519 | + <(' . $block_tags_b_re.')# start tag = $2 |
|
520 | + ' . $attr.'> # attributes followed by > and \n |
|
521 | + ' . $content.' # content, support nesting |
|
522 | 522 | </\2> # the matching end tag |
523 | 523 | [ ]* # trailing spaces/tabs |
524 | 524 | (?=\n+|\Z) # followed by a newline or end of document |
525 | 525 | |
526 | 526 | | # Special version for tags of group a. |
527 | 527 | |
528 | - [ ]{0,' . $less_than_tab . '} |
|
529 | - <(' . $block_tags_a_re . ')# start tag = $3 |
|
530 | - ' . $attr . '>[ ]*\n # attributes followed by > |
|
531 | - ' . $content2 . ' # content, support nesting |
|
528 | + [ ]{0,' . $less_than_tab.'} |
|
529 | + <(' . $block_tags_a_re.')# start tag = $3 |
|
530 | + ' . $attr.'>[ ]*\n # attributes followed by > |
|
531 | + ' . $content2.' # content, support nesting |
|
532 | 532 | </\3> # the matching end tag |
533 | 533 | [ ]* # trailing spaces/tabs |
534 | 534 | (?=\n+|\Z) # followed by a newline or end of document |
@@ -536,16 +536,16 @@ discard block |
||
536 | 536 | | # Special case just for <hr />. It was easier to make a special |
537 | 537 | # case than to make the other regex more complicated. |
538 | 538 | |
539 | - [ ]{0,' . $less_than_tab . '} |
|
539 | + [ ]{0,' . $less_than_tab.'} |
|
540 | 540 | <(hr) # start tag = $2 |
541 | - ' . $attr . ' # attributes |
|
541 | + ' . $attr.' # attributes |
|
542 | 542 | /?> # the matching end tag |
543 | 543 | [ ]* |
544 | 544 | (?=\n{2,}|\Z) # followed by a blank line or end of document |
545 | 545 | |
546 | 546 | | # Special case for standalone HTML comments: |
547 | 547 | |
548 | - [ ]{0,' . $less_than_tab . '} |
|
548 | + [ ]{0,' . $less_than_tab.'} |
|
549 | 549 | (?s: |
550 | 550 | <!-- .*? --> |
551 | 551 | ) |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | |
555 | 555 | | # PHP and ASP-style processor instructions (<? and <%) |
556 | 556 | |
557 | - [ ]{0,' . $less_than_tab . '} |
|
557 | + [ ]{0,' . $less_than_tab.'} |
|
558 | 558 | (?s: |
559 | 559 | <([?%]) # $2 |
560 | 560 | .*? |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | |
598 | 598 | # Then hash the block. |
599 | 599 | static $i = 0; |
600 | - $key = "$boundary\x1A" . ++ $i . $boundary; |
|
600 | + $key = "$boundary\x1A".++ $i.$boundary; |
|
601 | 601 | $this->html_hashes[$key] = $text; |
602 | 602 | return $key; # String that will replace the tag. |
603 | 603 | } |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | [ ]* # Tailing spaces |
669 | 669 | $ # End of line. |
670 | 670 | }mx', |
671 | - "\n" . $this->hashBlock("<hr$this->empty_element_suffix") . "\n", |
|
671 | + "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", |
|
672 | 672 | $text |
673 | 673 | ); |
674 | 674 | } |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | # |
681 | 681 | # Process character escapes, code spans, and inline HTML |
682 | 682 | # in one shot. |
683 | - "parseSpan" => - 30, |
|
683 | + "parseSpan" => -30, |
|
684 | 684 | # Process anchor and image tags. Images must come first, |
685 | 685 | # because ![foo][f] looks like an anchor. |
686 | 686 | "doImages" => 10, |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | '{ |
739 | 739 | ( # wrap whole match in $1 |
740 | 740 | \[ |
741 | - (' . $this->nested_brackets_re . ') # link text = $2 |
|
741 | + (' . $this->nested_brackets_re.') # link text = $2 |
|
742 | 742 | \] |
743 | 743 | |
744 | 744 | [ ]? # one optional space |
@@ -760,14 +760,14 @@ discard block |
||
760 | 760 | '{ |
761 | 761 | ( # wrap whole match in $1 |
762 | 762 | \[ |
763 | - (' . $this->nested_brackets_re . ') # link text = $2 |
|
763 | + (' . $this->nested_brackets_re.') # link text = $2 |
|
764 | 764 | \] |
765 | 765 | \( # literal paren |
766 | 766 | [ \n]* |
767 | 767 | (?: |
768 | 768 | <(.+?)> # href = $3 |
769 | 769 | | |
770 | - (' . $this->nested_url_parenthesis_re . ') # href = $4 |
|
770 | + (' . $this->nested_url_parenthesis_re.') # href = $4 |
|
771 | 771 | ) |
772 | 772 | [ \n]* |
773 | 773 | ( # $5 |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | { |
809 | 809 | $whole_match = $matches[1]; |
810 | 810 | $link_text = $matches[2]; |
811 | - $link_id =& $matches[3]; |
|
811 | + $link_id = & $matches[3]; |
|
812 | 812 | |
813 | 813 | if ($link_id == "") { |
814 | 814 | # for shortcut links like [this][] or [this]. |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | $whole_match = $matches[1]; |
845 | 845 | $link_text = $this->runSpanGamut($matches[2]); |
846 | 846 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
847 | - $title =& $matches[7]; |
|
847 | + $title = & $matches[7]; |
|
848 | 848 | |
849 | 849 | $url = $this->encodeAttribute($url); |
850 | 850 | |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | '{ |
873 | 873 | ( # wrap whole match in $1 |
874 | 874 | !\[ |
875 | - (' . $this->nested_brackets_re . ') # alt text = $2 |
|
875 | + (' . $this->nested_brackets_re.') # alt text = $2 |
|
876 | 876 | \] |
877 | 877 | |
878 | 878 | [ ]? # one optional space |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | '{ |
897 | 897 | ( # wrap whole match in $1 |
898 | 898 | !\[ |
899 | - (' . $this->nested_brackets_re . ') # alt text = $2 |
|
899 | + (' . $this->nested_brackets_re.') # alt text = $2 |
|
900 | 900 | \] |
901 | 901 | \s? # One optional whitespace character |
902 | 902 | \( # literal paren |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | (?: |
905 | 905 | <(\S*)> # src url = $3 |
906 | 906 | | |
907 | - (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
907 | + (' . $this->nested_url_parenthesis_re.') # src url = $4 |
|
908 | 908 | ) |
909 | 909 | [ \n]* |
910 | 910 | ( # $5 |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | $whole_match = $matches[1]; |
958 | 958 | $alt_text = $matches[2]; |
959 | 959 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
960 | - $title =& $matches[7]; |
|
960 | + $title = & $matches[7]; |
|
961 | 961 | |
962 | 962 | $alt_text = $this->encodeAttribute($alt_text); |
963 | 963 | $url = $this->encodeAttribute($url); |
@@ -1017,15 +1017,15 @@ discard block |
||
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | $level = $matches[2]{0} == '=' ? 1 : 2; |
1020 | - $block = "<h$level>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
1021 | - return "\n" . $this->hashBlock($block) . "\n\n"; |
|
1020 | + $block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
1021 | + return "\n".$this->hashBlock($block)."\n\n"; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | function _doHeaders_callback_atx($matches) |
1025 | 1025 | { |
1026 | 1026 | $level = strlen($matches[1]); |
1027 | - $block = "<h$level>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
1028 | - return "\n" . $this->hashBlock($block) . "\n\n"; |
|
1027 | + $block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
1028 | + return "\n".$this->hashBlock($block)."\n\n"; |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | function doLists($text) |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | $whole_list_re = ' |
1051 | 1051 | ( # $1 = whole list |
1052 | 1052 | ( # $2 |
1053 | - ([ ]{0,' . $less_than_tab . '}) # $3 = number of spaces |
|
1054 | - (' . $marker_re . ') # $4 = first list item marker |
|
1053 | + ([ ]{0,' . $less_than_tab.'}) # $3 = number of spaces |
|
1054 | + (' . $marker_re.') # $4 = first list item marker |
|
1055 | 1055 | [ ]+ |
1056 | 1056 | ) |
1057 | 1057 | (?s:.+?) |
@@ -1062,13 +1062,13 @@ discard block |
||
1062 | 1062 | (?=\S) |
1063 | 1063 | (?! # Negative lookahead for another list item marker |
1064 | 1064 | [ ]* |
1065 | - ' . $marker_re . '[ ]+ |
|
1065 | + ' . $marker_re.'[ ]+ |
|
1066 | 1066 | ) |
1067 | 1067 | | |
1068 | 1068 | (?= # Lookahead for another kind of list |
1069 | 1069 | \n |
1070 | 1070 | \3 # Must have the same indentation |
1071 | - ' . $other_marker_re . '[ ]+ |
|
1071 | + ' . $other_marker_re.'[ ]+ |
|
1072 | 1072 | ) |
1073 | 1073 | ) |
1074 | 1074 | ) |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | $text = preg_replace_callback( |
1082 | 1082 | '{ |
1083 | 1083 | ^ |
1084 | - ' . $whole_list_re . ' |
|
1084 | + ' . $whole_list_re.' |
|
1085 | 1085 | }mx', |
1086 | 1086 | array(&$this, '_doLists_callback'), |
1087 | 1087 | $text |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | $text = preg_replace_callback( |
1091 | 1091 | '{ |
1092 | 1092 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
1093 | - ' . $whole_list_re . ' |
|
1093 | + ' . $whole_list_re.' |
|
1094 | 1094 | }mx', |
1095 | 1095 | array(&$this, '_doLists_callback'), |
1096 | 1096 | $text |
@@ -1116,8 +1116,8 @@ discard block |
||
1116 | 1116 | $list .= "\n"; |
1117 | 1117 | $result = $this->processListItems($list, $marker_any_re); |
1118 | 1118 | |
1119 | - $result = $this->hashBlock("<$list_type>\n" . $result . "</$list_type>"); |
|
1120 | - return "\n" . $result . "\n\n"; |
|
1119 | + $result = $this->hashBlock("<$list_type>\n".$result."</$list_type>"); |
|
1120 | + return "\n".$result."\n\n"; |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | var $list_level = 0; |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | # change the syntax rules such that sub-lists must start with a |
1150 | 1150 | # starting cardinal number; e.g. "1." or "a.". |
1151 | 1151 | |
1152 | - $this->list_level ++; |
|
1152 | + $this->list_level++; |
|
1153 | 1153 | |
1154 | 1154 | # trim trailing blank lines: |
1155 | 1155 | $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str); |
@@ -1158,35 +1158,35 @@ discard block |
||
1158 | 1158 | '{ |
1159 | 1159 | (\n)? # leading line = $1 |
1160 | 1160 | (^[ ]*) # leading whitespace = $2 |
1161 | - (' . $marker_any_re . ' # list marker and space = $3 |
|
1161 | + (' . $marker_any_re.' # list marker and space = $3 |
|
1162 | 1162 | (?:[ ]+|(?=\n)) # space only required if item is not empty |
1163 | 1163 | ) |
1164 | 1164 | ((?s:.*?)) # list item text = $4 |
1165 | 1165 | (?:(\n+(?=\n))|\n) # tailing blank line = $5 |
1166 | - (?= \n* (\z | \2 (' . $marker_any_re . ') (?:[ ]+|(?=\n)))) |
|
1166 | + (?= \n* (\z | \2 (' . $marker_any_re.') (?:[ ]+|(?=\n)))) |
|
1167 | 1167 | }xm', |
1168 | 1168 | array(&$this, '_processListItems_callback'), |
1169 | 1169 | $list_str |
1170 | 1170 | ); |
1171 | 1171 | |
1172 | - $this->list_level --; |
|
1172 | + $this->list_level--; |
|
1173 | 1173 | return $list_str; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | function _processListItems_callback($matches) |
1177 | 1177 | { |
1178 | 1178 | $item = $matches[4]; |
1179 | - $leading_line =& $matches[1]; |
|
1180 | - $leading_space =& $matches[2]; |
|
1179 | + $leading_line = & $matches[1]; |
|
1180 | + $leading_space = & $matches[2]; |
|
1181 | 1181 | $marker_space = $matches[3]; |
1182 | - $tailing_blank_line =& $matches[5]; |
|
1182 | + $tailing_blank_line = & $matches[5]; |
|
1183 | 1183 | |
1184 | 1184 | if ($leading_line || $tailing_blank_line || |
1185 | 1185 | preg_match('/\n{2,}/', $item) |
1186 | 1186 | ) { |
1187 | 1187 | # Replace marker with the appropriate whitespace indentation |
1188 | - $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
|
1189 | - $item = $this->runBlockGamut($this->outdent($item) . "\n"); |
|
1188 | + $item = $leading_space.str_repeat(' ', strlen($marker_space)).$item; |
|
1189 | + $item = $this->runBlockGamut($this->outdent($item)."\n"); |
|
1190 | 1190 | } else { |
1191 | 1191 | # Recursion for sub-lists: |
1192 | 1192 | $item = $this->doLists($this->outdent($item)); |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | $item = $this->runSpanGamut($item); |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - return "<li>" . $item . "</li>\n"; |
|
1197 | + return "<li>".$item."</li>\n"; |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | function doCodeBlocks($text) |
@@ -1207,11 +1207,11 @@ discard block |
||
1207 | 1207 | (?:\n\n|\A\n?) |
1208 | 1208 | ( # $1 = the code block -- one or more lines, starting with a space/tab |
1209 | 1209 | (?> |
1210 | - [ ]{' . $this->tab_width . '} # Lines must start with a tab or a tab-width of spaces |
|
1210 | + [ ]{' . $this->tab_width.'} # Lines must start with a tab or a tab-width of spaces |
|
1211 | 1211 | .*\n+ |
1212 | 1212 | )+ |
1213 | 1213 | ) |
1214 | - ((?=^[ ]{0,' . $this->tab_width . '}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
1214 | + ((?=^[ ]{0,' . $this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc |
|
1215 | 1215 | }xm', |
1216 | 1216 | array(&$this, '_doCodeBlocks_callback'), |
1217 | 1217 | $text |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock); |
1232 | 1232 | |
1233 | 1233 | $codeblock = "<pre><code>$codeblock\n</code></pre>"; |
1234 | - return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
1234 | + return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | function makeCodeSpan($code) |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | $token_relist[] = $strong_re; |
1281 | 1281 | |
1282 | 1282 | # Construct master expression from list. |
1283 | - $token_re = '{(' . implode('|', $token_relist) . ')}'; |
|
1283 | + $token_re = '{('.implode('|', $token_relist).')}'; |
|
1284 | 1284 | $this->em_strong_prepared_relist["$em$strong"] = $token_re; |
1285 | 1285 | } |
1286 | 1286 | } |
@@ -1307,8 +1307,8 @@ discard block |
||
1307 | 1307 | # |
1308 | 1308 | $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); |
1309 | 1309 | $text_stack[0] .= $parts[0]; |
1310 | - $token =& $parts[1]; |
|
1311 | - $text =& $parts[2]; |
|
1310 | + $token = & $parts[1]; |
|
1311 | + $text = & $parts[2]; |
|
1312 | 1312 | |
1313 | 1313 | if (empty($token)) { |
1314 | 1314 | # Reached end of text span: empty stack without emitting. |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | $bq |
1446 | 1446 | ); |
1447 | 1447 | |
1448 | - return "\n" . $this->hashBlock("<blockquote>\n$bq\n</blockquote>") . "\n\n"; |
|
1448 | + return "\n".$this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n"; |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | function _doBlockQuotes_callback2($matches) |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | # Wrap <p> tags and unhashify HTML blocks |
1471 | 1471 | # |
1472 | 1472 | foreach ($grafs as $key => $value) { |
1473 | - if (!preg_match('/^B\x1A[0-9]+B$/', $value)) { |
|
1473 | + if ( ! preg_match('/^B\x1A[0-9]+B$/', $value)) { |
|
1474 | 1474 | # Is a paragraph. |
1475 | 1475 | $value = $this->runSpanGamut($value); |
1476 | 1476 | $value = preg_replace('/^([ ]*)/', "<p>", $value); |
@@ -1551,7 +1551,7 @@ discard block |
||
1551 | 1551 | '/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', |
1552 | 1552 | '&', |
1553 | 1553 | $text |
1554 | - );; |
|
1554 | + ); ; |
|
1555 | 1555 | } |
1556 | 1556 | # Encode remaining <'s |
1557 | 1557 | $text = str_replace('<', '<', $text); |
@@ -1625,9 +1625,9 @@ discard block |
||
1625 | 1625 | # Based by a filter by Matthew Wickline, posted to BBEdit-Talk. |
1626 | 1626 | # With some optimizations by Milian Wolff. |
1627 | 1627 | # |
1628 | - $addr = "mailto:" . $addr; |
|
1628 | + $addr = "mailto:".$addr; |
|
1629 | 1629 | $chars = preg_split('/(?<!^)(?!$)/', $addr); |
1630 | - $seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
1630 | + $seed = (int) abs(crc32($addr) / strlen($addr)); # Deterministic seed. |
|
1631 | 1631 | |
1632 | 1632 | foreach ($chars as $key => $char) { |
1633 | 1633 | $ord = ord($char); |
@@ -1639,9 +1639,9 @@ discard block |
||
1639 | 1639 | if ($r > 90 && $char != '@') /* do nothing */ { |
1640 | 1640 | ; |
1641 | 1641 | } else if ($r < 45) { |
1642 | - $chars[$key] = '&#x' . dechex($ord) . ';'; |
|
1642 | + $chars[$key] = '&#x'.dechex($ord).';'; |
|
1643 | 1643 | } else { |
1644 | - $chars[$key] = '&#' . $ord . ';'; |
|
1644 | + $chars[$key] = '&#'.$ord.';'; |
|
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | } |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | |
1664 | 1664 | $span_re = '{ |
1665 | 1665 | ( |
1666 | - \\\\' . $this->escape_chars_re . ' |
|
1666 | + \\\\' . $this->escape_chars_re.' |
|
1667 | 1667 | | |
1668 | 1668 | (?<![`\\\\]) |
1669 | 1669 | `+ # code span marker |
@@ -1683,7 +1683,7 @@ discard block |
||
1683 | 1683 | <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag |
1684 | 1684 | | |
1685 | 1685 | </[-a-zA-Z0-9:_]+\s*> # closing tag |
1686 | - ') . ' |
|
1686 | + ').' |
|
1687 | 1687 | ) |
1688 | 1688 | }xs'; |
1689 | 1689 | |
@@ -1720,11 +1720,11 @@ discard block |
||
1720 | 1720 | # |
1721 | 1721 | switch ($token{0}) { |
1722 | 1722 | case "\\": |
1723 | - return $this->hashPart("&#" . ord($token{1}) . ";"); |
|
1723 | + return $this->hashPart("&#".ord($token{1}).";"); |
|
1724 | 1724 | case "`": |
1725 | 1725 | # Search for end marker in remaining text. |
1726 | 1726 | if (preg_match( |
1727 | - '/^(.*?[^`])' . preg_quote($token) . '(?!`)(.*)$/sm', |
|
1727 | + '/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', |
|
1728 | 1728 | $str, |
1729 | 1729 | $matches |
1730 | 1730 | )) { |
@@ -1743,7 +1743,7 @@ discard block |
||
1743 | 1743 | # |
1744 | 1744 | # Remove one level of line-leading tabs or spaces |
1745 | 1745 | # |
1746 | - return preg_replace('/^(\t|[ ]{1,' . $this->tab_width . '})/m', '', $text); |
|
1746 | + return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text); |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | |
@@ -1783,7 +1783,7 @@ discard block |
||
1783 | 1783 | # Calculate amount of space, insert spaces, insert block. |
1784 | 1784 | $amount = $this->tab_width - |
1785 | 1785 | $strlen($line, 'UTF-8') % $this->tab_width; |
1786 | - $line .= str_repeat(" ", $amount) . $block; |
|
1786 | + $line .= str_repeat(" ", $amount).$block; |
|
1787 | 1787 | } |
1788 | 1788 | return $line; |
1789 | 1789 | } |
@@ -1984,11 +1984,11 @@ discard block |
||
1984 | 1984 | |
1985 | 1985 | # compose attributes as string |
1986 | 1986 | $attr_str = ""; |
1987 | - if (!empty($id)) { |
|
1988 | - $attr_str .= ' id="' . $id . '"'; |
|
1987 | + if ( ! empty($id)) { |
|
1988 | + $attr_str .= ' id="'.$id.'"'; |
|
1989 | 1989 | } |
1990 | - if (!empty($classes)) { |
|
1991 | - $attr_str .= ' class="' . implode(" ", $classes) . '"'; |
|
1990 | + if ( ! empty($classes)) { |
|
1991 | + $attr_str .= ' class="'.implode(" ", $classes).'"'; |
|
1992 | 1992 | } |
1993 | 1993 | return $attr_str; |
1994 | 1994 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | # Link defs are in the form: ^[id]: url "optional title" |
2005 | 2005 | $text = preg_replace_callback( |
2006 | 2006 | '{ |
2007 | - ^[ ]{0,' . $less_than_tab . '}\[(.+)\][ ]?: # id = $1 |
|
2007 | + ^[ ]{0,' . $less_than_tab.'}\[(.+)\][ ]?: # id = $1 |
|
2008 | 2008 | [ ]* |
2009 | 2009 | \n? # maybe *one* newline |
2010 | 2010 | [ ]* |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | [")] |
2024 | 2024 | [ ]* |
2025 | 2025 | )? # title is optional |
2026 | - (?:[ ]* ' . $this->id_class_attr_catch_re . ' )? # $5 = extra id & class attr |
|
2026 | + (?:[ ]* ' . $this->id_class_attr_catch_re.' )? # $5 = extra id & class attr |
|
2027 | 2027 | (?:\n+|\Z) |
2028 | 2028 | }xm', |
2029 | 2029 | array(&$this, '_stripLinkDefinitions_callback'), |
@@ -2037,8 +2037,8 @@ discard block |
||
2037 | 2037 | $link_id = strtolower($matches[1]); |
2038 | 2038 | $url = $matches[2] == '' ? $matches[3] : $matches[2]; |
2039 | 2039 | $this->urls[$link_id] = $url; |
2040 | - $this->titles[$link_id] =& $matches[4]; |
|
2041 | - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); |
|
2040 | + $this->titles[$link_id] = & $matches[4]; |
|
2041 | + $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy = & $matches[5]); |
|
2042 | 2042 | return ''; # String that will replace the block |
2043 | 2043 | } |
2044 | 2044 | |
@@ -2140,10 +2140,10 @@ discard block |
||
2140 | 2140 | ( # $2: Capture whole tag. |
2141 | 2141 | </? # Any opening or closing tag. |
2142 | 2142 | (?> # Tag name. |
2143 | - ' . $this->block_tags_re . ' | |
|
2144 | - ' . $this->context_block_tags_re . ' | |
|
2145 | - ' . $this->clean_tags_re . ' | |
|
2146 | - (?!\s)' . $enclosing_tag_re . ' |
|
2143 | + ' . $this->block_tags_re.' | |
|
2144 | + ' . $this->context_block_tags_re.' | |
|
2145 | + ' . $this->clean_tags_re.' | |
|
2146 | + (?!\s)' . $enclosing_tag_re.' |
|
2147 | 2147 | ) |
2148 | 2148 | (?: |
2149 | 2149 | (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name. |
@@ -2163,27 +2163,27 @@ discard block |
||
2163 | 2163 | | |
2164 | 2164 | # Code span marker |
2165 | 2165 | `+ |
2166 | - ' . (!$span ? ' # If not in span. |
|
2166 | + ' . ( ! $span ? ' # If not in span. |
|
2167 | 2167 | | |
2168 | 2168 | # Indented code block |
2169 | 2169 | (?: ^[ ]*\n | ^ | \n[ ]*\n ) |
2170 | - [ ]{' . ($indent + 4) . '}[^\n]* \n |
|
2170 | + [ ]{' . ($indent + 4).'}[^\n]* \n |
|
2171 | 2171 | (?> |
2172 | - (?: [ ]{' . ($indent + 4) . '}[^\n]* | [ ]* ) \n |
|
2172 | + (?: [ ]{' . ($indent + 4).'}[^\n]* | [ ]* ) \n |
|
2173 | 2173 | )* |
2174 | 2174 | | |
2175 | 2175 | # Fenced code block marker |
2176 | 2176 | (?<= ^ | \n ) |
2177 | - [ ]{0,' . ($indent + 3) . '}~{3,} |
|
2177 | + [ ]{0,' . ($indent + 3).'}~{3,} |
|
2178 | 2178 | [ ]* |
2179 | 2179 | (?: |
2180 | 2180 | \.?[-_:a-zA-Z0-9]+ # standalone class name |
2181 | 2181 | | |
2182 | - ' . $this->id_class_attr_nocatch_re . ' # extra attributes |
|
2182 | + ' . $this->id_class_attr_nocatch_re.' # extra attributes |
|
2183 | 2183 | )? |
2184 | 2184 | [ ]* |
2185 | 2185 | \n |
2186 | - ' : '') . ' # End (if not is span). |
|
2186 | + ' : '').' # End (if not is span). |
|
2187 | 2187 | ) |
2188 | 2188 | }xs'; |
2189 | 2189 | |
@@ -2213,7 +2213,7 @@ discard block |
||
2213 | 2213 | if ($span) { |
2214 | 2214 | $void = $this->hashPart("", ':'); |
2215 | 2215 | $newline = "$void\n"; |
2216 | - $parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void; |
|
2216 | + $parts[0] = $void.str_replace("\n", $newline, $parts[0]).$void; |
|
2217 | 2217 | } |
2218 | 2218 | |
2219 | 2219 | $parsed .= $parts[0]; # Text before current tag. |
@@ -2235,12 +2235,12 @@ discard block |
||
2235 | 2235 | # Find corresponding end marker. |
2236 | 2236 | $tag_re = preg_quote($tag); |
2237 | 2237 | if (preg_match( |
2238 | - '{^(?>.+?|\n(?!\n))*?(?<!`)' . $tag_re . '(?!`)}', |
|
2238 | + '{^(?>.+?|\n(?!\n))*?(?<!`)'.$tag_re.'(?!`)}', |
|
2239 | 2239 | $text, |
2240 | 2240 | $matches |
2241 | 2241 | )) { |
2242 | 2242 | # End marker found: pass text unchanged until marker. |
2243 | - $parsed .= $tag . $matches[0]; |
|
2243 | + $parsed .= $tag.$matches[0]; |
|
2244 | 2244 | $text = substr($text, strlen($matches[0])); |
2245 | 2245 | } else { |
2246 | 2246 | # Unmatched marker: just skip it. |
@@ -2250,17 +2250,17 @@ discard block |
||
2250 | 2250 | # |
2251 | 2251 | # Check for: Fenced code block marker. |
2252 | 2252 | # |
2253 | - else if (preg_match('{^\n?([ ]{0,' . ($indent + 3) . '})(~+)}', $tag, $capture)) { |
|
2253 | + else if (preg_match('{^\n?([ ]{0,'.($indent + 3).'})(~+)}', $tag, $capture)) { |
|
2254 | 2254 | # Fenced code block marker: find matching end marker. |
2255 | 2255 | $fence_indent = strlen($capture[1]); # use captured indent in re |
2256 | 2256 | $fence_re = $capture[2]; # use captured fence in re |
2257 | 2257 | if (preg_match( |
2258 | - '{^(?>.*\n)*?[ ]{' . ($fence_indent) . '}' . $fence_re . '[ ]*(?:\n|$)}', |
|
2258 | + '{^(?>.*\n)*?[ ]{'.($fence_indent).'}'.$fence_re.'[ ]*(?:\n|$)}', |
|
2259 | 2259 | $text, |
2260 | 2260 | $matches |
2261 | 2261 | )) { |
2262 | 2262 | # End marker found: pass text unchanged until marker. |
2263 | - $parsed .= $tag . $matches[0]; |
|
2263 | + $parsed .= $tag.$matches[0]; |
|
2264 | 2264 | $text = substr($text, strlen($matches[0])); |
2265 | 2265 | } else { |
2266 | 2266 | # No end marker: just skip it. |
@@ -2280,14 +2280,14 @@ discard block |
||
2280 | 2280 | # Opening Context Block tag (like ins and del) |
2281 | 2281 | # used as a block tag (tag is alone on it's line). |
2282 | 2282 | # |
2283 | - else if (preg_match('{^<(?:' . $this->block_tags_re . ')\b}', $tag) || |
|
2284 | - (preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) && |
|
2283 | + else if (preg_match('{^<(?:'.$this->block_tags_re.')\b}', $tag) || |
|
2284 | + (preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) && |
|
2285 | 2285 | preg_match($newline_before_re, $parsed) && |
2286 | 2286 | preg_match($newline_after_re, $text)) |
2287 | 2287 | ) { |
2288 | 2288 | # Need to parse tag and following text using the HTML parser. |
2289 | 2289 | list($block_text, $text) = |
2290 | - $this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true); |
|
2290 | + $this->_hashHTMLBlocks_inHTML($tag.$text, "hashBlock", true); |
|
2291 | 2291 | |
2292 | 2292 | # Make sure it stays outside of any paragraph by adding newlines. |
2293 | 2293 | $parsed .= "\n\n$block_text\n\n"; |
@@ -2296,13 +2296,13 @@ discard block |
||
2296 | 2296 | # Check for: Clean tag (like script, math) |
2297 | 2297 | # HTML Comments, processing instructions. |
2298 | 2298 | # |
2299 | - else if (preg_match('{^<(?:' . $this->clean_tags_re . ')\b}', $tag) || |
|
2299 | + else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) || |
|
2300 | 2300 | $tag{1} == '!' || $tag{1} == '?' |
2301 | 2301 | ) { |
2302 | 2302 | # Need to parse tag and following text using the HTML parser. |
2303 | 2303 | # (don't check for markdown attribute) |
2304 | 2304 | list($block_text, $text) = |
2305 | - $this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false); |
|
2305 | + $this->_hashHTMLBlocks_inHTML($tag.$text, "hashClean", false); |
|
2306 | 2306 | |
2307 | 2307 | $parsed .= $block_text; |
2308 | 2308 | } |
@@ -2311,15 +2311,15 @@ discard block |
||
2311 | 2311 | # |
2312 | 2312 | else if ($enclosing_tag_re !== '' && |
2313 | 2313 | # Same name as enclosing tag. |
2314 | - preg_match('{^</?(?:' . $enclosing_tag_re . ')\b}', $tag) |
|
2314 | + preg_match('{^</?(?:'.$enclosing_tag_re.')\b}', $tag) |
|
2315 | 2315 | ) { |
2316 | 2316 | # |
2317 | 2317 | # Increase/decrease nested tag count. |
2318 | 2318 | # |
2319 | 2319 | if ($tag{1} == '/') { |
2320 | - $depth --; |
|
2320 | + $depth--; |
|
2321 | 2321 | } else if ($tag{strlen($tag) - 2} != '/') { |
2322 | - $depth ++; |
|
2322 | + $depth++; |
|
2323 | 2323 | } |
2324 | 2324 | |
2325 | 2325 | if ($depth < 0) { |
@@ -2327,7 +2327,7 @@ discard block |
||
2327 | 2327 | # Going out of parent element. Clean up and break so we |
2328 | 2328 | # return to the calling function. |
2329 | 2329 | # |
2330 | - $text = $tag . $text; |
|
2330 | + $text = $tag.$text; |
|
2331 | 2331 | break; |
2332 | 2332 | } |
2333 | 2333 | |
@@ -2439,7 +2439,7 @@ discard block |
||
2439 | 2439 | # Check for: Auto-close tag (like <hr/>) |
2440 | 2440 | # Comments and Processing Instructions. |
2441 | 2441 | # |
2442 | - if (preg_match('{^</?(?:' . $this->auto_close_tags_re . ')\b}', $tag) || |
|
2442 | + if (preg_match('{^</?(?:'.$this->auto_close_tags_re.')\b}', $tag) || |
|
2443 | 2443 | $tag{1} == '!' || $tag{1} == '?' |
2444 | 2444 | ) { |
2445 | 2445 | # Just add the tag to the block as if it was text. |
@@ -2449,11 +2449,11 @@ discard block |
||
2449 | 2449 | # Increase/decrease nested tag count. Only do so if |
2450 | 2450 | # the tag's name match base tag's. |
2451 | 2451 | # |
2452 | - if (preg_match('{^</?' . $base_tag_name_re . '\b}', $tag)) { |
|
2452 | + if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) { |
|
2453 | 2453 | if ($tag{1} == '/') { |
2454 | - $depth --; |
|
2454 | + $depth--; |
|
2455 | 2455 | } else if ($tag{strlen($tag) - 2} != '/') { |
2456 | - $depth ++; |
|
2456 | + $depth++; |
|
2457 | 2457 | } |
2458 | 2458 | } |
2459 | 2459 | |
@@ -2462,16 +2462,16 @@ discard block |
||
2462 | 2462 | # |
2463 | 2463 | if ($md_attr && |
2464 | 2464 | preg_match($markdown_attr_re, $tag, $attr_m) && |
2465 | - preg_match('/^1|block|span$/', $attr_m[2] . $attr_m[3]) |
|
2465 | + preg_match('/^1|block|span$/', $attr_m[2].$attr_m[3]) |
|
2466 | 2466 | ) { |
2467 | 2467 | # Remove `markdown` attribute from opening tag. |
2468 | 2468 | $tag = preg_replace($markdown_attr_re, '', $tag); |
2469 | 2469 | |
2470 | 2470 | # Check if text inside this tag must be parsed in span mode. |
2471 | - $this->mode = $attr_m[2] . $attr_m[3]; |
|
2471 | + $this->mode = $attr_m[2].$attr_m[3]; |
|
2472 | 2472 | $span_mode = $this->mode == 'span' || $this->mode != 'block' && |
2473 | 2473 | preg_match( |
2474 | - '{^<(?:' . $this->contain_span_tags_re . ')\b}', |
|
2474 | + '{^<(?:'.$this->contain_span_tags_re.')\b}', |
|
2475 | 2475 | $tag |
2476 | 2476 | ); |
2477 | 2477 | |
@@ -2511,7 +2511,7 @@ discard block |
||
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | # Append tag content to parsed text. |
2514 | - if (!$span_mode) { |
|
2514 | + if ( ! $span_mode) { |
|
2515 | 2515 | $parsed .= "\n\n$block_text\n\n"; |
2516 | 2516 | } else { |
2517 | 2517 | $parsed .= "$block_text"; |
@@ -2560,7 +2560,7 @@ discard block |
||
2560 | 2560 | '{ |
2561 | 2561 | ( # wrap whole match in $1 |
2562 | 2562 | \[ |
2563 | - (' . $this->nested_brackets_re . ') # link text = $2 |
|
2563 | + (' . $this->nested_brackets_re.') # link text = $2 |
|
2564 | 2564 | \] |
2565 | 2565 | |
2566 | 2566 | [ ]? # one optional space |
@@ -2582,14 +2582,14 @@ discard block |
||
2582 | 2582 | '{ |
2583 | 2583 | ( # wrap whole match in $1 |
2584 | 2584 | \[ |
2585 | - (' . $this->nested_brackets_re . ') # link text = $2 |
|
2585 | + (' . $this->nested_brackets_re.') # link text = $2 |
|
2586 | 2586 | \] |
2587 | 2587 | \( # literal paren |
2588 | 2588 | [ \n]* |
2589 | 2589 | (?: |
2590 | 2590 | <(.+?)> # href = $3 |
2591 | 2591 | | |
2592 | - (' . $this->nested_url_parenthesis_re . ') # href = $4 |
|
2592 | + (' . $this->nested_url_parenthesis_re.') # href = $4 |
|
2593 | 2593 | ) |
2594 | 2594 | [ \n]* |
2595 | 2595 | ( # $5 |
@@ -2599,7 +2599,7 @@ discard block |
||
2599 | 2599 | [ \n]* # ignore any spaces/tabs between closing quote and ) |
2600 | 2600 | )? # title is optional |
2601 | 2601 | \) |
2602 | - (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
2602 | + (?:[ ]? ' . $this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
2603 | 2603 | ) |
2604 | 2604 | }xs', |
2605 | 2605 | array(&$this, '_doAnchors_inline_callback'), |
@@ -2631,7 +2631,7 @@ discard block |
||
2631 | 2631 | { |
2632 | 2632 | $whole_match = $matches[1]; |
2633 | 2633 | $link_text = $matches[2]; |
2634 | - $link_id =& $matches[3]; |
|
2634 | + $link_id = & $matches[3]; |
|
2635 | 2635 | |
2636 | 2636 | if ($link_id == "") { |
2637 | 2637 | # for shortcut links like [this][] or [this]. |
@@ -2670,8 +2670,8 @@ discard block |
||
2670 | 2670 | $whole_match = $matches[1]; |
2671 | 2671 | $link_text = $this->runSpanGamut($matches[2]); |
2672 | 2672 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
2673 | - $title =& $matches[7]; |
|
2674 | - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); |
|
2673 | + $title = & $matches[7]; |
|
2674 | + $attr = $this->doExtraAttributes("a", $dummy = & $matches[8]); |
|
2675 | 2675 | |
2676 | 2676 | $url = $this->encodeAttribute($url); |
2677 | 2677 | |
@@ -2700,7 +2700,7 @@ discard block |
||
2700 | 2700 | '{ |
2701 | 2701 | ( # wrap whole match in $1 |
2702 | 2702 | !\[ |
2703 | - (' . $this->nested_brackets_re . ') # alt text = $2 |
|
2703 | + (' . $this->nested_brackets_re.') # alt text = $2 |
|
2704 | 2704 | \] |
2705 | 2705 | |
2706 | 2706 | [ ]? # one optional space |
@@ -2724,7 +2724,7 @@ discard block |
||
2724 | 2724 | '{ |
2725 | 2725 | ( # wrap whole match in $1 |
2726 | 2726 | !\[ |
2727 | - (' . $this->nested_brackets_re . ') # alt text = $2 |
|
2727 | + (' . $this->nested_brackets_re.') # alt text = $2 |
|
2728 | 2728 | \] |
2729 | 2729 | \s? # One optional whitespace character |
2730 | 2730 | \( # literal paren |
@@ -2732,7 +2732,7 @@ discard block |
||
2732 | 2732 | (?: |
2733 | 2733 | <(\S*)> # src url = $3 |
2734 | 2734 | | |
2735 | - (' . $this->nested_url_parenthesis_re . ') # src url = $4 |
|
2735 | + (' . $this->nested_url_parenthesis_re.') # src url = $4 |
|
2736 | 2736 | ) |
2737 | 2737 | [ \n]* |
2738 | 2738 | ( # $5 |
@@ -2742,7 +2742,7 @@ discard block |
||
2742 | 2742 | [ \n]* |
2743 | 2743 | )? # title is optional |
2744 | 2744 | \) |
2745 | - (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes |
|
2745 | + (?:[ ]? ' . $this->id_class_attr_catch_re.' )? # $8 = id/class attributes |
|
2746 | 2746 | ) |
2747 | 2747 | }xs', |
2748 | 2748 | array(&$this, '_doImages_inline_callback'), |
@@ -2789,8 +2789,8 @@ discard block |
||
2789 | 2789 | $whole_match = $matches[1]; |
2790 | 2790 | $alt_text = $matches[2]; |
2791 | 2791 | $url = $matches[3] == '' ? $matches[4] : $matches[3]; |
2792 | - $title =& $matches[7]; |
|
2793 | - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); |
|
2792 | + $title = & $matches[7]; |
|
2793 | + $attr = $this->doExtraAttributes("img", $dummy = & $matches[8]); |
|
2794 | 2794 | |
2795 | 2795 | $alt_text = $this->encodeAttribute($alt_text); |
2796 | 2796 | $url = $this->encodeAttribute($url); |
@@ -2820,7 +2820,7 @@ discard block |
||
2820 | 2820 | $text = preg_replace_callback( |
2821 | 2821 | '{ |
2822 | 2822 | (^.+?) # $1: Header text |
2823 | - (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes |
|
2823 | + (?:[ ]+ ' . $this->id_class_attr_catch_re.' )? # $3 = id/class attributes |
|
2824 | 2824 | [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer |
2825 | 2825 | }mx', |
2826 | 2826 | array(&$this, '_doHeaders_callback_setext'), |
@@ -2841,7 +2841,7 @@ discard block |
||
2841 | 2841 | (.+?) # $2 = Header text |
2842 | 2842 | [ ]* |
2843 | 2843 | \#* # optional closing #\'s (not counted) |
2844 | - (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes |
|
2844 | + (?:[ ]+ ' . $this->id_class_attr_catch_re.' )? # $3 = id/class attributes |
|
2845 | 2845 | [ ]* |
2846 | 2846 | \n+ |
2847 | 2847 | }xm', |
@@ -2858,17 +2858,17 @@ discard block |
||
2858 | 2858 | return $matches[0]; |
2859 | 2859 | } |
2860 | 2860 | $level = $matches[3]{0} == '=' ? 1 : 2; |
2861 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2]); |
|
2862 | - $block = "<h$level$attr>" . $this->runSpanGamut($matches[1]) . "</h$level>"; |
|
2863 | - return "\n" . $this->hashBlock($block) . "\n\n"; |
|
2861 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[2]); |
|
2862 | + $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>"; |
|
2863 | + return "\n".$this->hashBlock($block)."\n\n"; |
|
2864 | 2864 | } |
2865 | 2865 | |
2866 | 2866 | function _doHeaders_callback_atx($matches) |
2867 | 2867 | { |
2868 | 2868 | $level = strlen($matches[1]); |
2869 | - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3]); |
|
2870 | - $block = "<h$level$attr>" . $this->runSpanGamut($matches[2]) . "</h$level>"; |
|
2871 | - return "\n" . $this->hashBlock($block) . "\n\n"; |
|
2869 | + $attr = $this->doExtraAttributes("h$level", $dummy = & $matches[3]); |
|
2870 | + $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>"; |
|
2871 | + return "\n".$this->hashBlock($block)."\n\n"; |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | function doTables($text) |
@@ -2889,11 +2889,11 @@ discard block |
||
2889 | 2889 | ' |
2890 | 2890 | { |
2891 | 2891 | ^ # Start of a line |
2892 | - [ ]{0,' . $less_than_tab . '} # Allowed whitespace. |
|
2892 | + [ ]{0,' . $less_than_tab.'} # Allowed whitespace. |
|
2893 | 2893 | [|] # Optional leading pipe (present) |
2894 | 2894 | (.+) \n # $1: Header row (at least one pipe) |
2895 | 2895 | |
2896 | - [ ]{0,' . $less_than_tab . '} # Allowed whitespace. |
|
2896 | + [ ]{0,' . $less_than_tab.'} # Allowed whitespace. |
|
2897 | 2897 | [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline |
2898 | 2898 | |
2899 | 2899 | ( # $3: Cells |
@@ -2920,10 +2920,10 @@ discard block |
||
2920 | 2920 | ' |
2921 | 2921 | { |
2922 | 2922 | ^ # Start of a line |
2923 | - [ ]{0,' . $less_than_tab . '} # Allowed whitespace. |
|
2923 | + [ ]{0,' . $less_than_tab.'} # Allowed whitespace. |
|
2924 | 2924 | (\S.*[|].*) \n # $1: Header row (at least one pipe) |
2925 | 2925 | |
2926 | - [ ]{0,' . $less_than_tab . '} # Allowed whitespace. |
|
2926 | + [ ]{0,' . $less_than_tab.'} # Allowed whitespace. |
|
2927 | 2927 | ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline |
2928 | 2928 | |
2929 | 2929 | ( # $3: Cells |
@@ -2989,7 +2989,7 @@ discard block |
||
2989 | 2989 | $text .= "<thead>\n"; |
2990 | 2990 | $text .= "<tr>\n"; |
2991 | 2991 | foreach ($headers as $n => $header) { |
2992 | - $text .= " <th$attr[$n]>" . $this->runSpanGamut(trim($header)) . "</th>\n"; |
|
2992 | + $text .= " <th$attr[$n]>".$this->runSpanGamut(trim($header))."</th>\n"; |
|
2993 | 2993 | } |
2994 | 2994 | $text .= "</tr>\n"; |
2995 | 2995 | $text .= "</thead>\n"; |
@@ -3009,14 +3009,14 @@ discard block |
||
3009 | 3009 | |
3010 | 3010 | $text .= "<tr>\n"; |
3011 | 3011 | foreach ($row_cells as $n => $cell) { |
3012 | - $text .= " <td$attr[$n]>" . $this->runSpanGamut(trim($cell)) . "</td>\n"; |
|
3012 | + $text .= " <td$attr[$n]>".$this->runSpanGamut(trim($cell))."</td>\n"; |
|
3013 | 3013 | } |
3014 | 3014 | $text .= "</tr>\n"; |
3015 | 3015 | } |
3016 | 3016 | $text .= "</tbody>\n"; |
3017 | 3017 | $text .= "</table>"; |
3018 | 3018 | |
3019 | - return $this->hashBlock($text) . "\n"; |
|
3019 | + return $this->hashBlock($text)."\n"; |
|
3020 | 3020 | } |
3021 | 3021 | |
3022 | 3022 | function doDefLists($text) |
@@ -3030,10 +3030,10 @@ discard block |
||
3030 | 3030 | $whole_list_re = '(?> |
3031 | 3031 | ( # $1 = whole list |
3032 | 3032 | ( # $2 |
3033 | - [ ]{0,' . $less_than_tab . '} |
|
3033 | + [ ]{0,' . $less_than_tab.'} |
|
3034 | 3034 | ((?>.*\S.*\n)+) # $3 = defined term |
3035 | 3035 | \n? |
3036 | - [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition |
|
3036 | + [ ]{0,' . $less_than_tab.'}:[ ]+ # colon starting definition |
|
3037 | 3037 | ) |
3038 | 3038 | (?s:.+?) |
3039 | 3039 | ( # $4 |
@@ -3042,13 +3042,13 @@ discard block |
||
3042 | 3042 | \n{2,} |
3043 | 3043 | (?=\S) |
3044 | 3044 | (?! # Negative lookahead for another term |
3045 | - [ ]{0,' . $less_than_tab . '} |
|
3045 | + [ ]{0,' . $less_than_tab.'} |
|
3046 | 3046 | (?: \S.*\n )+? # defined term |
3047 | 3047 | \n? |
3048 | - [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition |
|
3048 | + [ ]{0,' . $less_than_tab.'}:[ ]+ # colon starting definition |
|
3049 | 3049 | ) |
3050 | 3050 | (?! # Negative lookahead for another definition |
3051 | - [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition |
|
3051 | + [ ]{0,' . $less_than_tab.'}:[ ]+ # colon starting definition |
|
3052 | 3052 | ) |
3053 | 3053 | ) |
3054 | 3054 | ) |
@@ -3057,7 +3057,7 @@ discard block |
||
3057 | 3057 | $text = preg_replace_callback( |
3058 | 3058 | '{ |
3059 | 3059 | (?>\A\n?|(?<=\n\n)) |
3060 | - ' . $whole_list_re . ' |
|
3060 | + ' . $whole_list_re.' |
|
3061 | 3061 | }mx', |
3062 | 3062 | array(&$this, '_doDefLists_callback'), |
3063 | 3063 | $text |
@@ -3074,8 +3074,8 @@ discard block |
||
3074 | 3074 | # Turn double returns into triple returns, so that we can make a |
3075 | 3075 | # paragraph for the last item in a list, if necessary: |
3076 | 3076 | $result = trim($this->processDefListItems($list)); |
3077 | - $result = "<dl>\n" . $result . "\n</dl>"; |
|
3078 | - return $this->hashBlock($result) . "\n\n"; |
|
3077 | + $result = "<dl>\n".$result."\n</dl>"; |
|
3078 | + return $this->hashBlock($result)."\n\n"; |
|
3079 | 3079 | } |
3080 | 3080 | |
3081 | 3081 | function processDefListItems($list_str) |
@@ -3094,7 +3094,7 @@ discard block |
||
3094 | 3094 | '{ |
3095 | 3095 | (?>\A\n?|\n\n+) # leading line |
3096 | 3096 | ( # definition terms = $1 |
3097 | - [ ]{0,' . $less_than_tab . '} # leading whitespace |
|
3097 | + [ ]{0,' . $less_than_tab.'} # leading whitespace |
|
3098 | 3098 | (?!\:[ ]|[ ]) # negative lookahead for a definition |
3099 | 3099 | # mark (colon) or more whitespace. |
3100 | 3100 | (?> \S.* \n)+? # actual term (not whitespace). |
@@ -3111,13 +3111,13 @@ discard block |
||
3111 | 3111 | '{ |
3112 | 3112 | \n(\n+)? # leading line = $1 |
3113 | 3113 | ( # marker space = $2 |
3114 | - [ ]{0,' . $less_than_tab . '} # whitespace before colon |
|
3114 | + [ ]{0,' . $less_than_tab.'} # whitespace before colon |
|
3115 | 3115 | \:[ ]+ # definition mark (colon) |
3116 | 3116 | ) |
3117 | 3117 | ((?s:.+?)) # definition text = $3 |
3118 | 3118 | (?= \n+ # stop at next definition mark, |
3119 | 3119 | (?: # next term or end of text |
3120 | - [ ]{0,' . $less_than_tab . '} \:[ ] | |
|
3120 | + [ ]{0,' . $less_than_tab.'} \:[ ] | |
|
3121 | 3121 | <dt> | \z |
3122 | 3122 | ) |
3123 | 3123 | ) |
@@ -3135,9 +3135,9 @@ discard block |
||
3135 | 3135 | $text = ''; |
3136 | 3136 | foreach ($terms as $term) { |
3137 | 3137 | $term = $this->runSpanGamut(trim($term)); |
3138 | - $text .= "\n<dt>" . $term . "</dt>"; |
|
3138 | + $text .= "\n<dt>".$term."</dt>"; |
|
3139 | 3139 | } |
3140 | - return $text . "\n"; |
|
3140 | + return $text."\n"; |
|
3141 | 3141 | } |
3142 | 3142 | |
3143 | 3143 | function _processDefListItems_callback_dd($matches) |
@@ -3148,15 +3148,15 @@ discard block |
||
3148 | 3148 | |
3149 | 3149 | if ($leading_line || preg_match('/\n{2,}/', $def)) { |
3150 | 3150 | # Replace marker with the appropriate whitespace indentation |
3151 | - $def = str_repeat(' ', strlen($marker_space)) . $def; |
|
3152 | - $def = $this->runBlockGamut($this->outdent($def . "\n\n")); |
|
3153 | - $def = "\n" . $def . "\n"; |
|
3151 | + $def = str_repeat(' ', strlen($marker_space)).$def; |
|
3152 | + $def = $this->runBlockGamut($this->outdent($def."\n\n")); |
|
3153 | + $def = "\n".$def."\n"; |
|
3154 | 3154 | } else { |
3155 | 3155 | $def = rtrim($def); |
3156 | 3156 | $def = $this->runSpanGamut($this->outdent($def)); |
3157 | 3157 | } |
3158 | 3158 | |
3159 | - return "\n<dd>" . $def . "</dd>\n"; |
|
3159 | + return "\n<dd>".$def."</dd>\n"; |
|
3160 | 3160 | } |
3161 | 3161 | |
3162 | 3162 | function doFencedCodeBlocks($text) |
@@ -3181,7 +3181,7 @@ discard block |
||
3181 | 3181 | (?: |
3182 | 3182 | \.?([-_:a-zA-Z0-9]+) # 2: standalone class name |
3183 | 3183 | | |
3184 | - ' . $this->id_class_attr_catch_re . ' # 3: Extra attributes |
|
3184 | + ' . $this->id_class_attr_catch_re.' # 3: Extra attributes |
|
3185 | 3185 | )? |
3186 | 3186 | [ ]* \n # Whitespace and newline following marker. |
3187 | 3187 | |
@@ -3205,8 +3205,8 @@ discard block |
||
3205 | 3205 | |
3206 | 3206 | function _doFencedCodeBlocks_callback($matches) |
3207 | 3207 | { |
3208 | - $classname =& $matches[2]; |
|
3209 | - $attrs =& $matches[3]; |
|
3208 | + $classname = & $matches[2]; |
|
3209 | + $attrs = & $matches[3]; |
|
3210 | 3210 | $codeblock = $matches[4]; |
3211 | 3211 | $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); |
3212 | 3212 | $codeblock = preg_replace_callback( |
@@ -3219,7 +3219,7 @@ discard block |
||
3219 | 3219 | if ($classname{0} == '.') { |
3220 | 3220 | $classname = substr($classname, 1); |
3221 | 3221 | } |
3222 | - $attr_str = ' class="' . $this->code_class_prefix . $classname . '"'; |
|
3222 | + $attr_str = ' class="'.$this->code_class_prefix.$classname.'"'; |
|
3223 | 3223 | } else { |
3224 | 3224 | $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs); |
3225 | 3225 | } |
@@ -3227,7 +3227,7 @@ discard block |
||
3227 | 3227 | $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; |
3228 | 3228 | $codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>"; |
3229 | 3229 | |
3230 | - return "\n\n" . $this->hashBlock($codeblock) . "\n\n"; |
|
3230 | + return "\n\n".$this->hashBlock($codeblock)."\n\n"; |
|
3231 | 3231 | } |
3232 | 3232 | |
3233 | 3233 | function _doFencedCodeBlocks_newlines($matches) |
@@ -3280,7 +3280,7 @@ discard block |
||
3280 | 3280 | |
3281 | 3281 | # Check if this should be enclosed in a paragraph. |
3282 | 3282 | # Clean tag hashes & block tag hashes are left alone. |
3283 | - $is_p = !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value); |
|
3283 | + $is_p = ! preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value); |
|
3284 | 3284 | |
3285 | 3285 | if ($is_p) { |
3286 | 3286 | $value = "<p>$value</p>"; |
@@ -3310,7 +3310,7 @@ discard block |
||
3310 | 3310 | # Link defs are in the form: [^id]: url "optional title" |
3311 | 3311 | $text = preg_replace_callback( |
3312 | 3312 | '{ |
3313 | - ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1 |
|
3313 | + ^[ ]{0,' . $less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 |
|
3314 | 3314 | [ ]* |
3315 | 3315 | \n? # maybe *one* newline |
3316 | 3316 | ( # text = $2 (no blank lines allowed) |
@@ -3332,7 +3332,7 @@ discard block |
||
3332 | 3332 | |
3333 | 3333 | function _stripFootnotes_callback($matches) |
3334 | 3334 | { |
3335 | - $note_id = $this->fn_id_prefix . $matches[1]; |
|
3335 | + $note_id = $this->fn_id_prefix.$matches[1]; |
|
3336 | 3336 | $this->footnotes[$note_id] = $this->outdent($matches[2]); |
3337 | 3337 | return ''; # String that will replace the block |
3338 | 3338 | } |
@@ -3343,7 +3343,7 @@ discard block |
||
3343 | 3343 | # Replace footnote references in $text [^id] with a special text-token |
3344 | 3344 | # which will be replaced by the actual footnote marker in appendFootnotes. |
3345 | 3345 | # |
3346 | - if (!$this->in_anchor) { |
|
3346 | + if ( ! $this->in_anchor) { |
|
3347 | 3347 | $text = preg_replace('{\[\^(.+?)\]}', "F\x1Afn:\\1\x1A:", $text); |
3348 | 3348 | } |
3349 | 3349 | return $text; |
@@ -3360,10 +3360,10 @@ discard block |
||
3360 | 3360 | $text |
3361 | 3361 | ); |
3362 | 3362 | |
3363 | - if (!empty($this->footnotes_ordered)) { |
|
3363 | + if ( ! empty($this->footnotes_ordered)) { |
|
3364 | 3364 | $text .= "\n\n"; |
3365 | 3365 | $text .= "<div class=\"footnotes\">\n"; |
3366 | - $text .= "<hr" . $this->empty_element_suffix . "\n"; |
|
3366 | + $text .= "<hr".$this->empty_element_suffix."\n"; |
|
3367 | 3367 | $text .= "<ol>\n\n"; |
3368 | 3368 | |
3369 | 3369 | $attr = " rev=\"footnote\""; |
@@ -3379,7 +3379,7 @@ discard block |
||
3379 | 3379 | } |
3380 | 3380 | $num = 0; |
3381 | 3381 | |
3382 | - while (!empty($this->footnotes_ordered)) { |
|
3382 | + while ( ! empty($this->footnotes_ordered)) { |
|
3383 | 3383 | $footnote = reset($this->footnotes_ordered); |
3384 | 3384 | $note_id = key($this->footnotes_ordered); |
3385 | 3385 | unset($this->footnotes_ordered[$note_id]); |
@@ -3405,13 +3405,13 @@ discard block |
||
3405 | 3405 | } |
3406 | 3406 | # Add backlink to last paragraph; create new paragraph if needed. |
3407 | 3407 | if (preg_match('{</p>$}', $footnote)) { |
3408 | - $footnote = substr($footnote, 0, - 4) . " $backlink</p>"; |
|
3408 | + $footnote = substr($footnote, 0, - 4)." $backlink</p>"; |
|
3409 | 3409 | } else { |
3410 | 3410 | $footnote .= "\n\n<p>$backlink</p>"; |
3411 | 3411 | } |
3412 | 3412 | |
3413 | 3413 | $text .= "<li id=\"fn:$note_id\">\n"; |
3414 | - $text .= $footnote . "\n"; |
|
3414 | + $text .= $footnote."\n"; |
|
3415 | 3415 | $text .= "</li>\n\n"; |
3416 | 3416 | } |
3417 | 3417 | |
@@ -3423,18 +3423,18 @@ discard block |
||
3423 | 3423 | |
3424 | 3424 | function _appendFootnotes_callback($matches) |
3425 | 3425 | { |
3426 | - $node_id = $this->fn_id_prefix . $matches[1]; |
|
3426 | + $node_id = $this->fn_id_prefix.$matches[1]; |
|
3427 | 3427 | |
3428 | 3428 | # Create footnote marker only if it has a corresponding footnote *and* |
3429 | 3429 | # the footnote hasn't been used by another marker. |
3430 | 3430 | if (isset($this->footnotes[$node_id])) { |
3431 | - $num =& $this->footnotes_numbers[$node_id]; |
|
3432 | - if (!isset($num)) { |
|
3431 | + $num = & $this->footnotes_numbers[$node_id]; |
|
3432 | + if ( ! isset($num)) { |
|
3433 | 3433 | # Transfer footnote content to the ordered list and give it its |
3434 | 3434 | # number |
3435 | 3435 | $this->footnotes_ordered[$node_id] = $this->footnotes[$node_id]; |
3436 | 3436 | $this->footnotes_ref_count[$node_id] = 1; |
3437 | - $num = $this->footnote_counter ++; |
|
3437 | + $num = $this->footnote_counter++; |
|
3438 | 3438 | $ref_count_mark = ''; |
3439 | 3439 | } else { |
3440 | 3440 | $ref_count_mark = $this->footnotes_ref_count[$node_id] += 1; |
@@ -3456,12 +3456,12 @@ discard block |
||
3456 | 3456 | $node_id = $this->encodeAttribute($node_id); |
3457 | 3457 | |
3458 | 3458 | return |
3459 | - "<sup id=\"fnref$ref_count_mark:$node_id\">" . |
|
3460 | - "<a href=\"#fn:$node_id\"$attr>$num</a>" . |
|
3459 | + "<sup id=\"fnref$ref_count_mark:$node_id\">". |
|
3460 | + "<a href=\"#fn:$node_id\"$attr>$num</a>". |
|
3461 | 3461 | "</sup>"; |
3462 | 3462 | } |
3463 | 3463 | |
3464 | - return "[^" . $matches[1] . "]"; |
|
3464 | + return "[^".$matches[1]."]"; |
|
3465 | 3465 | } |
3466 | 3466 | |
3467 | 3467 | ### Abbreviations ### |
@@ -3476,7 +3476,7 @@ discard block |
||
3476 | 3476 | # Link defs are in the form: [id]*: url "optional title" |
3477 | 3477 | $text = preg_replace_callback( |
3478 | 3478 | '{ |
3479 | - ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
3479 | + ^[ ]{0,' . $less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 |
|
3480 | 3480 | (.*) # text = $2 (no blank lines allowed) |
3481 | 3481 | }xm', |
3482 | 3482 | array(&$this, '_stripAbbreviations_callback'), |
@@ -3506,10 +3506,10 @@ discard block |
||
3506 | 3506 | // cannot use the /x modifier because abbr_word_re may |
3507 | 3507 | // contain significant spaces: |
3508 | 3508 | $text = preg_replace_callback( |
3509 | - '{' . |
|
3510 | - '(?<![\w\x1A])' . |
|
3511 | - '(?:' . $this->abbr_word_re . ')' . |
|
3512 | - '(?![\w\x1A])' . |
|
3509 | + '{'. |
|
3510 | + '(?<![\w\x1A])'. |
|
3511 | + '(?:'.$this->abbr_word_re.')'. |
|
3512 | + '(?![\w\x1A])'. |
|
3513 | 3513 | '}', |
3514 | 3514 | array(&$this, '_doAbbreviations_callback'), |
3515 | 3515 | $text |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param string $type Any key from _migration_paths, or {module_name} |
323 | 323 | * |
324 | - * @return bool|string |
|
324 | + * @return false|string |
|
325 | 325 | */ |
326 | 326 | public function get_latest($type='app') |
327 | 327 | { |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | /** |
466 | 466 | * Based on the 'type', determines the correct migration path. |
467 | 467 | * |
468 | - * @param $type |
|
468 | + * @param string $type |
|
469 | 469 | * @param bool $create |
470 | 470 | * |
471 | 471 | * @return null|string |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | // Add trailing slash if not set |
141 | 141 | foreach ($this->_migration_paths as $alias => $path) { |
142 | - $this->_migration_paths[$alias] = rtrim($this->_migration_paths[$alias], '/') . '/'; |
|
142 | + $this->_migration_paths[$alias] = rtrim($this->_migration_paths[$alias], '/').'/'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Load migration language |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return mixed TRUE if already latest, FALSE if failed, string if upgraded |
202 | 202 | */ |
203 | - public function version($type='all', $target_version) |
|
203 | + public function version($type = 'all', $target_version) |
|
204 | 204 | { |
205 | 205 | // Note: We use strings, so that timestamp versions work on 32-bit systems |
206 | 206 | $current_version = $this->get_version($type); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | // Run migrations that are inside the target range |
267 | 267 | if ( |
268 | - ($method === 'up' && $number > $current_version && $number <= $target_version) OR |
|
268 | + ($method === 'up' && $number > $current_version && $number <= $target_version) OR |
|
269 | 269 | ($method === 'down' && $number <= $current_version && $number > $target_version) |
270 | 270 | ) |
271 | 271 | { |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return mixed TRUE if already latest, FALSE if failed, string if upgraded |
307 | 307 | */ |
308 | - public function latest($type='app') |
|
308 | + public function latest($type = 'app') |
|
309 | 309 | { |
310 | 310 | $last_migration = $this->get_latest($type); |
311 | 311 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return bool|string |
325 | 325 | */ |
326 | - public function get_latest($type='app') |
|
326 | + public function get_latest($type = 'app') |
|
327 | 327 | { |
328 | 328 | $migrations = $this->find_migrations($type); |
329 | 329 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return array list of migration file paths sorted by version |
371 | 371 | */ |
372 | - public function find_migrations($type='app') |
|
372 | + public function find_migrations($type = 'app') |
|
373 | 373 | { |
374 | 374 | $migrations = array(); |
375 | 375 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return string Current migration version |
409 | 409 | */ |
410 | - public function get_version($type='app') |
|
410 | + public function get_version($type = 'app') |
|
411 | 411 | { |
412 | 412 | $row = $this->db->select('version') |
413 | 413 | ->where('alias', $type) |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | $prefix = str_pad($this->get_version() + 1, 3, '0', STR_PAD_LEFT); |
444 | 444 | } |
445 | 445 | |
446 | - return $prefix .'_'. ucfirst(strtolower($name)) .'.php'; |
|
446 | + return $prefix.'_'.ucfirst(strtolower($name)).'.php'; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | //-------------------------------------------------------------------- |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return null|string |
472 | 472 | */ |
473 | - public function determine_migration_path($type, $create=false) |
|
473 | + public function determine_migration_path($type, $create = false) |
|
474 | 474 | { |
475 | 475 | $type = strtolower($type); |
476 | 476 | |
@@ -489,17 +489,17 @@ discard block |
||
489 | 489 | |
490 | 490 | if (is_array($folders) && count($folders)) |
491 | 491 | { |
492 | - $path = $folders[0] . $module .'/migrations'; |
|
492 | + $path = $folders[0].$module.'/migrations'; |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
496 | - return rtrim($path, '/') .'/'; |
|
496 | + return rtrim($path, '/').'/'; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | // Look in our predefined groups. |
500 | - if (! empty($this->_migration_paths[$type])) |
|
500 | + if ( ! empty($this->_migration_paths[$type])) |
|
501 | 501 | { |
502 | - return rtrim($this->_migration_paths[$type], '/') .'/'; |
|
502 | + return rtrim($this->_migration_paths[$type], '/').'/'; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | return null; |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @param string $migration Migration reached |
562 | 562 | * @return mixed Outputs a report of the migration |
563 | 563 | */ |
564 | - protected function _update_version($type='all', $migration) |
|
564 | + protected function _update_version($type = 'all', $migration) |
|
565 | 565 | { |
566 | 566 | $this->db->where('alias', $type) |
567 | 567 | ->delete($this->_migration_table); |
@@ -292,7 +292,7 @@ |
||
292 | 292 | * @param $user_id |
293 | 293 | * @param $key |
294 | 294 | * |
295 | - * @return bool |
|
295 | + * @return false|null |
|
296 | 296 | */ |
297 | 297 | public function removeMetaFromUser($user_id, $key) |
298 | 298 | { |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | // If it's an update, we probably won't have the username/email |
138 | 138 | // so grab it so that we can use it. |
139 | - if (! empty($data[ $this->primary_key ])) |
|
139 | + if ( ! empty($data[$this->primary_key])) |
|
140 | 140 | { |
141 | - if (! isset($data[$field]) ) |
|
141 | + if ( ! isset($data[$field])) |
|
142 | 142 | { |
143 | - $value = $this->get_field( $data['id'], $field ); |
|
143 | + $value = $this->get_field($data['id'], $field); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | // However, if it's an insert, then we should have it, If we don't, leave. |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Still here? then create the hash based on the current realm. |
158 | - if (! empty($data['password']) ) |
|
158 | + if ( ! empty($data['password'])) |
|
159 | 159 | { |
160 | - $key = md5($value .':'. config_item('api.realm') .':'. $data['password']); |
|
160 | + $key = md5($value.':'.config_item('api.realm').':'.$data['password']); |
|
161 | 161 | $data['api_key'] = $key; |
162 | 162 | } |
163 | 163 | |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return object |
230 | 230 | */ |
231 | - public function saveMetaToUser($user_id, $key, $value=null) |
|
231 | + public function saveMetaToUser($user_id, $key, $value = null) |
|
232 | 232 | { |
233 | - if (! Events::trigger('beforeAddMetaToUser', [$user_id, $key])) |
|
233 | + if ( ! Events::trigger('beforeAddMetaToUser', [$user_id, $key])) |
|
234 | 234 | { |
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | |
238 | - $user_id = (int)$user_id; |
|
238 | + $user_id = (int) $user_id; |
|
239 | 239 | |
240 | 240 | // Does this key already exist? |
241 | - $test = $this->db->where([ 'user_id' => $user_id, 'meta_key' => $key ])->get('user_meta'); |
|
241 | + $test = $this->db->where(['user_id' => $user_id, 'meta_key' => $key])->get('user_meta'); |
|
242 | 242 | |
243 | 243 | // Doesn't exist, so insert it. |
244 | - if (! $test->num_rows()) |
|
244 | + if ( ! $test->num_rows()) |
|
245 | 245 | { |
246 | 246 | $data = [ |
247 | 247 | 'user_id' => $user_id, |
@@ -271,12 +271,12 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function getMetaItem($user_id, $key) |
273 | 273 | { |
274 | - $query = $this->db->where('user_id', (int)$user_id) |
|
274 | + $query = $this->db->where('user_id', (int) $user_id) |
|
275 | 275 | ->where('meta_key', $key) |
276 | 276 | ->select('meta_value') |
277 | 277 | ->get('user_meta'); |
278 | 278 | |
279 | - if (! $query->num_rows()) |
|
279 | + if ( ! $query->num_rows()) |
|
280 | 280 | { |
281 | 281 | return null; |
282 | 282 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function removeMetaFromUser($user_id, $key) |
298 | 298 | { |
299 | - if (! Events::trigger('beforeRemoveMetaFromUser', [$user_id, $key])) |
|
299 | + if ( ! Events::trigger('beforeRemoveMetaFromUser', [$user_id, $key])) |
|
300 | 300 | { |
301 | 301 | return false; |
302 | 302 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $this->db->where('meta_key', $key); |
311 | 311 | } |
312 | 312 | |
313 | - $this->db->where('user_id', (int)$user_id) |
|
313 | + $this->db->where('user_id', (int) $user_id) |
|
314 | 314 | ->delete('user_meta'); |
315 | 315 | } |
316 | 316 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | |
319 | 319 | public function getMetaForUser($user_id) |
320 | 320 | { |
321 | - $query = $this->db->where('user_id', (int)$user_id) |
|
321 | + $query = $this->db->where('user_id', (int) $user_id) |
|
322 | 322 | ->select('meta_key, meta_value') |
323 | 323 | ->get('user_meta'); |
324 | 324 | |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | |
329 | 329 | if (count($rows)) |
330 | 330 | { |
331 | - array_walk( $rows, function ( $row ) use ( &$meta ) |
|
331 | + array_walk($rows, function($row) use (&$meta) |
|
332 | 332 | { |
333 | - $meta[ $row->meta_key ] = $row->meta_value; |
|
333 | + $meta[$row->meta_key] = $row->meta_value; |
|
334 | 334 | } ); |
335 | 335 | } |
336 | 336 | |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | |
351 | 351 | if (is_object($data['fields'])) |
352 | 352 | { |
353 | - $data['fields']->meta = (object)$meta; |
|
353 | + $data['fields']->meta = (object) $meta; |
|
354 | 354 | } |
355 | 355 | else |
356 | 356 | { |
357 | - $data['fields']['meta']= $meta; |
|
357 | + $data['fields']['meta'] = $meta; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $data; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param string the name of the class |
108 | 108 | * @param mixed the optional parameters |
109 | 109 | * @param string an optional object name |
110 | - * @return void |
|
110 | + * @return null|HMVC_Loader |
|
111 | 111 | */ |
112 | 112 | public function library($library = '', $params = NULL, $object_name = NULL) { |
113 | 113 | if (is_array($library)) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string the name of the class |
148 | 148 | * @param string name for the model |
149 | 149 | * @param bool database connection |
150 | - * @return void |
|
150 | + * @return null|HMVC_Loader |
|
151 | 151 | */ |
152 | 152 | public function model($model, $name = '', $db_conn = FALSE) { |
153 | 153 | if (is_array($model)) { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param string |
233 | 233 | * @param bool |
234 | 234 | * @param bool |
235 | - * @return void |
|
235 | + * @return boolean|null |
|
236 | 236 | */ |
237 | 237 | public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { |
238 | 238 | // Detect module |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * This function loads the specified helper file. |
264 | 264 | * |
265 | 265 | * @param mixed |
266 | - * @return void |
|
266 | + * @return null|HMVC_Loader |
|
267 | 267 | */ |
268 | 268 | public function helper($helper = array()) { |
269 | 269 | if (is_array($helper)) { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @param array |
302 | 302 | * @param string |
303 | - * @return void |
|
303 | + * @return null|HMVC_Loader |
|
304 | 304 | */ |
305 | 305 | public function language($file = array(), $lang = '') { |
306 | 306 | if (is_array($file)) { |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * Searches a given module name. Returns the path if found, FALSE otherwise |
518 | 518 | * |
519 | 519 | * @param string $module |
520 | - * @return string|boolean |
|
520 | + * @return string|false |
|
521 | 521 | */ |
522 | 522 | private function find_module($module) { |
523 | 523 | $config = & $this->_ci_get_component('config'); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | */ |
31 | 31 | |
32 | -if (!defined("BASEPATH")) |
|
32 | +if ( ! defined("BASEPATH")) |
|
33 | 33 | exit("No direct script access allowed"); |
34 | 34 | |
35 | 35 | class HMVC_Loader extends CI_Loader { |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | public function controller($uri, $params = array(), $return = FALSE) { |
79 | 79 | // No valid module detected, add current module to uri |
80 | 80 | list($module) = $this->detect_module($uri); |
81 | - if (!isset($module)) { |
|
81 | + if ( ! isset($module)) { |
|
82 | 82 | $router = & $this->_ci_get_component('router'); |
83 | 83 | if ($router->module) { |
84 | 84 | $module = $router->module; |
85 | - $uri = $module . '/' . $uri; |
|
85 | + $uri = $module.'/'.$uri; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | // Allow application/views/* to override any module |
201 | 201 | // views for easier app customization. |
202 | - if (file_exists(APPPATH .'views/'. $view .'.php')) |
|
202 | + if (file_exists(APPPATH.'views/'.$view.'.php')) |
|
203 | 203 | { |
204 | 204 | return parent::view($view, $vars, $return); |
205 | 205 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $void = $this->widget($module.'/'.$widget); |
360 | 360 | |
361 | 361 | // Remove module if widget not found within it |
362 | - if (!$void) { |
|
362 | + if ( ! $void) { |
|
363 | 363 | $this->remove_module(); |
364 | 364 | } |
365 | 365 | |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | $method = isset($segments[1]) ? $segments[1] : "index"; |
441 | 441 | |
442 | 442 | // Controller not found |
443 | - if (!$class) { |
|
443 | + if ( ! $class) { |
|
444 | 444 | return; |
445 | 445 | } |
446 | 446 | |
447 | - if (!array_key_exists(strtolower($class), $this->_ci_controllers)) { |
|
447 | + if ( ! array_key_exists(strtolower($class), $this->_ci_controllers)) { |
|
448 | 448 | // Determine filepath |
449 | - $filepath = APPPATH . 'controllers/' . $router->fetch_directory() . $class . '.php'; |
|
449 | + $filepath = APPPATH.'controllers/'.$router->fetch_directory().$class.'.php'; |
|
450 | 450 | |
451 | 451 | // Load the controller file |
452 | 452 | if (file_exists($filepath)) { |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // Controller class not found, show 404 |
457 | - if (!class_exists($class)) { |
|
457 | + if ( ! class_exists($class)) { |
|
458 | 458 | show_404("{$class}/{$method}"); |
459 | 459 | } |
460 | 460 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | $controller = $this->_ci_controllers[strtolower($class)]; |
466 | 466 | |
467 | 467 | // Method does not exists |
468 | - if (!method_exists($controller, $method)) { |
|
468 | + if ( ! method_exists($controller, $method)) { |
|
469 | 469 | show_404("{$class}/{$method}"); |
470 | 470 | } |
471 | 471 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | |
525 | 525 | // Check all locations for this module |
526 | 526 | foreach ($config->item('modules_locations') as $location) { |
527 | - $path = $location . rtrim($module, '/') . '/'; |
|
527 | + $path = $location.rtrim($module, '/').'/'; |
|
528 | 528 | if (is_dir($path)) { |
529 | 529 | return $path; |
530 | 530 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * Copies the entire contents of a single folder |
22 | 22 | * into a source folder, recursively. |
23 | 23 | * |
24 | - * @param $source |
|
25 | - * @param $destination |
|
24 | + * @param string $source |
|
25 | + * @param string $destination |
|
26 | 26 | */ |
27 | 27 | public function copyFolder($source, $destination) |
28 | 28 | { |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * Deletes all files and folders, recursively, within $path, |
72 | 72 | * except for any files listed in the $leave_files array. |
73 | 73 | * |
74 | - * @param $path |
|
75 | - * @param array $leave_files |
|
74 | + * @param string $path |
|
75 | + * @param string[] $leave_files |
|
76 | 76 | */ |
77 | 77 | public function cleanFolder($path, $leave_files=[]) |
78 | 78 | { |
@@ -97,6 +97,10 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | + /** |
|
101 | + * @param string $source |
|
102 | + * @param string $destination |
|
103 | + */ |
|
100 | 104 | public function compressFolder($source, $destination, $include_dir=false) |
101 | 105 | { |
102 | 106 | if (! extension_loaded('zip') ) { |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | //-------------------------------------------------------------------- |
12 | 12 | |
13 | - public function __construct($ci=null) |
|
13 | + public function __construct($ci = null) |
|
14 | 14 | { |
15 | - $this->ci =& $ci; |
|
15 | + $this->ci = & $ci; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | //-------------------------------------------------------------------- |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | |
31 | 31 | @$this->ensureFolder($destination); |
32 | 32 | |
33 | - while (false !== ( $file = readdir($dir)) ) |
|
33 | + while (false !== ($file = readdir($dir))) |
|
34 | 34 | { |
35 | - if ( ! in_array($file, $this->ignore_files) ) |
|
35 | + if ( ! in_array($file, $this->ignore_files)) |
|
36 | 36 | { |
37 | - if ( is_dir($source .'/'. $file) ) |
|
37 | + if (is_dir($source.'/'.$file)) |
|
38 | 38 | { |
39 | - $this->copyFolder($source .'/'. $file, $destination .'/'. $file); |
|
39 | + $this->copyFolder($source.'/'.$file, $destination.'/'.$file); |
|
40 | 40 | } |
41 | 41 | else { |
42 | - copy($source .'/'. $file, $destination .'/'. $file); |
|
42 | + copy($source.'/'.$file, $destination.'/'.$file); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param $path |
75 | 75 | * @param array $leave_files |
76 | 76 | */ |
77 | - public function cleanFolder($path, $leave_files=[]) |
|
77 | + public function cleanFolder($path, $leave_files = []) |
|
78 | 78 | { |
79 | 79 | foreach (glob("{$path}/*") as $file) |
80 | 80 | { |
@@ -97,25 +97,25 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | - public function compressFolder($source, $destination, $include_dir=false) |
|
100 | + public function compressFolder($source, $destination, $include_dir = false) |
|
101 | 101 | { |
102 | - if (! extension_loaded('zip') ) { |
|
102 | + if ( ! extension_loaded('zip')) { |
|
103 | 103 | CLI::error('ZipArchive extension is required.'); |
104 | 104 | exit(1); |
105 | 105 | } |
106 | 106 | |
107 | - if (! file_exists($source)) { |
|
107 | + if ( ! file_exists($source)) { |
|
108 | 108 | CLI::error('Source folder not found for zipping.'); |
109 | 109 | exit(1); |
110 | 110 | } |
111 | 111 | |
112 | 112 | if (file_exists($destination)) |
113 | 113 | { |
114 | - unlink ($destination); |
|
114 | + unlink($destination); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $zip = new ZipArchive(); |
118 | - if (! $zip->open($destination, ZIPARCHIVE::CREATE)) |
|
118 | + if ( ! $zip->open($destination, ZIPARCHIVE::CREATE)) |
|
119 | 119 | { |
120 | 120 | CLI::error('Unknown error opening zip file.'); |
121 | 121 | exit(1); |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | |
130 | 130 | if ($include_dir) { |
131 | 131 | |
132 | - $arr = explode("/",$source); |
|
133 | - $maindir = $arr[count($arr)- 1]; |
|
132 | + $arr = explode("/", $source); |
|
133 | + $maindir = $arr[count($arr) - 1]; |
|
134 | 134 | |
135 | 135 | $source = ""; |
136 | - for ($i=0; $i < count($arr) - 1; $i++) { |
|
137 | - $source .= '/' . $arr[$i]; |
|
136 | + for ($i = 0; $i < count($arr) - 1; $i++) { |
|
137 | + $source .= '/'.$arr[$i]; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $source = substr($source, 1); |
@@ -147,18 +147,18 @@ discard block |
||
147 | 147 | $file = str_replace('\\', '/', $file); |
148 | 148 | |
149 | 149 | // Ignore "." and ".." folders |
150 | - if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..', '.DS_Store')) ) |
|
150 | + if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..', '.DS_Store'))) |
|
151 | 151 | continue; |
152 | 152 | |
153 | 153 | $file = realpath($file); |
154 | 154 | |
155 | 155 | if (is_dir($file) === true) |
156 | 156 | { |
157 | - $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); |
|
157 | + $zip->addEmptyDir(str_replace($source.'/', '', $file.'/')); |
|
158 | 158 | } |
159 | 159 | else if (is_file($file) === true) |
160 | 160 | { |
161 | - $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); |
|
161 | + $zip->addFromString(str_replace($source.'/', '', $file), file_get_contents($file)); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * Quickly creates boilerplate code for a new API resource. |
104 | 104 | * |
105 | 105 | * @param $segments |
106 | - * @param $quiet |
|
106 | + * @param boolean $quiet |
|
107 | 107 | */ |
108 | 108 | private function scaffold( $segments, $quiet ) |
109 | 109 | { |
@@ -220,6 +220,9 @@ discard block |
||
220 | 220 | |
221 | 221 | //-------------------------------------------------------------------- |
222 | 222 | |
223 | + /** |
|
224 | + * @param string $name |
|
225 | + */ |
|
223 | 226 | private function detectModel($name) |
224 | 227 | { |
225 | 228 | $model_name = ucfirst($name) .'_model.php'; |
@@ -242,8 +245,8 @@ discard block |
||
242 | 245 | /** |
243 | 246 | * Creates the new APIController - based resource with basic CRUD. |
244 | 247 | * |
245 | - * @param $single |
|
246 | - * @param $plural |
|
248 | + * @param string $single |
|
249 | + * @param string $plural |
|
247 | 250 | * @param $version |
248 | 251 | * |
249 | 252 | * @return $this |
@@ -271,8 +274,8 @@ discard block |
||
271 | 274 | /** |
272 | 275 | * Creates the language file to accompany the controller. |
273 | 276 | * |
274 | - * @param $single |
|
275 | - * @param $plural |
|
277 | + * @param string $single |
|
278 | + * @param string $plural |
|
276 | 279 | * @param $version |
277 | 280 | * |
278 | 281 | * @return $this |
@@ -297,8 +300,8 @@ discard block |
||
297 | 300 | * Creates the API Blueprint file for that resource in |
298 | 301 | * APPPATH/docs/api |
299 | 302 | * |
300 | - * @param $single |
|
301 | - * @param $plural |
|
303 | + * @param string $single |
|
304 | + * @param string $plural |
|
302 | 305 | * @param $version |
303 | 306 | * @param $model |
304 | 307 | * |
@@ -349,7 +352,7 @@ discard block |
||
349 | 352 | * Modifies the _toc.ini file (or creates) for the specified Blueprint docs. |
350 | 353 | * |
351 | 354 | * @param $plural |
352 | - * @param $version |
|
355 | + * @param string $version |
|
353 | 356 | * |
354 | 357 | * @return $this|bool |
355 | 358 | */ |
@@ -385,7 +388,7 @@ discard block |
||
385 | 388 | * Creates a generic representation of the object from the database |
386 | 389 | * table. |
387 | 390 | * |
388 | - * @param $model |
|
391 | + * @param string $model |
|
389 | 392 | * |
390 | 393 | * @return string |
391 | 394 | */ |
@@ -537,6 +540,10 @@ discard block |
||
537 | 540 | //-------------------------------------------------------------------- |
538 | 541 | |
539 | 542 | |
543 | + /** |
|
544 | + * @param string $tpl |
|
545 | + * @param string $name |
|
546 | + */ |
|
540 | 547 | private function makeMigration( $tpl, $name ) |
541 | 548 | { |
542 | 549 | // Create the migration |
@@ -561,7 +568,7 @@ discard block |
||
561 | 568 | /** |
562 | 569 | * Modifies the config/api.php file and sets the Auth type |
563 | 570 | * |
564 | - * @param $type |
|
571 | + * @param string $type |
|
565 | 572 | */ |
566 | 573 | private function setAuthType( $type ) |
567 | 574 | { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param array $segments |
57 | 57 | * @param bool $quiet |
58 | 58 | */ |
59 | - public function run($segments=[], $quiet=false) |
|
59 | + public function run($segments = [], $quiet = false) |
|
60 | 60 | { |
61 | 61 | // Show an index? |
62 | 62 | if (empty($segments[0])) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->scaffold($segments, $quiet); |
76 | 76 | break; |
77 | 77 | default: |
78 | - if (! $quiet) |
|
78 | + if ( ! $quiet) |
|
79 | 79 | { |
80 | 80 | CLI::write('Nothing to do.', 'green'); |
81 | 81 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | { |
90 | 90 | CLI::write("\nAvailable API Generators"); |
91 | 91 | |
92 | - CLI::write( CLI::color('install', 'yellow') .' install Creates migrations, alters config file for desired authentication' ); |
|
93 | - CLI::write( CLI::color('scaffold', 'yellow') .' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files' ); |
|
92 | + CLI::write(CLI::color('install', 'yellow').' install Creates migrations, alters config file for desired authentication'); |
|
93 | + CLI::write(CLI::color('scaffold', 'yellow').' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | //-------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param $segments |
106 | 106 | * @param $quiet |
107 | 107 | */ |
108 | - private function scaffold( $segments, $quiet ) |
|
108 | + private function scaffold($segments, $quiet) |
|
109 | 109 | { |
110 | 110 | $this->load->helper('inflector'); |
111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | if (empty($resource)) |
120 | 120 | { |
121 | - $resource = strtolower( CLI::prompt('Resource name') ); |
|
121 | + $resource = strtolower(CLI::prompt('Resource name')); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | // Resources should be plural, but we'll need a singular name also. |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | |
139 | 139 | if (empty($model)) |
140 | 140 | { |
141 | - $model = $this->detectModel( $resource_single ); |
|
141 | + $model = $this->detectModel($resource_single); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /* |
145 | 145 | * Start Building |
146 | 146 | */ |
147 | - $this->destination = APPPATH .'controllers/'; |
|
148 | - if (! empty($version)) |
|
147 | + $this->destination = APPPATH.'controllers/'; |
|
148 | + if ( ! empty($version)) |
|
149 | 149 | { |
150 | - $this->destination .= $version .'/'; |
|
150 | + $this->destination .= $version.'/'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Controller |
154 | - if (! $this->createController($resource_single, $resource_plural, $version) ) |
|
154 | + if ( ! $this->createController($resource_single, $resource_plural, $version)) |
|
155 | 155 | { |
156 | 156 | CLI::error('Unknown error creating Controller.'); |
157 | 157 | exit(1); |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Language Files |
161 | - if (! $this->createLanguage($resource_single, $resource_plural, $version, $model) ) |
|
161 | + if ( ! $this->createLanguage($resource_single, $resource_plural, $version, $model)) |
|
162 | 162 | { |
163 | 163 | CLI::error('Unknown error creating Language File.'); |
164 | 164 | exit(1); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // Blueprint File |
168 | 168 | if ($blueprint) |
169 | 169 | { |
170 | - if (! $this->createBlueprint($resource_single, $resource_plural, $version, $model) ) |
|
170 | + if ( ! $this->createBlueprint($resource_single, $resource_plural, $version, $model)) |
|
171 | 171 | { |
172 | 172 | CLI::error('Unknown error creating Blueprint file.'); |
173 | 173 | exit(1); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // Modify Routes |
178 | - if (! $this->addRoutes($resource_plural, $version) ) |
|
178 | + if ( ! $this->addRoutes($resource_plural, $version)) |
|
179 | 179 | { |
180 | 180 | CLI::error('Unknown error adding Routes.'); |
181 | 181 | exit(1); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | CLI::write("\nVersions are simply controller folders (i.e. controllers/v1/...)"); |
196 | 196 | CLI::write("(Enter 'na' for no version folder)"); |
197 | 197 | |
198 | - $version = strtolower( CLI::prompt('Version name', 'v1') ); |
|
198 | + $version = strtolower(CLI::prompt('Version name', 'v1')); |
|
199 | 199 | $version = $version == 'na' ? '' : $version; |
200 | 200 | |
201 | 201 | return $version; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | private function askBlueprint() |
212 | 212 | { |
213 | 213 | CLI::write("\nAPI Blueprint is a plain-text API documentation starter."); |
214 | - CLI::write("See: ". CLI::color('https://apiblueprint.org', 'light_blue')); |
|
214 | + CLI::write("See: ".CLI::color('https://apiblueprint.org', 'light_blue')); |
|
215 | 215 | |
216 | 216 | $make_blueprint = CLI::prompt('Create Blueprint file?', ['y', 'n']); |
217 | 217 | |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | |
223 | 223 | private function detectModel($name) |
224 | 224 | { |
225 | - $model_name = ucfirst($name) .'_model.php'; |
|
225 | + $model_name = ucfirst($name).'_model.php'; |
|
226 | 226 | |
227 | - if (! file_exists(APPPATH .'models/'. $model_name)) |
|
227 | + if ( ! file_exists(APPPATH.'models/'.$model_name)) |
|
228 | 228 | { |
229 | 229 | CLI::write("\nUnable to find model named: {$model_name}"); |
230 | 230 | $model_name = CLI::prompt('Model filename'); |
231 | 231 | } |
232 | 232 | else |
233 | 233 | { |
234 | - CLI::write("Using model: ". CLI::color($model_name, 'yellow') ); |
|
234 | + CLI::write("Using model: ".CLI::color($model_name, 'yellow')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $model_name; |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | * @internal param $name |
251 | 251 | * |
252 | 252 | */ |
253 | - private function createController( $single, $plural, $version ) |
|
253 | + private function createController($single, $plural, $version) |
|
254 | 254 | { |
255 | 255 | $data = [ |
256 | - 'today' => date( 'Y-m-d H:ia' ), |
|
257 | - 'model_name' => strtolower($single) .'_model', |
|
256 | + 'today' => date('Y-m-d H:ia'), |
|
257 | + 'model_name' => strtolower($single).'_model', |
|
258 | 258 | 'plural' => $plural, |
259 | 259 | 'single' => $single, |
260 | 260 | 'class_name' => ucfirst($plural), |
261 | 261 | 'version' => $version |
262 | 262 | ]; |
263 | 263 | |
264 | - $destination = $this->destination . ucfirst($plural) .'.php'; |
|
264 | + $destination = $this->destination.ucfirst($plural).'.php'; |
|
265 | 265 | |
266 | - return $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ); |
|
266 | + return $this->copyTemplate('controller', $destination, $data, $this->overwrite); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | //-------------------------------------------------------------------- |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return $this |
279 | 279 | */ |
280 | - private function createLanguage( $single, $plural, $version ) |
|
280 | + private function createLanguage($single, $plural, $version) |
|
281 | 281 | { |
282 | 282 | $data = [ |
283 | 283 | 'plural' => $plural, |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | 'uc_plural' => ucfirst($plural), |
287 | 287 | ]; |
288 | 288 | |
289 | - $destination = APPPATH ."language/english/api_{$plural}_lang.php"; |
|
289 | + $destination = APPPATH."language/english/api_{$plural}_lang.php"; |
|
290 | 290 | |
291 | - return $this->copyTemplate( 'lang', $destination, $data, $this->overwrite ); |
|
291 | + return $this->copyTemplate('lang', $destination, $data, $this->overwrite); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | //-------------------------------------------------------------------- |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | * @internal param $name |
307 | 307 | * |
308 | 308 | */ |
309 | - private function createBlueprint( $single, $plural, $version, $model ) |
|
309 | + private function createBlueprint($single, $plural, $version, $model) |
|
310 | 310 | { |
311 | 311 | $version = rtrim($version, '/'); |
312 | - if (! empty($version)) |
|
312 | + if ( ! empty($version)) |
|
313 | 313 | { |
314 | 314 | $version .= '/'; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Load the model so we can use the correct table to use |
318 | - $model = strtolower( str_replace('.php', '', $model) ); |
|
319 | - $this->load->model( $model, $model, true ); |
|
318 | + $model = strtolower(str_replace('.php', '', $model)); |
|
319 | + $this->load->model($model, $model, true); |
|
320 | 320 | |
321 | 321 | $obj = $this->formatObject($model); |
322 | 322 | |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | 'formatted' => $obj |
332 | 332 | ]; |
333 | 333 | |
334 | - $destination = APPPATH .'docs/api/'. $version . $plural .'.md'; |
|
334 | + $destination = APPPATH.'docs/api/'.$version.$plural.'.md'; |
|
335 | 335 | |
336 | - $success = $this->copyTemplate( 'blueprint', $destination, $data, $this->overwrite ); |
|
336 | + $success = $this->copyTemplate('blueprint', $destination, $data, $this->overwrite); |
|
337 | 337 | |
338 | - if (! $this->updateTOC($plural, $version)) |
|
338 | + if ( ! $this->updateTOC($plural, $version)) |
|
339 | 339 | { |
340 | 340 | CLI::write("\tUnable to modify the toc file.", 'light_red'); |
341 | 341 | } |
@@ -353,21 +353,21 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return $this|bool |
355 | 355 | */ |
356 | - private function updateTOC( $plural, $version ) |
|
356 | + private function updateTOC($plural, $version) |
|
357 | 357 | { |
358 | - $path = APPPATH .'docs/_toc.ini'; |
|
358 | + $path = APPPATH.'docs/_toc.ini'; |
|
359 | 359 | |
360 | 360 | // We need a TOC file to exist if we're going to modify it silly. |
361 | - if (! file_exists($path)) |
|
361 | + if ( ! file_exists($path)) |
|
362 | 362 | { |
363 | - if (! $this->copyTemplate('toc', $path)) |
|
363 | + if ( ! $this->copyTemplate('toc', $path)) |
|
364 | 364 | { |
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | 369 | $version = rtrim($version, '/ '); |
370 | - if (! empty($version)) |
|
370 | + if ( ! empty($version)) |
|
371 | 371 | { |
372 | 372 | $version .= '/'; |
373 | 373 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return string |
391 | 391 | */ |
392 | - private function formatObject( $model ) |
|
392 | + private function formatObject($model) |
|
393 | 393 | { |
394 | 394 | $fields = $this->db->field_data($this->$model->table_name); |
395 | 395 | |
@@ -448,14 +448,14 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return $this |
450 | 450 | */ |
451 | - private function addRoutes( $plural, $version ) |
|
451 | + private function addRoutes($plural, $version) |
|
452 | 452 | { |
453 | - $path = APPPATH .'config/routes.php'; |
|
453 | + $path = APPPATH.'config/routes.php'; |
|
454 | 454 | |
455 | 455 | $version = rtrim($version, ', '); |
456 | - if (! empty($version)) |
|
456 | + if ( ! empty($version)) |
|
457 | 457 | { |
458 | - $version .='/'; |
|
458 | + $version .= '/'; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | $content = "\$routes->resources('{$version}{$plural}');\n"; |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | */ |
477 | 477 | private function install( ) |
478 | 478 | { |
479 | - CLI::write("Available Auth Types: ". CLI::color('basic, digest, none', 'yellow') ); |
|
479 | + CLI::write("Available Auth Types: ".CLI::color('basic, digest, none', 'yellow')); |
|
480 | 480 | |
481 | - $this->auth_type = trim( CLI::prompt('Auth type') ); |
|
481 | + $this->auth_type = trim(CLI::prompt('Auth type')); |
|
482 | 482 | |
483 | 483 | switch ($this->auth_type) |
484 | 484 | { |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | |
532 | 532 | // Update the config setting |
533 | 533 | $content = "config['api.enable_logging'] = true;"; |
534 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"] ); |
|
534 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"]); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | //-------------------------------------------------------------------- |
538 | 538 | |
539 | 539 | |
540 | - private function makeMigration( $tpl, $name ) |
|
540 | + private function makeMigration($tpl, $name) |
|
541 | 541 | { |
542 | 542 | // Create the migration |
543 | 543 | $this->load->library('migration'); |
544 | 544 | |
545 | 545 | $destination = $this->migration->determine_migration_path('app', true); |
546 | 546 | |
547 | - $file = $this->migration->make_name( $name ); |
|
547 | + $file = $this->migration->make_name($name); |
|
548 | 548 | |
549 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
549 | + $destination = rtrim($destination, '/').'/'.$file; |
|
550 | 550 | |
551 | - if (! $this->copyTemplate( $tpl, $destination, [], true) ) |
|
551 | + if ( ! $this->copyTemplate($tpl, $destination, [], true)) |
|
552 | 552 | { |
553 | 553 | CLI::error('Error creating migration file.'); |
554 | 554 | } |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param $type |
565 | 565 | */ |
566 | - private function setAuthType( $type ) |
|
566 | + private function setAuthType($type) |
|
567 | 567 | { |
568 | 568 | $content = "config['api.auth_type'] = '{$type}';"; |
569 | 569 | |
570 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"] ); |
|
570 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"]); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | //-------------------------------------------------------------------- |
@@ -97,6 +97,9 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | + /** |
|
101 | + * @param string $name |
|
102 | + */ |
|
100 | 103 | protected function quietSetOptions( $name ) |
101 | 104 | { |
102 | 105 | $options = CLI::getOptions(); |
@@ -120,6 +123,9 @@ discard block |
||
120 | 123 | |
121 | 124 | //-------------------------------------------------------------------- |
122 | 125 | |
126 | + /** |
|
127 | + * @param string $name |
|
128 | + */ |
|
123 | 129 | protected function collectOptions( $name ) |
124 | 130 | { |
125 | 131 | $options = CLI::getOptions(); |
@@ -159,6 +165,7 @@ discard block |
||
159 | 165 | |
160 | 166 | /** |
161 | 167 | * Generates the standard views for our CRUD methods. |
168 | + * @param string $name |
|
162 | 169 | */ |
163 | 170 | protected function createViews( $name ) |
164 | 171 | { |
@@ -47,49 +47,49 @@ discard block |
||
47 | 47 | |
48 | 48 | //-------------------------------------------------------------------- |
49 | 49 | |
50 | - public function run( $segments = [ ], $quiet = FALSE ) |
|
50 | + public function run($segments = [], $quiet = FALSE) |
|
51 | 51 | { |
52 | - $name = array_shift( $segments ); |
|
52 | + $name = array_shift($segments); |
|
53 | 53 | |
54 | - if ( empty( $name ) ) |
|
54 | + if (empty($name)) |
|
55 | 55 | { |
56 | - $name = CLI::prompt( 'Controller name' ); |
|
56 | + $name = CLI::prompt('Controller name'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Format to CI Standards |
60 | - $name = ucfirst( $name ); |
|
60 | + $name = ucfirst($name); |
|
61 | 61 | |
62 | - if ( $quiet === FALSE ) |
|
62 | + if ($quiet === FALSE) |
|
63 | 63 | { |
64 | - $this->collectOptions( $name ); |
|
64 | + $this->collectOptions($name); |
|
65 | 65 | } |
66 | 66 | else |
67 | 67 | { |
68 | - $this->quietSetOptions( $name ); |
|
68 | + $this->quietSetOptions($name); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $data = [ |
72 | 72 | 'controller_name' => $name, |
73 | - 'today' => date( 'Y-m-d H:ia' ) |
|
73 | + 'today' => date('Y-m-d H:ia') |
|
74 | 74 | ]; |
75 | 75 | |
76 | - $data = array_merge( $data, $this->options ); |
|
76 | + $data = array_merge($data, $this->options); |
|
77 | 77 | |
78 | 78 | if ($data['themed'] == 'y' || $data['themed'] === true) |
79 | 79 | { |
80 | 80 | $data['base_class'] = 'ThemedController'; |
81 | 81 | } |
82 | 82 | |
83 | - $destination = $this->determineOutputPath( 'controllers' ) . $name . '.php'; |
|
83 | + $destination = $this->determineOutputPath('controllers').$name.'.php'; |
|
84 | 84 | |
85 | - if ( ! $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ) ) |
|
85 | + if ( ! $this->copyTemplate('controller', $destination, $data, $this->overwrite)) |
|
86 | 86 | { |
87 | - CLI::error( 'Error creating new files' ); |
|
87 | + CLI::error('Error creating new files'); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( CLI::option( 'create_views' ) && $this->options['themed'] == 'y' ) |
|
90 | + if (CLI::option('create_views') && $this->options['themed'] == 'y') |
|
91 | 91 | { |
92 | - $this->createViews( $name ); |
|
92 | + $this->createViews($name); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return TRUE; |
@@ -97,20 +97,20 @@ discard block |
||
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
99 | 99 | |
100 | - protected function quietSetOptions( $name ) |
|
100 | + protected function quietSetOptions($name) |
|
101 | 101 | { |
102 | 102 | $options = CLI::getOptions(); |
103 | 103 | |
104 | - if ( ! empty( $options['model'] ) ) |
|
104 | + if ( ! empty($options['model'])) |
|
105 | 105 | { |
106 | 106 | $this->options['model'] = $options['model']; |
107 | 107 | |
108 | 108 | // Format per CI |
109 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
109 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
110 | 110 | { |
111 | 111 | $this->options['model'] .= '_model'; |
112 | 112 | } |
113 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
113 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
114 | 114 | |
115 | 115 | $this->options['themed'] = 'y'; |
116 | 116 | } |
@@ -120,36 +120,34 @@ discard block |
||
120 | 120 | |
121 | 121 | //-------------------------------------------------------------------- |
122 | 122 | |
123 | - protected function collectOptions( $name ) |
|
123 | + protected function collectOptions($name) |
|
124 | 124 | { |
125 | 125 | $options = CLI::getOptions(); |
126 | 126 | |
127 | 127 | // Model? |
128 | - $this->options['model'] = empty( $options['model'] ) ? |
|
129 | - CLI::prompt( 'Model Name? (empty is fine)' ) : |
|
130 | - $options['model']; |
|
128 | + $this->options['model'] = empty($options['model']) ? |
|
129 | + CLI::prompt('Model Name? (empty is fine)') : $options['model']; |
|
131 | 130 | |
132 | 131 | // Format per CI |
133 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
132 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
134 | 133 | { |
135 | 134 | $this->options['model'] .= '_model'; |
136 | 135 | } |
137 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
136 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
138 | 137 | |
139 | 138 | // If we're using a model, then force the use of a themed controller. |
140 | - if ( ! empty( $this->options['model'] ) ) |
|
139 | + if ( ! empty($this->options['model'])) |
|
141 | 140 | { |
142 | 141 | $options['themed'] = 'y'; |
143 | 142 | } |
144 | 143 | |
145 | 144 | // Themed Controller? |
146 | - $this->options['themed'] = empty( $options['themed'] ) ? |
|
147 | - CLI::prompt( 'Is a Themed Controller?', [ 'y', 'n' ] ) : |
|
148 | - $options['themed']; |
|
145 | + $this->options['themed'] = empty($options['themed']) ? |
|
146 | + CLI::prompt('Is a Themed Controller?', ['y', 'n']) : $options['themed']; |
|
149 | 147 | |
150 | 148 | $this->options['themed'] = $this->options['themed'] == 'y' ? TRUE : FALSE; |
151 | 149 | |
152 | - if ( $this->options['themed'] ) |
|
150 | + if ($this->options['themed']) |
|
153 | 151 | { |
154 | 152 | $this->options['base_class'] = 'ThemedController'; |
155 | 153 | } |
@@ -160,35 +158,35 @@ discard block |
||
160 | 158 | /** |
161 | 159 | * Generates the standard views for our CRUD methods. |
162 | 160 | */ |
163 | - protected function createViews( $name ) |
|
161 | + protected function createViews($name) |
|
164 | 162 | { |
165 | - $this->load->helper( 'inflector' ); |
|
163 | + $this->load->helper('inflector'); |
|
166 | 164 | |
167 | 165 | $data = [ |
168 | 166 | 'name' => $name, |
169 | 167 | 'lower_name' => strtolower($name), |
170 | - 'single_name' => singular( $name ), |
|
171 | - 'plural_name' => plural( $name ), |
|
168 | + 'single_name' => singular($name), |
|
169 | + 'plural_name' => plural($name), |
|
172 | 170 | 'fields' => $this->prepareFields() |
173 | 171 | ]; |
174 | 172 | |
175 | - $subfolder = empty( $this->module ) ? '/' . strtolower($name) : '/'. $data['lower_name']; |
|
173 | + $subfolder = empty($this->module) ? '/'.strtolower($name) : '/'.$data['lower_name']; |
|
176 | 174 | |
177 | 175 | // Index |
178 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'index.php'; |
|
179 | - $this->copyTemplate( 'view_index', $destination, $data, $this->overwrite ); |
|
176 | + $destination = $this->determineOutputPath('views'.$subfolder).'index.php'; |
|
177 | + $this->copyTemplate('view_index', $destination, $data, $this->overwrite); |
|
180 | 178 | |
181 | 179 | // Create |
182 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'create.php'; |
|
183 | - $this->copyTemplate( 'view_create', $destination, $data, $this->overwrite ); |
|
180 | + $destination = $this->determineOutputPath('views'.$subfolder).'create.php'; |
|
181 | + $this->copyTemplate('view_create', $destination, $data, $this->overwrite); |
|
184 | 182 | |
185 | 183 | // Show |
186 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'show.php'; |
|
187 | - $this->copyTemplate( 'view_show', $destination, $data, $this->overwrite ); |
|
184 | + $destination = $this->determineOutputPath('views'.$subfolder).'show.php'; |
|
185 | + $this->copyTemplate('view_show', $destination, $data, $this->overwrite); |
|
188 | 186 | |
189 | 187 | // Index |
190 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'update.php'; |
|
191 | - $this->copyTemplate( 'view_update', $destination, $data, $this->overwrite ); |
|
188 | + $destination = $this->determineOutputPath('views'.$subfolder).'update.php'; |
|
189 | + $this->copyTemplate('view_update', $destination, $data, $this->overwrite); |
|
192 | 190 | } |
193 | 191 | |
194 | 192 | //-------------------------------------------------------------------- |
@@ -199,14 +197,14 @@ discard block |
||
199 | 197 | */ |
200 | 198 | protected function prepareFields() |
201 | 199 | { |
202 | - $fields = CLI::option( 'fields' ); |
|
200 | + $fields = CLI::option('fields'); |
|
203 | 201 | |
204 | - if ( empty( $fields ) ) |
|
202 | + if (empty($fields)) |
|
205 | 203 | { |
206 | 204 | // If we have a model, we can get our fields from there |
207 | - if (! empty($this->options['model'])) |
|
205 | + if ( ! empty($this->options['model'])) |
|
208 | 206 | { |
209 | - $fields = $this->getFieldsFromModel( $this->options['model'] ); |
|
207 | + $fields = $this->getFieldsFromModel($this->options['model']); |
|
210 | 208 | |
211 | 209 | if (empty($fields)) |
212 | 210 | { |
@@ -219,15 +217,15 @@ discard block |
||
219 | 217 | } |
220 | 218 | } |
221 | 219 | |
222 | - $fields = explode( ' ', $fields ); |
|
220 | + $fields = explode(' ', $fields); |
|
223 | 221 | |
224 | - $new_fields = [ ]; |
|
222 | + $new_fields = []; |
|
225 | 223 | |
226 | - foreach ( $fields as $field ) |
|
224 | + foreach ($fields as $field) |
|
227 | 225 | { |
228 | - $pop = [ NULL, NULL, NULL ]; |
|
229 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
230 | - $type = strtolower( $type ); |
|
226 | + $pop = [NULL, NULL, NULL]; |
|
227 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
228 | + $type = strtolower($type); |
|
231 | 229 | |
232 | 230 | // Ignore list |
233 | 231 | if (in_array($field, ['created_on', 'modified_on'])) |
@@ -277,16 +275,16 @@ discard block |
||
277 | 275 | |
278 | 276 | //-------------------------------------------------------------------- |
279 | 277 | |
280 | - private function getFieldsFromModel( $model ) |
|
278 | + private function getFieldsFromModel($model) |
|
281 | 279 | { |
282 | 280 | $this->load->model($model); |
283 | 281 | |
284 | - if (! $this->db->table_exists( $this->$model->table() )) |
|
282 | + if ( ! $this->db->table_exists($this->$model->table())) |
|
285 | 283 | { |
286 | 284 | return ''; |
287 | 285 | } |
288 | 286 | |
289 | - $fields = $this->db->field_data( $this->$model->table() ); |
|
287 | + $fields = $this->db->field_data($this->$model->table()); |
|
290 | 288 | |
291 | 289 | $return = ''; |
292 | 290 | |
@@ -294,14 +292,14 @@ discard block |
||
294 | 292 | // it would have been passed on the CLI |
295 | 293 | foreach ($fields as $field) |
296 | 294 | { |
297 | - $temp = $field->name .':'. $field->type; |
|
295 | + $temp = $field->name.':'.$field->type; |
|
298 | 296 | |
299 | - if (! empty($field->max_length)) |
|
297 | + if ( ! empty($field->max_length)) |
|
300 | 298 | { |
301 | - $temp .= ':'. $field->max_length; |
|
299 | + $temp .= ':'.$field->max_length; |
|
302 | 300 | } |
303 | 301 | |
304 | - $return .= ' '. $temp; |
|
302 | + $return .= ' '.$temp; |
|
305 | 303 | } |
306 | 304 | |
307 | 305 | return $return; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * 'create_user_table' action = 'create', table = 'user' |
160 | 160 | * 'add_name_to_user_table action = 'add', table = 'user' |
161 | 161 | * |
162 | - * @param $name |
|
162 | + * @param string $name |
|
163 | 163 | */ |
164 | 164 | public function detectAction($name) |
165 | 165 | { |
@@ -199,6 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | //-------------------------------------------------------------------- |
201 | 201 | |
202 | + /** |
|
203 | + * @param string $name |
|
204 | + */ |
|
202 | 205 | public function collectOptions($name, $quiet=false) |
203 | 206 | { |
204 | 207 | $options = CLI::getOptions(); |
@@ -308,7 +311,7 @@ discard block |
||
308 | 311 | * Reads the fields from an existing table and fills out our |
309 | 312 | * $fields array and $primary key information. |
310 | 313 | * |
311 | - * @param $table |
|
314 | + * @param string $table |
|
312 | 315 | */ |
313 | 316 | protected function readTable($table) |
314 | 317 | { |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | |
93 | 93 | //-------------------------------------------------------------------- |
94 | 94 | |
95 | - public function run($segments=[], $quiet=false) |
|
95 | + public function run($segments = [], $quiet = false) |
|
96 | 96 | { |
97 | - $name = array_shift( $segments ); |
|
97 | + $name = array_shift($segments); |
|
98 | 98 | |
99 | - if ( empty( $name ) ) |
|
99 | + if (empty($name)) |
|
100 | 100 | { |
101 | - $name = CLI::prompt( 'Migration name' ); |
|
101 | + $name = CLI::prompt('Migration name'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Format to CI Standards |
105 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
105 | + $name = str_replace('.php', '', strtolower($name)); |
|
106 | 106 | |
107 | 107 | $this->detectAction($name); |
108 | 108 | |
109 | - $this->collectOptions( $name, $quiet ); |
|
109 | + $this->collectOptions($name, $quiet); |
|
110 | 110 | |
111 | 111 | $data = [ |
112 | 112 | 'name' => $name, |
113 | 113 | 'clean_name' => ucwords(str_replace('_', ' ', $name)), |
114 | - 'today' => date( 'Y-m-d H:ia' ), |
|
115 | - 'fields' => trim( $this->stringify( $this->fields ), ', '), |
|
114 | + 'today' => date('Y-m-d H:ia'), |
|
115 | + 'fields' => trim($this->stringify($this->fields), ', '), |
|
116 | 116 | 'raw_fields' => $this->fields, |
117 | 117 | 'action' => $this->action, |
118 | 118 | 'table' => $this->table, |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | 'column' => $this->column |
121 | 121 | ]; |
122 | 122 | |
123 | - if (! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
123 | + if ( ! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
124 | 124 | { |
125 | - $data['column_string'] = trim( $this->stringify($this->fields[$this->column]), ', '); |
|
125 | + $data['column_string'] = trim($this->stringify($this->fields[$this->column]), ', '); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $this->load->library('migration'); |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | // todo Allow different migration "types" |
131 | 131 | $type = 'app'; |
132 | 132 | |
133 | - if (! empty($this->module)) |
|
133 | + if ( ! empty($this->module)) |
|
134 | 134 | { |
135 | - $type = 'mod:'. $this->module; |
|
135 | + $type = 'mod:'.$this->module; |
|
136 | 136 | } |
137 | 137 | $destination = $this->migration->determine_migration_path($type, true); |
138 | 138 | |
139 | 139 | $file = $this->migration->make_name($name); |
140 | 140 | |
141 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
141 | + $destination = rtrim($destination, '/').'/'.$file; |
|
142 | 142 | |
143 | - if (! $this->copyTemplate( 'migration', $destination, $data, true) ) |
|
143 | + if ( ! $this->copyTemplate('migration', $destination, $data, true)) |
|
144 | 144 | { |
145 | 145 | CLI::error('Error creating seed file.'); |
146 | 146 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $action = $this->actionMap[$action]; |
174 | 174 | } |
175 | 175 | |
176 | - if (! in_array($action, $this->allowedActions)) |
|
176 | + if ( ! in_array($action, $this->allowedActions)) |
|
177 | 177 | { |
178 | 178 | return; |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | // The name of the table is assumed to be the one |
189 | 189 | // prior to the $index found. |
190 | - $this->table = plural( implode('_', array_slice($segments, 0, $index) ) ); |
|
190 | + $this->table = plural(implode('_', array_slice($segments, 0, $index))); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // Are we referencing a column? |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | |
200 | 200 | //-------------------------------------------------------------------- |
201 | 201 | |
202 | - public function collectOptions($name, $quiet=false) |
|
202 | + public function collectOptions($name, $quiet = false) |
|
203 | 203 | { |
204 | 204 | $options = CLI::getOptions(); |
205 | 205 | |
206 | 206 | // Use existing db table? |
207 | - if (array_key_exists('fromdb', $options) ) |
|
207 | + if (array_key_exists('fromdb', $options)) |
|
208 | 208 | { |
209 | 209 | $this->readTable($this->table); |
210 | 210 | } |
@@ -217,10 +217,9 @@ discard block |
||
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | - $fields = empty( $fields ) ? |
|
221 | - CLI::prompt( 'Fields? (name:type)' ) : |
|
222 | - $options['fields']; |
|
223 | - $this->fields = $this->parseFields( $fields ); |
|
220 | + $fields = empty($fields) ? |
|
221 | + CLI::prompt('Fields? (name:type)') : $options['fields']; |
|
222 | + $this->fields = $this->parseFields($fields); |
|
224 | 223 | } |
225 | 224 | } |
226 | 225 | |
@@ -244,7 +243,7 @@ discard block |
||
244 | 243 | $fields = []; |
245 | 244 | $segments = explode(' ', $str); |
246 | 245 | |
247 | - if (! count($segments)) |
|
246 | + if ( ! count($segments)) |
|
248 | 247 | { |
249 | 248 | return $fields; |
250 | 249 | } |
@@ -252,7 +251,7 @@ discard block |
||
252 | 251 | foreach ($segments as $segment) |
253 | 252 | { |
254 | 253 | $pop = [null, null, null]; |
255 | - list($field, $type, $size) = array_merge( explode(':', $segment), $pop); |
|
254 | + list($field, $type, $size) = array_merge(explode(':', $segment), $pop); |
|
256 | 255 | $type = strtolower($type); |
257 | 256 | |
258 | 257 | // Is type one of our convenience mapped items? |
@@ -261,7 +260,7 @@ discard block |
||
261 | 260 | $type = $this->map[$type]; |
262 | 261 | } |
263 | 262 | |
264 | - $f = [ 'type' => $type ]; |
|
263 | + $f = ['type' => $type]; |
|
265 | 264 | |
266 | 265 | // Creating a primary key? |
267 | 266 | if ($type == 'id') |
@@ -275,9 +274,9 @@ discard block |
||
275 | 274 | } |
276 | 275 | |
277 | 276 | // Constraint? |
278 | - if (! empty($size)) |
|
277 | + if ( ! empty($size)) |
|
279 | 278 | { |
280 | - $f['constraint'] = (int)$size; |
|
279 | + $f['constraint'] = (int) $size; |
|
281 | 280 | } |
282 | 281 | else if (array_key_exists($type, $this->defaultSizes)) |
283 | 282 | { |
@@ -319,7 +318,7 @@ discard block |
||
319 | 318 | } |
320 | 319 | |
321 | 320 | // Table exists? |
322 | - if (! $this->db->table_exists($table)) |
|
321 | + if ( ! $this->db->table_exists($table)) |
|
323 | 322 | { |
324 | 323 | return false; |
325 | 324 | } |
@@ -327,7 +326,7 @@ discard block |
||
327 | 326 | $fields = $this->db->field_data($table); |
328 | 327 | |
329 | 328 | // Any fields? |
330 | - if (! is_array($fields) || ! count($fields)) |
|
329 | + if ( ! is_array($fields) || ! count($fields)) |
|
331 | 330 | { |
332 | 331 | return false; |
333 | 332 | } |
@@ -336,30 +335,30 @@ discard block |
||
336 | 335 | |
337 | 336 | foreach ($fields as $field) |
338 | 337 | { |
339 | - $f = [ 'type' => $field->type ]; |
|
338 | + $f = ['type' => $field->type]; |
|
340 | 339 | |
341 | 340 | // Constraint |
342 | - if (! empty($field->max_length)) |
|
341 | + if ( ! empty($field->max_length)) |
|
343 | 342 | { |
344 | 343 | $f['constraint'] = $field->max_length; |
345 | 344 | } |
346 | 345 | else if (array_key_exists($field->type, $this->defaultSizes)) |
347 | 346 | { |
348 | - $f['constraint'] = $this->defaultSizes[ $field->type ]; |
|
347 | + $f['constraint'] = $this->defaultSizes[$field->type]; |
|
349 | 348 | } |
350 | 349 | |
351 | 350 | // Default |
352 | - if (! empty($field->default)) $f['default'] = $field->default; |
|
351 | + if ( ! empty($field->default)) $f['default'] = $field->default; |
|
353 | 352 | |
354 | 353 | // Primary Key? |
355 | - if (! empty($field->primary_key) && $field->primary_key == 1) |
|
354 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
356 | 355 | { |
357 | 356 | $this->primary_key = $field->name; |
358 | 357 | $f['auto_increment'] = true; |
359 | 358 | $f['unsigned'] = true; |
360 | 359 | } |
361 | 360 | |
362 | - $new_fields[ $field->name ] = $f; |
|
361 | + $new_fields[$field->name] = $f; |
|
363 | 362 | } |
364 | 363 | |
365 | 364 | $this->fields = $new_fields; |
@@ -107,6 +107,10 @@ discard block |
||
107 | 107 | /* |
108 | 108 | * Customizes our settings |
109 | 109 | */ |
110 | + |
|
111 | + /** |
|
112 | + * @param string $model_name |
|
113 | + */ |
|
110 | 114 | protected function collectOptions( $model_name, $options=[] ) |
111 | 115 | { |
112 | 116 | $this->load->helper( 'inflector' ); |
@@ -180,6 +184,9 @@ discard block |
||
180 | 184 | |
181 | 185 | //-------------------------------------------------------------------- |
182 | 186 | |
187 | + /** |
|
188 | + * @param string $model_name |
|
189 | + */ |
|
183 | 190 | protected function quietSetOptions( $model_name, $options=[] ) |
184 | 191 | { |
185 | 192 | $this->load->helper( 'inflector' ); |
@@ -56,47 +56,47 @@ discard block |
||
56 | 56 | |
57 | 57 | //-------------------------------------------------------------------- |
58 | 58 | |
59 | - public function run( $segments = [ ], $quiet = false ) |
|
59 | + public function run($segments = [], $quiet = false) |
|
60 | 60 | { |
61 | - $name = array_shift( $segments ); |
|
61 | + $name = array_shift($segments); |
|
62 | 62 | |
63 | 63 | $options = CLI::getOptions(); |
64 | 64 | |
65 | - $this->options['table_name'] = array_shift( $segments ); |
|
65 | + $this->options['table_name'] = array_shift($segments); |
|
66 | 66 | |
67 | - if ( empty( $name ) ) |
|
67 | + if (empty($name)) |
|
68 | 68 | { |
69 | - $name = CLI::prompt( 'Model name' ); |
|
69 | + $name = CLI::prompt('Model name'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Format to CI Standards |
73 | - if ( substr( $name, - 6 ) !== '_model' ) |
|
73 | + if (substr($name, - 6) !== '_model') |
|
74 | 74 | { |
75 | 75 | $name .= '_model'; |
76 | 76 | } |
77 | - $name = ucfirst( $name ); |
|
77 | + $name = ucfirst($name); |
|
78 | 78 | |
79 | - if ( $quiet === false ) |
|
79 | + if ($quiet === false) |
|
80 | 80 | { |
81 | - $this->collectOptions( $name, $options ); |
|
81 | + $this->collectOptions($name, $options); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - $this->quietSetOptions( $name, $options ); |
|
85 | + $this->quietSetOptions($name, $options); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $data = [ |
89 | 89 | 'model_name' => $name, |
90 | - 'today' => date( 'Y-m-d H:ia' ) |
|
90 | + 'today' => date('Y-m-d H:ia') |
|
91 | 91 | ]; |
92 | 92 | |
93 | - $data = array_merge( $data, $this->options ); |
|
93 | + $data = array_merge($data, $this->options); |
|
94 | 94 | |
95 | - $destination = $this->determineOutputPath( 'models' ) . $name . '.php'; |
|
95 | + $destination = $this->determineOutputPath('models').$name.'.php'; |
|
96 | 96 | |
97 | - if ( ! $this->copyTemplate( 'model', $destination, $data, $this->overwrite ) ) |
|
97 | + if ( ! $this->copyTemplate('model', $destination, $data, $this->overwrite)) |
|
98 | 98 | { |
99 | - CLI::error( 'Error creating new files' ); |
|
99 | + CLI::error('Error creating new files'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return TRUE; |
@@ -107,70 +107,67 @@ discard block |
||
107 | 107 | /* |
108 | 108 | * Customizes our settings |
109 | 109 | */ |
110 | - protected function collectOptions( $model_name, $options=[] ) |
|
110 | + protected function collectOptions($model_name, $options = []) |
|
111 | 111 | { |
112 | - $this->load->helper( 'inflector' ); |
|
112 | + $this->load->helper('inflector'); |
|
113 | 113 | |
114 | 114 | // Table Name? |
115 | - if ( empty( $this->options['table_name'] ) ) |
|
115 | + if (empty($this->options['table_name'])) |
|
116 | 116 | { |
117 | - $this->options['table_name'] = empty( $options['table'] ) ? |
|
118 | - CLI::prompt( 'Table name', plural( strtolower( str_replace( '_model', '', $model_name ) ) ) ) : |
|
119 | - $options['table']; |
|
117 | + $this->options['table_name'] = empty($options['table']) ? |
|
118 | + CLI::prompt('Table name', plural(strtolower(str_replace('_model', '', $model_name)))) : $options['table']; |
|
120 | 119 | } |
121 | 120 | |
122 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
121 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
123 | 122 | |
124 | 123 | // Primary Key |
125 | 124 | if (empty($this->options['primary_key'])) |
126 | 125 | { |
127 | - $this->options['primary_key'] = empty( $options['primary_key'] ) ? |
|
128 | - CLI::prompt( 'Primary Key', 'id' ) : |
|
129 | - $options['primary_key']; |
|
126 | + $this->options['primary_key'] = empty($options['primary_key']) ? |
|
127 | + CLI::prompt('Primary Key', 'id') : $options['primary_key']; |
|
130 | 128 | } |
131 | 129 | |
132 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
130 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
133 | 131 | |
134 | 132 | // Set Created? |
135 | - if ( empty( $options['set_created'] ) ) |
|
133 | + if (empty($options['set_created'])) |
|
136 | 134 | { |
137 | - $ans = CLI::prompt( 'Set Created date?', [ 'y', 'n' ] ); |
|
138 | - if ( $ans == 'n' ) |
|
135 | + $ans = CLI::prompt('Set Created date?', ['y', 'n']); |
|
136 | + if ($ans == 'n') |
|
139 | 137 | { |
140 | 138 | $this->options['set_created'] = FALSE; |
141 | 139 | } |
142 | 140 | } |
143 | 141 | |
144 | 142 | // Set Modified? |
145 | - if ( empty( $options['set_modified'] ) ) |
|
143 | + if (empty($options['set_modified'])) |
|
146 | 144 | { |
147 | - $ans = CLI::prompt( 'Set Modified date?', [ 'y', 'n' ] ); |
|
148 | - if ( $ans == 'n' ) |
|
145 | + $ans = CLI::prompt('Set Modified date?', ['y', 'n']); |
|
146 | + if ($ans == 'n') |
|
149 | 147 | { |
150 | 148 | $this->options['set_modified'] = FALSE; |
151 | 149 | } |
152 | 150 | } |
153 | 151 | |
154 | 152 | // Date Format |
155 | - $this->options['date_format'] = empty( $options['date_format'] ) ? |
|
156 | - CLI::prompt( 'Date Format?', [ 'datetime', 'date', 'int' ] ) : |
|
157 | - $options['date_format']; |
|
153 | + $this->options['date_format'] = empty($options['date_format']) ? |
|
154 | + CLI::prompt('Date Format?', ['datetime', 'date', 'int']) : $options['date_format']; |
|
158 | 155 | |
159 | 156 | // Log User? |
160 | - if ( empty( $options['log_user'] ) ) |
|
157 | + if (empty($options['log_user'])) |
|
161 | 158 | { |
162 | - $ans = CLI::prompt( 'Log User actions?', [ 'y', 'n' ] ); |
|
163 | - if ( $ans == 'y' ) |
|
159 | + $ans = CLI::prompt('Log User actions?', ['y', 'n']); |
|
160 | + if ($ans == 'y') |
|
164 | 161 | { |
165 | 162 | $this->options['log_user'] = TRUE; |
166 | 163 | } |
167 | 164 | } |
168 | 165 | |
169 | 166 | // Soft Deletes |
170 | - if ( empty( $options['soft_delete'] ) ) |
|
167 | + if (empty($options['soft_delete'])) |
|
171 | 168 | { |
172 | - $ans = CLI::prompt( 'Use Soft Deletes?', [ 'y', 'n' ] ); |
|
173 | - if ( $ans == 'n' ) |
|
169 | + $ans = CLI::prompt('Use Soft Deletes?', ['y', 'n']); |
|
170 | + if ($ans == 'n') |
|
174 | 171 | { |
175 | 172 | $this->options['soft_delete'] = false; |
176 | 173 | } |
@@ -180,21 +177,21 @@ discard block |
||
180 | 177 | |
181 | 178 | //-------------------------------------------------------------------- |
182 | 179 | |
183 | - protected function quietSetOptions( $model_name, $options=[] ) |
|
180 | + protected function quietSetOptions($model_name, $options = []) |
|
184 | 181 | { |
185 | - $this->load->helper( 'inflector' ); |
|
182 | + $this->load->helper('inflector'); |
|
186 | 183 | |
187 | 184 | if (empty($this->options['table_name'])) |
188 | 185 | { |
189 | - $this->options['table_name'] = plural( strtolower( str_replace( '_model', '', $model_name ) ) ); |
|
186 | + $this->options['table_name'] = plural(strtolower(str_replace('_model', '', $model_name))); |
|
190 | 187 | } |
191 | 188 | |
192 | 189 | // Try to set it from the database first, |
193 | 190 | // otherwise, try to pull from fields |
194 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
191 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
195 | 192 | |
196 | - $this->options['primary_key'] = ! empty( $this->options['primary_key'] ) ? $this->options['primary_key'] : 'id'; |
|
197 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
193 | + $this->options['primary_key'] = ! empty($this->options['primary_key']) ? $this->options['primary_key'] : 'id'; |
|
194 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
198 | 195 | } |
199 | 196 | |
200 | 197 | //-------------------------------------------------------------------- |
@@ -206,12 +203,12 @@ discard block |
||
206 | 203 | * |
207 | 204 | * @return mixed An array of fields or false if the table does not exist |
208 | 205 | */ |
209 | - protected function table_info( $table_name, $options=[] ) |
|
206 | + protected function table_info($table_name, $options = []) |
|
210 | 207 | { |
211 | 208 | $this->load->database(); |
212 | 209 | |
213 | 210 | // Check whether the table exists in this database |
214 | - if ( ! $this->db->table_exists( $table_name ) ) |
|
211 | + if ( ! $this->db->table_exists($table_name)) |
|
215 | 212 | { |
216 | 213 | if (empty($options['fields'])) |
217 | 214 | { |
@@ -222,12 +219,12 @@ discard block |
||
222 | 219 | } |
223 | 220 | else |
224 | 221 | { |
225 | - $fields = $this->db->field_data( $table_name ); |
|
222 | + $fields = $this->db->field_data($table_name); |
|
226 | 223 | } |
227 | 224 | |
228 | 225 | // There may be something wrong or the database driver may not return |
229 | 226 | // field data |
230 | - if ( empty( $fields ) ) |
|
227 | + if (empty($fields)) |
|
231 | 228 | { |
232 | 229 | return FALSE; |
233 | 230 | } |
@@ -237,9 +234,9 @@ discard block |
||
237 | 234 | $this->options['use_soft_deletes'] = false; |
238 | 235 | |
239 | 236 | // Use the primary key if the table has one already set. |
240 | - foreach ( $fields as $field ) |
|
237 | + foreach ($fields as $field) |
|
241 | 238 | { |
242 | - if ( ! empty( $field->primary_key ) && $field->primary_key == 1 ) |
|
239 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
243 | 240 | { |
244 | 241 | $this->options['primary_key'] = $field->name; |
245 | 242 | } |
@@ -261,7 +258,7 @@ discard block |
||
261 | 258 | } |
262 | 259 | |
263 | 260 | // Set our validation rules based on these fields |
264 | - $this->options['rules'] = $this->buildValidationRules( $fields ); |
|
261 | + $this->options['rules'] = $this->buildValidationRules($fields); |
|
265 | 262 | |
266 | 263 | return $fields; |
267 | 264 | } |
@@ -274,20 +271,20 @@ discard block |
||
274 | 271 | */ |
275 | 272 | protected function parseFieldString($fields) |
276 | 273 | { |
277 | - if ( empty( $fields ) ) |
|
274 | + if (empty($fields)) |
|
278 | 275 | { |
279 | 276 | return NULL; |
280 | 277 | } |
281 | 278 | |
282 | - $fields = explode( ' ', $fields ); |
|
279 | + $fields = explode(' ', $fields); |
|
283 | 280 | |
284 | - $new_fields = [ ]; |
|
281 | + $new_fields = []; |
|
285 | 282 | |
286 | - foreach ( $fields as $field ) |
|
283 | + foreach ($fields as $field) |
|
287 | 284 | { |
288 | - $pop = [ NULL, NULL, NULL ]; |
|
289 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
290 | - $type = strtolower( $type ); |
|
285 | + $pop = [NULL, NULL, NULL]; |
|
286 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
287 | + $type = strtolower($type); |
|
291 | 288 | |
292 | 289 | // Strings |
293 | 290 | if (in_array($type, ['char', 'varchar', 'string'])) |
@@ -328,7 +325,7 @@ discard block |
||
328 | 325 | |
329 | 326 | // Convert to objects |
330 | 327 | array_walk($new_fields, function(&$item, $key) { |
331 | - $item = (object)$item; |
|
328 | + $item = (object) $item; |
|
332 | 329 | }); |
333 | 330 | |
334 | 331 | return $new_fields; |
@@ -345,7 +342,7 @@ discard block |
||
345 | 342 | * |
346 | 343 | * @return array |
347 | 344 | */ |
348 | - public function buildValidationrules($fields=[]) |
|
345 | + public function buildValidationrules($fields = []) |
|
349 | 346 | { |
350 | 347 | if (empty($fields) || ! is_array($fields) || ! count($fields)) |
351 | 348 | { |
@@ -390,7 +387,7 @@ discard block |
||
390 | 387 | break; |
391 | 388 | } |
392 | 389 | |
393 | - if (! empty($field->max_length)) |
|
390 | + if ( ! empty($field->max_length)) |
|
394 | 391 | { |
395 | 392 | $rule[] = "max_length[{$field->max_length}]"; |
396 | 393 | } |