This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * |
||
5 | * @package |
||
6 | * @copyright SalesAgility Ltd http://www.salesagility.com |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
||
10 | * the Free Software Foundation; either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||
19 | * along with this program; if not, see http://www.gnu.org/licenses |
||
20 | * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
||
21 | * Fifth Floor, Boston, MA 02110-1301 USA |
||
22 | * |
||
23 | * @author Salesagility Ltd <[email protected]> |
||
24 | */ |
||
25 | |||
26 | |||
27 | |||
28 | 1 | function requireLucene(){ |
|
29 | 1 | set_include_path(get_include_path() . PATH_SEPARATOR . "modules/AOD_Index/Lib"); |
|
30 | 1 | require_once('Zend/Search/Lucene.php'); |
|
31 | 1 | } |
|
32 | |||
33 | 1 | function getDocumentRevisionPath($revisionId){ |
|
34 | 1 | return "upload/$revisionId"; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Given a path to a PPTX document returns a lucene document with filename and contents set. |
||
39 | * @param $path |
||
40 | * @return Zend_Search_Lucene_Document |
||
41 | */ |
||
42 | 1 | function createPPTXDocument($path){ |
|
43 | $doc = Zend_Search_Lucene_Document_Pptx::loadPptxFile($path); |
||
44 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
45 | return $doc; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Given a path to a XLSX document returns a lucene document with filename and contents set. |
||
50 | * @param $path |
||
51 | * @return Zend_Search_Lucene_Document |
||
52 | */ |
||
53 | 1 | function createXLSXDocument($path){ |
|
54 | $doc = Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($path); |
||
55 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
56 | return $doc; |
||
57 | } |
||
58 | /** |
||
59 | * Given a path to a HTML document returns a lucene document with filename and contents set. |
||
60 | * @param $path |
||
61 | * @return Zend_Search_Lucene_Document |
||
62 | */ |
||
63 | 1 | function createHTMLDocument($path){ |
|
64 | $doc = Zend_Search_Lucene_Document_Html::loadHTMLFile($path); |
||
65 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
66 | return $doc; |
||
67 | } |
||
68 | /** |
||
69 | * Given a path to a DocX document returns a lucene document with filename and contents set. |
||
70 | * @param $path |
||
71 | * @return Zend_Search_Lucene_Document |
||
72 | */ |
||
73 | 1 | function createDocXDocument($path){ |
|
74 | $doc = Zend_Search_Lucene_Document_Docx::loadDocxFile($path); |
||
75 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
76 | return $doc; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Given a path to a Doc document returns a lucene document with filename and contents set. |
||
81 | * @param $path |
||
82 | * @return Zend_Search_Lucene_Document |
||
83 | */ |
||
84 | 1 | function createDocDocument($path){ |
|
85 | $fileHandle = fopen($path, "r"); |
||
86 | $line = @fread($fileHandle, filesize($path)); |
||
87 | $lines = explode(chr(0x0D),$line); |
||
88 | $outtext = ""; |
||
89 | foreach($lines as $thisline) |
||
90 | { |
||
91 | $pos = strpos($thisline, chr(0x00)); |
||
92 | if (($pos !== FALSE)||(strlen($thisline)==0)) |
||
0 ignored issues
–
show
|
|||
93 | { |
||
94 | } else { |
||
95 | $outtext .= $thisline." "; |
||
96 | } |
||
97 | } |
||
98 | $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext); |
||
99 | |||
100 | $doc = new Zend_Search_Lucene_Document(); |
||
101 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
102 | $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $outtext)); |
||
103 | fclose($fileHandle); |
||
104 | return $doc; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Given a path to a PDF document returns a lucene document with filename and contents set. |
||
109 | * @param $path |
||
110 | * @return Zend_Search_Lucene_Document |
||
111 | */ |
||
112 | 1 | function createPDFDocument($path){ |
|
113 | require_once('PdfParser.php'); |
||
114 | $text = PdfParser::parseFile($path); |
||
115 | $doc = new Zend_Search_Lucene_Document(); |
||
116 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
117 | $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $text)); |
||
118 | return $doc; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Given a path to an ODT doc returns a lucene document with contents and filename set. |
||
123 | * @param $path |
||
124 | * @return bool|Zend_Search_Lucene_Document |
||
125 | */ |
||
126 | 1 | function createOdtDocument($path){ |
|
127 | if(!is_file($path)){ |
||
128 | return false; |
||
129 | } |
||
130 | $doc = new Zend_Search_Lucene_Document(); |
||
131 | $documentBody = array(); |
||
132 | $coreProperties = array(); |
||
133 | $package = new ZipArchive(); |
||
134 | $package->open($path); |
||
135 | $contents = simplexml_load_string($package->getFromName("content.xml")); |
||
136 | $paragraphs = $contents->xpath('//text:*'); |
||
137 | foreach ($paragraphs as $paragraph) { |
||
138 | $documentBody[] = (string)$paragraph; |
||
139 | $documentBody[] = ' '; |
||
140 | } |
||
141 | // Close file |
||
142 | $package->close(); |
||
143 | $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', implode(' ', $documentBody), 'UTF-8')); |
||
144 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
145 | return $doc; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * Given a path to a plain text doc returns a lucene document with $filename and $contents set appropriately. |
||
150 | * @param $path |
||
151 | * @return Zend_Search_Lucene_Document |
||
152 | */ |
||
153 | 1 | function createTextDocument($path){ |
|
154 | $doc = new Zend_Search_Lucene_Document(); |
||
155 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
156 | $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', file_get_contents($path))); |
||
157 | return $doc; |
||
158 | } |
||
159 | |||
160 | |||
161 | /** |
||
162 | * Given the path to an rtf document returns a lucene document with $filename and $contents set appropriately. |
||
163 | * @param $path |
||
164 | * @return Zend_Search_Lucene_Document |
||
165 | */ |
||
166 | 1 | function createRTFDocument($path){ |
|
167 | $doc = new Zend_Search_Lucene_Document(); |
||
168 | $doc->addField(Zend_Search_Lucene_Field::Text('filename', basename($path))); |
||
169 | $contents = rtf2text($path); |
||
170 | //print_r($contents); |
||
171 | $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $contents)); |
||
172 | return $doc; |
||
173 | } |
||
174 | |||
175 | 1 | function rtf_isPlainText($s) { |
|
176 | $arrfailAt = array("*", "fonttbl", "colortbl", "datastore", "themedata"); |
||
177 | for ($i = 0; $i < count($arrfailAt); $i++) |
||
0 ignored issues
–
show
It seems like you are calling the size function
count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}
// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
![]() |
|||
178 | if (!empty($s[$arrfailAt[$i]])) return false; |
||
179 | return true; |
||
180 | } |
||
181 | |||
182 | 1 | function rtf2text($filename) { |
|
183 | // Read the data from the input file. |
||
184 | $text = file_get_contents($filename); |
||
185 | if (!strlen($text)) |
||
186 | return ""; |
||
187 | |||
188 | // Create empty stack array. |
||
189 | $document = ""; |
||
190 | $stack = array(); |
||
191 | $j = -1; |
||
192 | // Read the data character-by- character… |
||
193 | for ($i = 0, $len = strlen($text); $i < $len; $i++) { |
||
194 | $c = $text[$i]; |
||
195 | |||
196 | // Depending on current character select the further actions. |
||
197 | switch ($c) { |
||
198 | // the most important key word backslash |
||
199 | case "\\": |
||
200 | // read next character |
||
201 | $nc = $text[$i + 1]; |
||
202 | |||
203 | // If it is another backslash or nonbreaking space or hyphen, |
||
204 | // then the character is plain text and add it to the output stream. |
||
205 | if ($nc == '\\' && rtf_isPlainText($stack[$j])) $document .= '\\'; |
||
206 | elseif ($nc == '~' && rtf_isPlainText($stack[$j])) $document .= ' '; |
||
207 | elseif ($nc == '_' && rtf_isPlainText($stack[$j])) $document .= '-'; |
||
208 | // If it is an asterisk mark, add it to the stack. |
||
209 | elseif ($nc == '*') $stack[$j]["*"] = true; |
||
210 | // If it is a single quote, read next two characters that are the hexadecimal notation |
||
211 | // of a character we should add to the output stream. |
||
212 | elseif ($nc == "'") { |
||
213 | $hex = substr($text, $i + 2, 2); |
||
214 | if (rtf_isPlainText($stack[$j])) |
||
215 | $document .= html_entity_decode("&#".hexdec($hex).";"); |
||
216 | //Shift the pointer. |
||
217 | $i += 2; |
||
218 | // Since, we’ve found the alphabetic character, the next characters are control word |
||
219 | // and, possibly, some digit parameter. |
||
220 | } elseif ($nc >= 'a' && $nc <= 'z' || $nc >= 'A' && $nc <= 'Z') { |
||
221 | $word = ""; |
||
222 | $param = null; |
||
223 | |||
224 | // Start reading characters after the backslash. |
||
225 | for ($k = $i + 1, $m = 0; $k < strlen($text); $k++, $m++) { |
||
226 | $nc = $text[$k]; |
||
227 | // If the current character is a letter and there were no digits before it, |
||
228 | // then we’re still reading the control word. If there were digits, we should stop |
||
229 | // since we reach the end of the control word. |
||
230 | if ($nc >= 'a' && $nc <= 'z' || $nc >= 'A' && $nc <= 'Z') { |
||
231 | if (empty($param)) |
||
232 | $word .= $nc; |
||
233 | else |
||
234 | break; |
||
235 | // If it is a digit, store the parameter. |
||
236 | } elseif ($nc >= '0' && $nc <= '9') |
||
237 | $param .= $nc; |
||
238 | // Since minus sign may occur only before a digit parameter, check whether |
||
239 | // $param is empty. Otherwise, we reach the end of the control word. |
||
240 | elseif ($nc == '-') { |
||
241 | if (empty($param)) |
||
242 | $param .= $nc; |
||
243 | else |
||
244 | break; |
||
245 | } else |
||
246 | break; |
||
247 | } |
||
248 | // Shift the pointer on the number of read characters. |
||
249 | $i += $m - 1; |
||
250 | |||
251 | // Start analyzing what we’ve read. We are interested mostly in control words. |
||
252 | $toText = ""; |
||
253 | switch (strtolower($word)) { |
||
254 | // If the control word is "u", then its parameter is the decimal notation of the |
||
255 | // Unicode character that should be added to the output stream. |
||
256 | // We need to check whether the stack contains \ucN control word. If it does, |
||
257 | // we should remove the N characters from the output stream. |
||
258 | case "u": |
||
259 | $toText .= html_entity_decode("&#x".dechex($param).";"); |
||
260 | $ucDelta = @$stack[$j]["uc"]; |
||
261 | if ($ucDelta > 0) |
||
262 | $i += $ucDelta; |
||
263 | break; |
||
264 | // Select line feeds, spaces and tabs. |
||
265 | case "par": case "page": case "column": case "line": case "lbr": |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
266 | $toText .= "\n"; |
||
267 | break; |
||
268 | case "emspace": case "enspace": case "qmspace": |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
269 | $toText .= " "; |
||
270 | break; |
||
271 | case "tab": $toText .= "\t"; break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
272 | // Add current date and time instead of corresponding labels. |
||
273 | case "chdate": $toText .= date("m.d.Y"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
274 | case "chdpl": $toText .= date("l, j F Y"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
275 | case "chdpa": $toText .= date("D, j M Y"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
276 | case "chtime": $toText .= date("H:i:s"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
277 | // Replace some reserved characters to their html analogs. |
||
278 | case "emdash": $toText .= html_entity_decode("—"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
279 | case "endash": $toText .= html_entity_decode("–"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
280 | case "bullet": $toText .= html_entity_decode("•"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
281 | case "lquote": $toText .= html_entity_decode("‘"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
282 | case "rquote": $toText .= html_entity_decode("’"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
283 | case "ldblquote": $toText .= html_entity_decode("«"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
284 | case "rdblquote": $toText .= html_entity_decode("»"); break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
285 | // Add all other to the control words stack. If a control word |
||
286 | // does not include parameters, set ¶m to true. |
||
287 | default: |
||
288 | $stack[$j][strtolower($word)] = empty($param) ? true : $param; |
||
289 | break; |
||
290 | } |
||
291 | // Add data to the output stream if required. |
||
292 | if (rtf_isPlainText($stack[$j])) |
||
293 | $document .= $toText; |
||
294 | } |
||
295 | |||
296 | $i++; |
||
297 | break; |
||
298 | // If we read the opening brace {, then new subgroup starts and we add |
||
299 | // new array stack element and write the data from previous stack element to it. |
||
300 | case "{": |
||
301 | array_push($stack, $stack[$j++]); |
||
302 | break; |
||
303 | // If we read the closing brace }, then we reach the end of subgroup and should remove |
||
304 | // the last stack element. |
||
305 | case "}": |
||
306 | array_pop($stack); |
||
307 | $j--; |
||
308 | break; |
||
309 | // Skip “trash”. |
||
310 | case '\0': case '\r': case '\f': case '\n': break; |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() Terminating statement must be on a line by itself
As per the PSR-2 coding standard, the switch ($expr) {
case "A":
doSomething();
break; //wrong
case "B":
doSomething();
break; //right
case "C:":
doSomething();
return true; //right
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
311 | // Add other data to the output stream if required. |
||
312 | default: |
||
313 | if (rtf_isPlainText($stack[$j])) |
||
314 | $document .= $c; |
||
315 | break; |
||
316 | } |
||
317 | } |
||
318 | // Return result. |
||
319 | return $document; |
||
320 | } |
This check looks for the bodies of
if
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
if
bodies can be removed. If you have an empty if but statements in theelse
branch, consider inverting the condition.could be turned into
This is much more concise to read.