@@ -1,199 +1,199 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace puck\helpers; |
3 | 3 | class Chaos { |
4 | - public $GbToBigArray; |
|
5 | - public $_pinyin; |
|
6 | - public $string; |
|
7 | - public $url=''; |
|
8 | - public $msg=''; |
|
9 | - public $action; |
|
10 | - private $prefix; |
|
4 | + public $GbToBigArray; |
|
5 | + public $_pinyin; |
|
6 | + public $string; |
|
7 | + public $url=''; |
|
8 | + public $msg=''; |
|
9 | + public $action; |
|
10 | + private $prefix; |
|
11 | 11 | |
12 | 12 | function __construct() { |
13 | - $this->_pinyin=new PinYin(); |
|
14 | - } |
|
13 | + $this->_pinyin=new PinYin(); |
|
14 | + } |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $prefix |
18 | 18 | */ |
19 | 19 | public function addPrefix(array $prefix) { |
20 | 20 | $this->prefix=$prefix[array_rand($prefix)]; |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | 23 | public function clearPrefix() { |
24 | 24 | $this->prefix=''; |
25 | - } |
|
25 | + } |
|
26 | 26 | public function get($str) { |
27 | 27 | $this->cutting($str); |
28 | 28 | $this->convert(); |
29 | 29 | $this->clearPrefix(); |
30 | 30 | return $this->msg; |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - //分离URL |
|
34 | - private function cutting($str) { |
|
33 | + //分离URL |
|
34 | + private function cutting($str) { |
|
35 | 35 | |
36 | - if (preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | - $this->url=$result[1]; |
|
38 | - $this->msg=$str=str_replace($this->url, '%%%%', $str); |
|
39 | - } else { |
|
40 | - $this->msg=$str; |
|
41 | - } |
|
42 | - } |
|
36 | + if (preg_match("@(http://[^\\s]+)@i", $str, $result)) { |
|
37 | + $this->url=$result[1]; |
|
38 | + $this->msg=$str=str_replace($this->url, '%%%%', $str); |
|
39 | + } else { |
|
40 | + $this->msg=$str; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - private function convert($method='msg') { |
|
47 | - if ($method == 'msg' || $method == 'all') { |
|
48 | - $this->msg=$this->setPinyin($this->msg); |
|
49 | - $this->msg=$this->setRepeat($this->msg); |
|
50 | - //$this->msg = $this->GbToBig($this->msg); |
|
51 | - $this->msg=$this->setBlankness($this->msg); |
|
46 | + private function convert($method='msg') { |
|
47 | + if ($method == 'msg' || $method == 'all') { |
|
48 | + $this->msg=$this->setPinyin($this->msg); |
|
49 | + $this->msg=$this->setRepeat($this->msg); |
|
50 | + //$this->msg = $this->GbToBig($this->msg); |
|
51 | + $this->msg=$this->setBlankness($this->msg); |
|
52 | 52 | |
53 | - } |
|
54 | - if ($method == 'url' || $method == 'all') { |
|
55 | - $this->url=$this->setChacha($this->url); |
|
56 | - } |
|
57 | - $this->msg=$this->prefix.str_replace('%%%%', $this->url, $this->msg); |
|
58 | - } |
|
53 | + } |
|
54 | + if ($method == 'url' || $method == 'all') { |
|
55 | + $this->url=$this->setChacha($this->url); |
|
56 | + } |
|
57 | + $this->msg=$this->prefix.str_replace('%%%%', $this->url, $this->msg); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $url |
|
62 | - */ |
|
63 | - function setChacha($url) { |
|
64 | - $url=strtolower($url); |
|
65 | - $arr=array( |
|
66 | - 'a' => array('a', 'A', 'a', 'A', 'Α', 'А', 'α'), |
|
67 | - 'b' => array('b', 'B', 'b', 'B', 'Β', 'В', 'Ь'), |
|
68 | - 'c' => array('c', 'C', 'c', 'C', 'С', 'с'), |
|
69 | - 'd' => array('d', 'D', 'd', 'D'), |
|
70 | - 'e' => array('e', 'E', 'e', 'E', 'Ε', 'Е', 'е'), |
|
71 | - 'f' => array('f', 'F', 'f', 'F'), |
|
72 | - 'g' => array('g', 'G', 'g', 'G'), |
|
73 | - 'h' => array('h', 'H', 'h', 'H', 'Η', 'Н', 'н'), |
|
74 | - 'i' => array('i', 'I', 'i', 'I', 'Ι', 'Ⅰ'), |
|
75 | - 'j' => array('j', 'J', 'j', 'J'), |
|
76 | - 'k' => array('k', 'K', 'k', 'K', 'Κ', 'κ', 'к', 'К'), |
|
77 | - 'l' => array('l', 'L', 'l', 'L', '︱', '︳', '|'), |
|
78 | - 'm' => array('m', 'M', 'm', 'M', 'Μ', 'М', 'м'), |
|
79 | - 'n' => array('n', 'N', 'n', 'N', 'Ν', '∩'), |
|
80 | - 'o' => array('o', 'O', 'o', 'O', 'Ο', 'О'), |
|
81 | - 'p' => array('p', 'P', 'p', 'P', 'Ρ', 'Р', 'р'), |
|
82 | - 'q' => array('q', 'Q', 'q', 'Q'), |
|
83 | - 'r' => array('r', 'R', 'r', 'R'), |
|
84 | - 's' => array('s', 'S', 's', 'S'), |
|
85 | - 't' => array('t', 'T', 't', 'T', 'Τ', 'Т', 'ㄒ'), |
|
86 | - 'u' => array('u', 'U', 'u', 'U', '∪'), |
|
87 | - 'v' => array('v', 'V', 'v', 'V', '∨', 'ν'), |
|
88 | - 'w' => array('w', 'W', 'w', 'W'), |
|
89 | - 'x' => array('x', 'X', 'x', 'X', 'Χ', 'χ', 'Х', 'х', 'Ⅹ', '×'), |
|
90 | - 'y' => array('y', 'Y', 'y', 'Y', 'У'), |
|
91 | - 'z' => array('z', 'Z', 'z', 'Z', 'Ζ'), |
|
60 | + /** |
|
61 | + * @param string $url |
|
62 | + */ |
|
63 | + function setChacha($url) { |
|
64 | + $url=strtolower($url); |
|
65 | + $arr=array( |
|
66 | + 'a' => array('a', 'A', 'a', 'A', 'Α', 'А', 'α'), |
|
67 | + 'b' => array('b', 'B', 'b', 'B', 'Β', 'В', 'Ь'), |
|
68 | + 'c' => array('c', 'C', 'c', 'C', 'С', 'с'), |
|
69 | + 'd' => array('d', 'D', 'd', 'D'), |
|
70 | + 'e' => array('e', 'E', 'e', 'E', 'Ε', 'Е', 'е'), |
|
71 | + 'f' => array('f', 'F', 'f', 'F'), |
|
72 | + 'g' => array('g', 'G', 'g', 'G'), |
|
73 | + 'h' => array('h', 'H', 'h', 'H', 'Η', 'Н', 'н'), |
|
74 | + 'i' => array('i', 'I', 'i', 'I', 'Ι', 'Ⅰ'), |
|
75 | + 'j' => array('j', 'J', 'j', 'J'), |
|
76 | + 'k' => array('k', 'K', 'k', 'K', 'Κ', 'κ', 'к', 'К'), |
|
77 | + 'l' => array('l', 'L', 'l', 'L', '︱', '︳', '|'), |
|
78 | + 'm' => array('m', 'M', 'm', 'M', 'Μ', 'М', 'м'), |
|
79 | + 'n' => array('n', 'N', 'n', 'N', 'Ν', '∩'), |
|
80 | + 'o' => array('o', 'O', 'o', 'O', 'Ο', 'О'), |
|
81 | + 'p' => array('p', 'P', 'p', 'P', 'Ρ', 'Р', 'р'), |
|
82 | + 'q' => array('q', 'Q', 'q', 'Q'), |
|
83 | + 'r' => array('r', 'R', 'r', 'R'), |
|
84 | + 's' => array('s', 'S', 's', 'S'), |
|
85 | + 't' => array('t', 'T', 't', 'T', 'Τ', 'Т', 'ㄒ'), |
|
86 | + 'u' => array('u', 'U', 'u', 'U', '∪'), |
|
87 | + 'v' => array('v', 'V', 'v', 'V', '∨', 'ν'), |
|
88 | + 'w' => array('w', 'W', 'w', 'W'), |
|
89 | + 'x' => array('x', 'X', 'x', 'X', 'Χ', 'χ', 'Х', 'х', 'Ⅹ', '×'), |
|
90 | + 'y' => array('y', 'Y', 'y', 'Y', 'У'), |
|
91 | + 'z' => array('z', 'Z', 'z', 'Z', 'Ζ'), |
|
92 | 92 | |
93 | - '1' => array('1', '1'), |
|
94 | - '2' => array('2', '2'), |
|
95 | - '3' => array('3', '3'), |
|
96 | - '4' => array('4', '4'), |
|
97 | - '5' => array('5', '5'), |
|
98 | - '6' => array('6', '6'), |
|
99 | - '7' => array('7', '7'), |
|
100 | - '8' => array('8', '8'), |
|
101 | - '9' => array('9', '9'), |
|
102 | - '0' => array('0', '0'), |
|
93 | + '1' => array('1', '1'), |
|
94 | + '2' => array('2', '2'), |
|
95 | + '3' => array('3', '3'), |
|
96 | + '4' => array('4', '4'), |
|
97 | + '5' => array('5', '5'), |
|
98 | + '6' => array('6', '6'), |
|
99 | + '7' => array('7', '7'), |
|
100 | + '8' => array('8', '8'), |
|
101 | + '9' => array('9', '9'), |
|
102 | + '0' => array('0', '0'), |
|
103 | 103 | |
104 | - ':' => array(':', ':', '∶'), |
|
105 | - '/' => array('/', '/'), |
|
106 | - '.' => array('。', '·', '.', '、', '﹒', ',', '丶') |
|
104 | + ':' => array(':', ':', '∶'), |
|
105 | + '/' => array('/', '/'), |
|
106 | + '.' => array('。', '·', '.', '、', '﹒', ',', '丶') |
|
107 | 107 | |
108 | - ); |
|
109 | - $len=strlen($url); |
|
110 | - $temp="\n\n"; |
|
111 | - for ($i=0; $i < $len; $i++) { |
|
112 | - $t_str=substr($url, $i, 1); |
|
113 | - $sj=mt_rand(0, count($arr[$t_str]) - 1); |
|
114 | - $temp.=$arr[$t_str][$sj]; |
|
115 | - } |
|
116 | - return $temp; |
|
117 | - } |
|
108 | + ); |
|
109 | + $len=strlen($url); |
|
110 | + $temp="\n\n"; |
|
111 | + for ($i=0; $i < $len; $i++) { |
|
112 | + $t_str=substr($url, $i, 1); |
|
113 | + $sj=mt_rand(0, count($arr[$t_str]) - 1); |
|
114 | + $temp.=$arr[$t_str][$sj]; |
|
115 | + } |
|
116 | + return $temp; |
|
117 | + } |
|
118 | 118 | |
119 | - //随机把一个字符转为拼音 |
|
119 | + //随机把一个字符转为拼音 |
|
120 | 120 | |
121 | - /** |
|
122 | - * @param string $str |
|
123 | - */ |
|
124 | - function setPinyin($str) { |
|
125 | - $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
|
126 | - $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
|
127 | - if(mt_rand(0,10) > 5) { |
|
128 | - $pinyin = " "; |
|
129 | - } |
|
130 | - $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
|
121 | + /** |
|
122 | + * @param string $str |
|
123 | + */ |
|
124 | + function setPinyin($str) { |
|
125 | + $py = mt_rand(0, iconv_strlen( $str, 'UTF-8' )-1); |
|
126 | + $t_str = iconv_substr( $str, $py, 1, 'UTF-8'); |
|
127 | + if(mt_rand(0,10) > 5) { |
|
128 | + $pinyin = " "; |
|
129 | + } |
|
130 | + $pinyin = $this->_pinyin->convert($t_str,PINYIN_UNICODE); |
|
131 | 131 | $pinyin=implode(" ",$pinyin); |
132 | - if(mt_rand(0,10) > 5) { |
|
133 | - $pinyin .= " "; |
|
134 | - } |
|
135 | - if($t_str != "%"){ |
|
136 | - $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
|
137 | - } |
|
138 | - return $str; |
|
139 | - } |
|
132 | + if(mt_rand(0,10) > 5) { |
|
133 | + $pinyin .= " "; |
|
134 | + } |
|
135 | + if($t_str != "%"){ |
|
136 | + $str = preg_replace("'$t_str'", $pinyin, $str, 1); |
|
137 | + } |
|
138 | + return $str; |
|
139 | + } |
|
140 | 140 | |
141 | - //随机重复一个字符 |
|
141 | + //随机重复一个字符 |
|
142 | 142 | |
143 | - /** |
|
144 | - * @param string $str |
|
145 | - */ |
|
146 | - function setRepeat($str) { |
|
147 | - $len = iconv_strlen( $str, 'UTF-8' ); |
|
148 | - $action = 0; |
|
149 | - $temp = ''; |
|
150 | - for( $i=0; $i<$len; $i++ ){ |
|
151 | - $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
152 | - if( mt_rand( 1, 50 ) > 48 && $action == 0) { |
|
153 | - if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
154 | - $temp .= $t_str; |
|
155 | - $action = 1; |
|
156 | - } |
|
157 | - } |
|
158 | - $temp .= $t_str; |
|
159 | - } |
|
160 | - return $temp; |
|
161 | - } |
|
143 | + /** |
|
144 | + * @param string $str |
|
145 | + */ |
|
146 | + function setRepeat($str) { |
|
147 | + $len = iconv_strlen( $str, 'UTF-8' ); |
|
148 | + $action = 0; |
|
149 | + $temp = ''; |
|
150 | + for( $i=0; $i<$len; $i++ ){ |
|
151 | + $t_str = iconv_substr( $str, $i, 1 ,'UTF-8'); |
|
152 | + if( mt_rand( 1, 50 ) > 48 && $action == 0) { |
|
153 | + if(!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
154 | + $temp .= $t_str; |
|
155 | + $action = 1; |
|
156 | + } |
|
157 | + } |
|
158 | + $temp .= $t_str; |
|
159 | + } |
|
160 | + return $temp; |
|
161 | + } |
|
162 | 162 | |
163 | - //随机插入不影响阅读的字符 |
|
163 | + //随机插入不影响阅读的字符 |
|
164 | 164 | |
165 | - /** |
|
166 | - * @param string $str |
|
167 | - */ |
|
168 | - function setBlankness($str) { |
|
169 | - $blankness=array(" ", ' ', '҉', '̅̅', '̲', '̲̲', '̅', '̲̲̅̅'); |
|
170 | - $len=iconv_strlen($str, 'UTF-8'); |
|
171 | - $temp=''; |
|
172 | - for ($i=0; $i < $len; $i++) { |
|
173 | - $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
174 | - if (mt_rand(1, 50) > 48) { |
|
175 | - if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
176 | - $temp.=$blankness[mt_rand(0, 7)]; |
|
177 | - } |
|
178 | - } |
|
179 | - $temp.=$t_str; |
|
180 | - } |
|
181 | - return $temp; |
|
182 | - } |
|
165 | + /** |
|
166 | + * @param string $str |
|
167 | + */ |
|
168 | + function setBlankness($str) { |
|
169 | + $blankness=array(" ", ' ', '҉', '̅̅', '̲', '̲̲', '̅', '̲̲̅̅'); |
|
170 | + $len=iconv_strlen($str, 'UTF-8'); |
|
171 | + $temp=''; |
|
172 | + for ($i=0; $i < $len; $i++) { |
|
173 | + $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
174 | + if (mt_rand(1, 50) > 48) { |
|
175 | + if (!preg_match("@[a-z0-9%\\s]+@i", $t_str)) { |
|
176 | + $temp.=$blankness[mt_rand(0, 7)]; |
|
177 | + } |
|
178 | + } |
|
179 | + $temp.=$t_str; |
|
180 | + } |
|
181 | + return $temp; |
|
182 | + } |
|
183 | 183 | |
184 | - //随机进行繁体中文转换 |
|
185 | - function GbToBig($str) { |
|
186 | - $len=iconv_strlen($str, 'UTF-8'); |
|
187 | - $temp=''; |
|
188 | - for ($i=0; $i < $len; $i++) { |
|
189 | - $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
190 | - if (mt_rand(1, 50) > 48) { |
|
191 | - $t_str=strtr($t_str, $this->GbToBigArray); |
|
192 | - } |
|
193 | - $temp.=$t_str; |
|
194 | - } |
|
195 | - return $temp; |
|
196 | - } |
|
184 | + //随机进行繁体中文转换 |
|
185 | + function GbToBig($str) { |
|
186 | + $len=iconv_strlen($str, 'UTF-8'); |
|
187 | + $temp=''; |
|
188 | + for ($i=0; $i < $len; $i++) { |
|
189 | + $t_str=iconv_substr($str, $i, 1, 'UTF-8'); |
|
190 | + if (mt_rand(1, 50) > 48) { |
|
191 | + $t_str=strtr($t_str, $this->GbToBigArray); |
|
192 | + } |
|
193 | + $temp.=$t_str; |
|
194 | + } |
|
195 | + return $temp; |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | |
199 | 199 |
@@ -52,7 +52,7 @@ |
||
52 | 52 | /** |
53 | 53 | * Set a given configuration value. |
54 | 54 | * |
55 | - * @param array|string $key |
|
55 | + * @param string $key |
|
56 | 56 | * @param mixed $value |
57 | 57 | * @return void |
58 | 58 | */ |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param array $files |
171 | 171 | * @param array $server |
172 | 172 | * @param string $content |
173 | - * @return \think\Request |
|
173 | + * @return Request |
|
174 | 174 | */ |
175 | 175 | public function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [], $content = null) |
176 | 176 | { |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | /** |
613 | 613 | * 设置获取获取路由参数 |
614 | 614 | * @access public |
615 | - * @param string|array $name 变量名 |
|
615 | + * @param boolean $name 变量名 |
|
616 | 616 | * @param mixed $default 默认值 |
617 | 617 | * @param string|array $filter 过滤方法 |
618 | 618 | * @return mixed |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | /** |
630 | 630 | * 设置获取获取GET参数 |
631 | 631 | * @access public |
632 | - * @param string|array $name 变量名 |
|
632 | + * @param boolean $name 变量名 |
|
633 | 633 | * @param mixed $default 默认值 |
634 | 634 | * @param string|array $filter 过滤方法 |
635 | 635 | * @return mixed |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | /** |
784 | 784 | * 获取server参数 |
785 | 785 | * @access public |
786 | - * @param string|array $name 数据名称 |
|
786 | + * @param string $name 数据名称 |
|
787 | 787 | * @param string $default 默认值 |
788 | - * @param string|array $filter 过滤方法 |
|
788 | + * @param string $filter 过滤方法 |
|
789 | 789 | * @return mixed |
790 | 790 | */ |
791 | 791 | public function server($name = '', $default = null, $filter = '') |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | * @param string $name 变量名 |
1087 | 1087 | * @param string $type 变量类型 |
1088 | 1088 | * @param bool $checkEmpty 是否检测空值 |
1089 | - * @return mixed |
|
1089 | + * @return boolean |
|
1090 | 1090 | */ |
1091 | 1091 | public function has($name, $type = 'param', $checkEmpty = false) |
1092 | 1092 | { |
@@ -260,7 +260,7 @@ |
||
260 | 260 | * Check if an item or items exist in an array using "dot" notation. |
261 | 261 | * |
262 | 262 | * @param \ArrayAccess|array $array |
263 | - * @param string|array $keys |
|
263 | + * @param string $keys |
|
264 | 264 | * @return bool |
265 | 265 | */ |
266 | 266 | public static function has($array, $keys) { |
@@ -462,7 +462,7 @@ |
||
462 | 462 | * 获取环境变量 |
463 | 463 | * |
464 | 464 | * @param string $key |
465 | - * @param mixed $default |
|
465 | + * @param string|false $default |
|
466 | 466 | * @return mixed |
467 | 467 | */ |
468 | 468 | function env($key, $default = null) |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Progress |
228 | 228 | * |
229 | 229 | * @access public |
230 | - * @param $callback |
|
230 | + * @param \Closure $callback |
|
231 | 231 | */ |
232 | 232 | public function progress($callback) |
233 | 233 | { |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * Download Complete |
264 | 264 | * |
265 | 265 | * @access private |
266 | - * @param $fh |
|
266 | + * @param resource $fh |
|
267 | 267 | */ |
268 | 268 | private function downloadComplete($fh) |
269 | 269 | { |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * Get Info |
443 | 443 | * |
444 | 444 | * @access public |
445 | - * @param $opt |
|
445 | + * @param integer $opt |
|
446 | 446 | * |
447 | 447 | * @return mixed |
448 | 448 | */ |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * Get Opt |
463 | 463 | * |
464 | 464 | * @access public |
465 | - * @param $option |
|
465 | + * @param integer $option |
|
466 | 466 | * |
467 | 467 | * @return mixed |
468 | 468 | */ |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | * Set Timeout |
1106 | 1106 | * |
1107 | 1107 | * @access public |
1108 | - * @param $seconds |
|
1108 | + * @param integer $seconds |
|
1109 | 1109 | */ |
1110 | 1110 | public function setTimeout($seconds) |
1111 | 1111 | { |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * Set User Agent |
1131 | 1131 | * |
1132 | 1132 | * @access public |
1133 | - * @param $user_agent |
|
1133 | + * @param string $user_agent |
|
1134 | 1134 | */ |
1135 | 1135 | public function setUserAgent($user_agent) |
1136 | 1136 | { |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * Using `curl -H "Host:" ...' is equivalent to $curl->removeHeader('Host');. |
1174 | 1174 | * |
1175 | 1175 | * @access public |
1176 | - * @param $key |
|
1176 | + * @param string $key |
|
1177 | 1177 | */ |
1178 | 1178 | public function removeHeader($key) |
1179 | 1179 | { |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | * Parse Response Headers |
1361 | 1361 | * |
1362 | 1362 | * @access private |
1363 | - * @param $raw_response_headers |
|
1363 | + * @param string $raw_response_headers |
|
1364 | 1364 | * |
1365 | 1365 | * @return array |
1366 | 1366 | */ |
@@ -76,7 +76,6 @@ discard block |
||
76 | 76 | private $_with = Array(); |
77 | 77 | |
78 | 78 | /** |
79 | - * @param array $data Data to preload on object creation |
|
80 | 79 | */ |
81 | 80 | public function __construct() { |
82 | 81 | $this->db = app('db')->connect($this->dbConn); |
@@ -207,7 +206,7 @@ discard block |
||
207 | 206 | /** |
208 | 207 | * Save or Update object |
209 | 208 | * |
210 | - * @return mixed insert id or false in case of failure |
|
209 | + * @return boolean insert id or false in case of failure |
|
211 | 210 | */ |
212 | 211 | public function save($data = null) { |
213 | 212 | if ($this->isNew) |
@@ -216,7 +215,7 @@ discard block |
||
216 | 215 | } |
217 | 216 | |
218 | 217 | /** |
219 | - * @return mixed insert id or false in case of failure |
|
218 | + * @return boolean insert id or false in case of failure |
|
220 | 219 | */ |
221 | 220 | public function insert() { |
222 | 221 | if (!empty ($this->timestamps) && in_array("createdAt", $this->timestamps)) |
@@ -362,7 +361,7 @@ discard block |
||
362 | 361 | /** |
363 | 362 | * Delete method. Works only if object primaryKey is defined |
364 | 363 | * |
365 | - * @return boolean Indicates success. 0 or 1. |
|
364 | + * @return null|boolean Indicates success. 0 or 1. |
|
366 | 365 | */ |
367 | 366 | public function delete() { |
368 | 367 | if (empty ($this->data[$this->primaryKey])) |
@@ -522,7 +521,7 @@ discard block |
||
522 | 521 | * @param string $joinType SQL join type: LEFT, RIGHT, INNER, OUTER |
523 | 522 | * @param string $primaryKey SQL join On Second primaryKey |
524 | 523 | * |
525 | - * @return dbObject |
|
524 | + * @return Model |
|
526 | 525 | */ |
527 | 526 | private function join($objectName, $key = null, $joinType = 'LEFT', $primaryKey = null) { |
528 | 527 | $joinObj = new $objectName; |
@@ -571,7 +570,7 @@ discard block |
||
571 | 570 | /** |
572 | 571 | * Helper function to create dbObject with Json return type |
573 | 572 | * |
574 | - * @return dbObject |
|
573 | + * @return Model |
|
575 | 574 | */ |
576 | 575 | private function JsonBuilder() { |
577 | 576 | $this->returnType = 'Json'; |
@@ -585,7 +584,7 @@ discard block |
||
585 | 584 | /** |
586 | 585 | * Helper function to create dbObject with Array return type |
587 | 586 | * |
588 | - * @return dbObject |
|
587 | + * @return Model |
|
589 | 588 | */ |
590 | 589 | private function ArrayBuilder() { |
591 | 590 | $this->returnType = 'Array'; |
@@ -596,7 +595,7 @@ discard block |
||
596 | 595 | * Helper function to create dbObject with Object return type. |
597 | 596 | * Added for consistency. Works same way as new $objname () |
598 | 597 | * |
599 | - * @return dbObject |
|
598 | + * @return Model |
|
600 | 599 | */ |
601 | 600 | private function ObjectBuilder() { |
602 | 601 | $this->returnType = 'Object'; |
@@ -651,7 +650,7 @@ discard block |
||
651 | 650 | * @access public |
652 | 651 | * @param string $objectName Object Name |
653 | 652 | * |
654 | - * @return dbObject |
|
653 | + * @return null|Model |
|
655 | 654 | */ |
656 | 655 | private function with($objectName) { |
657 | 656 | if (!property_exists($this, 'relations') && !isset ($this->relations[$name])) |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @param string $subQueryAlias |
257 | 257 | * |
258 | - * @return MysqliDb |
|
258 | + * @return Mysql |
|
259 | 259 | */ |
260 | 260 | public static function subQuery($subQueryAlias = "") { |
261 | 261 | return new self(array('host' => $subQueryAlias, 'isSubQuery' => true)); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | /** |
278 | 278 | * Helper function to create dbObject with JSON return type |
279 | 279 | * |
280 | - * @return MysqliDb |
|
280 | + * @return Mysql |
|
281 | 281 | */ |
282 | 282 | public function jsonBuilder() { |
283 | 283 | $this->returnType = 'json'; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | /** |
288 | 288 | * Helper function to create dbObject with object return type. |
289 | 289 | * |
290 | - * @return MysqliDb |
|
290 | + * @return Mysql |
|
291 | 291 | */ |
292 | 292 | public function objectBuilder() { |
293 | 293 | $this->returnType = 'object'; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * Method attempts to prepare the SQL query |
351 | 351 | * and throws an error if there was a problem. |
352 | 352 | * |
353 | - * @return mysqli_stmt |
|
353 | + * @return \mysqli_stmt |
|
354 | 354 | */ |
355 | 355 | protected function _prepareQuery() { |
356 | 356 | if (!$stmt = $this->mysqli()->prepare($this->_query)) { |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * This helper method takes care of prepared statements' "bind_result method |
540 | 540 | * , when the number of variables to pass is unknown. |
541 | 541 | * |
542 | - * @param mysqli_stmt $stmt Equal to the prepared statement object. |
|
542 | + * @param \mysqli_stmt $stmt Equal to the prepared statement object. |
|
543 | 543 | * |
544 | 544 | * @return array The results of the SQL fetch. |
545 | 545 | */ |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * or only $count |
703 | 703 | * @param array $tableData Should contain an array of data for updating the database. |
704 | 704 | * |
705 | - * @return mysqli_stmt Returns the $stmt object. |
|
705 | + * @return null|\mysqli_stmt Returns the $stmt object. |
|
706 | 706 | */ |
707 | 707 | protected function _buildQuery($numRows = null, $tableData = null) { |
708 | 708 | // $this->_buildJoinOld(); |
@@ -1209,9 +1209,8 @@ discard block |
||
1209 | 1209 | * A convenient function that returns TRUE if exists at least an element that |
1210 | 1210 | * satisfy the where condition specified calling the "where" method before this one. |
1211 | 1211 | * |
1212 | - * @param string $tableName The name of the database table to work with. |
|
1213 | 1212 | * |
1214 | - * @return array Contains the returned rows from the select query. |
|
1213 | + * @return boolean Contains the returned rows from the select query. |
|
1215 | 1214 | */ |
1216 | 1215 | public function has() { |
1217 | 1216 | $this->getOne($this->tableName, '1'); |
@@ -1311,7 +1310,7 @@ discard block |
||
1311 | 1310 | * @param int|array $numRows Array to define SQL limit in format Array ($count, $offset) |
1312 | 1311 | * or only $count |
1313 | 1312 | * |
1314 | - * @return bool Indicates success. 0 or 1. |
|
1313 | + * @return null|boolean Indicates success. 0 or 1. |
|
1315 | 1314 | */ |
1316 | 1315 | public function delete($numRows = null) { |
1317 | 1316 | if ($this->isSubQuery) { |
@@ -1342,7 +1341,7 @@ discard block |
||
1342 | 1341 | * @param array $updateColumns Variable with values |
1343 | 1342 | * @param string $lastInsertId Variable value |
1344 | 1343 | * |
1345 | - * @return MysqliDb |
|
1344 | + * @return Mysql |
|
1346 | 1345 | */ |
1347 | 1346 | public function onDuplicate($updateColumns, $lastInsertId = null) { |
1348 | 1347 | $this->_lastInsertId = $lastInsertId; |
@@ -1359,7 +1358,7 @@ discard block |
||
1359 | 1358 | * @param mixed $whereValue The value of the database field. |
1360 | 1359 | * @param string $operator Comparison operator. Default is = |
1361 | 1360 | * |
1362 | - * @return MysqliDb |
|
1361 | + * @return Mysql |
|
1363 | 1362 | */ |
1364 | 1363 | public function orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=') { |
1365 | 1364 | return $this->where($whereProp, $whereValue, $operator, 'OR'); |
@@ -1375,7 +1374,7 @@ discard block |
||
1375 | 1374 | * @param string $operator Comparison operator. Default is = |
1376 | 1375 | * @param string $cond Condition of where statement (OR, AND) |
1377 | 1376 | * |
1378 | - * @return MysqliDb |
|
1377 | + * @return Mysql |
|
1379 | 1378 | */ |
1380 | 1379 | public function where($whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') { |
1381 | 1380 | // forkaround for an old operation api |
@@ -1401,7 +1400,7 @@ discard block |
||
1401 | 1400 | * @param mixed $havingValue The value of the database field. |
1402 | 1401 | * @param string $operator Comparison operator. Default is = |
1403 | 1402 | * |
1404 | - * @return MysqliDb |
|
1403 | + * @return Mysql |
|
1405 | 1404 | */ |
1406 | 1405 | public function orHaving($havingProp, $havingValue = null, $operator = null) { |
1407 | 1406 | return $this->having($havingProp, $havingValue, $operator, 'OR'); |
@@ -1416,7 +1415,7 @@ discard block |
||
1416 | 1415 | * @param mixed $havingValue The value of the database field. |
1417 | 1416 | * @param string $operator Comparison operator. Default is = |
1418 | 1417 | * |
1419 | - * @return MysqliDb |
|
1418 | + * @return Mysql |
|
1420 | 1419 | */ |
1421 | 1420 | |
1422 | 1421 | public function having($havingProp, $havingValue = 'DBNULL', $operator = '=', $cond = 'AND') { |
@@ -1444,7 +1443,7 @@ discard block |
||
1444 | 1443 | * @param string $joinType 'LEFT', 'INNER' etc. |
1445 | 1444 | * |
1446 | 1445 | * @throws Exception |
1447 | - * @return MysqliDb |
|
1446 | + * @return Mysql |
|
1448 | 1447 | */ |
1449 | 1448 | public function join($joinTable, $joinCondition, $joinType = '') { |
1450 | 1449 | $allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'); |
@@ -1529,7 +1528,7 @@ discard block |
||
1529 | 1528 | * This method does not escape strings by default so make sure you'll never use it in production. |
1530 | 1529 | * |
1531 | 1530 | * @author Jonas Barascu |
1532 | - * @param [[Type]] $query [[Description]] |
|
1531 | + * @param string $query [[Description]] |
|
1533 | 1532 | */ |
1534 | 1533 | private function queryUnprepared($query) { |
1535 | 1534 | // Execute query |
@@ -1603,11 +1602,11 @@ discard block |
||
1603 | 1602 | * @uses $MySqliDb->orderBy('id', 'desc')->orderBy('name', 'desc'); |
1604 | 1603 | * |
1605 | 1604 | * @param string $orderByField The name of the database field. |
1606 | - * @param string $orderByDirection Order direction. |
|
1605 | + * @param string $orderbyDirection Order direction. |
|
1607 | 1606 | * @param array $customFields Fieldset for ORDER BY FIELD() ordering |
1608 | 1607 | * |
1609 | 1608 | * @throws Exception |
1610 | - * @return MysqliDb |
|
1609 | + * @return Mysql |
|
1611 | 1610 | */ |
1612 | 1611 | public function orderBy($orderByField, $orderbyDirection = "DESC", $customFields = null) { |
1613 | 1612 | $allowedDirection = Array("ASC", "DESC"); |
@@ -1643,7 +1642,7 @@ discard block |
||
1643 | 1642 | * |
1644 | 1643 | * @param string $groupByField The name of the database field. |
1645 | 1644 | * |
1646 | - * @return MysqliDb |
|
1645 | + * @return Mysql |
|
1647 | 1646 | */ |
1648 | 1647 | public function groupBy($groupByField) { |
1649 | 1648 | $groupByField = preg_replace("/[^-a-z0-9\.\(\),_\*]+/i", '', $groupByField); |
@@ -1659,7 +1658,7 @@ discard block |
||
1659 | 1658 | * @param string $method The table lock method. Can be READ or WRITE. |
1660 | 1659 | * |
1661 | 1660 | * @throws Exception |
1662 | - * @return MysqliDb |
|
1661 | + * @return Mysql |
|
1663 | 1662 | */ |
1664 | 1663 | public function setLockMethod($method) { |
1665 | 1664 | // Switch the uppercase string |
@@ -1806,7 +1805,7 @@ discard block |
||
1806 | 1805 | * |
1807 | 1806 | * @param string $prefix Contains a tableprefix |
1808 | 1807 | * |
1809 | - * @return MysqliDb |
|
1808 | + * @return Mysql |
|
1810 | 1809 | */ |
1811 | 1810 | public function setPrefix($prefix = '') { |
1812 | 1811 | $this->prefix = $prefix; |
@@ -2016,7 +2015,7 @@ discard block |
||
2016 | 2015 | * @param bool $enabled Enable execution time tracking |
2017 | 2016 | * @param string $stripPrefix Prefix to strip from the path in exec log |
2018 | 2017 | * |
2019 | - * @return MysqliDb |
|
2018 | + * @return Mysql |
|
2020 | 2019 | */ |
2021 | 2020 | public function setTrace($enabled, $stripPrefix = null) { |
2022 | 2021 | $this->traceEnabled = $enabled; |
@@ -2053,7 +2052,7 @@ discard block |
||
2053 | 2052 | * |
2054 | 2053 | * @param string $idField field name to use for a mapped element key |
2055 | 2054 | * |
2056 | - * @return MysqliDb |
|
2055 | + * @return Mysql |
|
2057 | 2056 | */ |
2058 | 2057 | public function map($idField) { |
2059 | 2058 | $this->_mapKey = $idField; |
@@ -2069,7 +2068,7 @@ discard block |
||
2069 | 2068 | * @param string $whereProp The name of the database field. |
2070 | 2069 | * @param mixed $whereValue The value of the database field. |
2071 | 2070 | * |
2072 | - * @return dbWrapper |
|
2071 | + * @return Mysql |
|
2073 | 2072 | */ |
2074 | 2073 | public function joinOrWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') { |
2075 | 2074 | return $this->joinWhere($whereJoin, $whereProp, $whereValue, $operator, 'OR'); |
@@ -2084,7 +2083,7 @@ discard block |
||
2084 | 2083 | * @param string $whereProp The name of the database field. |
2085 | 2084 | * @param mixed $whereValue The value of the database field. |
2086 | 2085 | * |
2087 | - * @return dbWrapper |
|
2086 | + * @return Mysql |
|
2088 | 2087 | */ |
2089 | 2088 | public function joinWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') { |
2090 | 2089 | $this->_joinAnd[$whereJoin][] = Array($cond, $whereProp, $operator, $whereValue); |
@@ -2160,7 +2159,7 @@ discard block |
||
2160 | 2159 | * Helper function to create dbObject with array return type |
2161 | 2160 | * Added for consistency as thats default output type |
2162 | 2161 | * |
2163 | - * @return MysqliDb |
|
2162 | + * @return Mysql |
|
2164 | 2163 | */ |
2165 | 2164 | public function arrayBuilder() { |
2166 | 2165 | $this->returnType = 'array'; |
@@ -2241,7 +2240,7 @@ discard block |
||
2241 | 2240 | /** |
2242 | 2241 | * Function to enable SQL_CALC_FOUND_ROWS in the get queries |
2243 | 2242 | * |
2244 | - * @return MysqliDb |
|
2243 | + * @return Mysql |
|
2245 | 2244 | */ |
2246 | 2245 | public function withTotalCount() { |
2247 | 2246 | $this->setQueryOption('SQL_CALC_FOUND_ROWS'); |
@@ -2253,10 +2252,10 @@ discard block |
||
2253 | 2252 | * |
2254 | 2253 | * @uses $MySqliDb->setQueryOption('name'); |
2255 | 2254 | * |
2256 | - * @param string|array $options The optons name of the query. |
|
2255 | + * @param string $options The optons name of the query. |
|
2257 | 2256 | * |
2258 | 2257 | * @throws Exception |
2259 | - * @return MysqliDb |
|
2258 | + * @return Mysql |
|
2260 | 2259 | */ |
2261 | 2260 | public function setQueryOption($options) { |
2262 | 2261 | $allowedOptions = Array('ALL', 'DISTINCT', 'DISTINCTROW', 'HIGH_PRIORITY', 'STRAIGHT_JOIN', 'SQL_SMALL_RESULT', |