Issues (4069)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

modules/AOD_Index/LuceneUtils.php (30 issues)

Upgrade to new PHP Analysis Engine

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
This if statement is empty and can be removed.

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 the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
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
Performance Best Practice introduced by
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
}
Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
277
                        // Replace some reserved characters to their html analogs.
278
                        case "emdash": $toText .= html_entity_decode("&mdash;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
279
                        case "endash": $toText .= html_entity_decode("&ndash;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
280
                        case "bullet": $toText .= html_entity_decode("&#149;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
281
                        case "lquote": $toText .= html_entity_decode("&lsquo;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
282
                        case "rquote": $toText .= html_entity_decode("&rsquo;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
283
                        case "ldblquote": $toText .= html_entity_decode("&laquo;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
284
                        case "rdblquote": $toText .= html_entity_decode("&raquo;"); 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
285
                        // Add all other to the control words stack. If a control word
286
                        // does not include parameters, set &param 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.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

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.

Loading history...
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
}