These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | include 'php/jodel-web.php'; |
||
4 | |||
5 | View Code Duplication | if(isset($_GET['view'])) |
|
0 ignored issues
–
show
|
|||
6 | { |
||
7 | switch ($_GET['view']) { |
||
8 | case 'comment': |
||
9 | $view = 'comment'; |
||
10 | break; |
||
11 | |||
12 | case 'upVote': |
||
13 | $view = 'upVote'; |
||
14 | break; |
||
15 | |||
16 | default: |
||
17 | $view = 'time'; |
||
18 | break; |
||
19 | } |
||
20 | } |
||
21 | else |
||
22 | { |
||
23 | $view = 'time'; |
||
24 | } |
||
25 | |||
26 | if($view=='comment') |
||
27 | { |
||
28 | $url = "/v2/posts/location/discussed/"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
/v2/posts/location/discussed/ does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
29 | } |
||
30 | else |
||
31 | { |
||
32 | if($view=='upVote') |
||
33 | { |
||
34 | $url = "/v2/posts/location/popular/"; |
||
35 | } |
||
36 | else |
||
37 | { |
||
38 | $url = "/v2/posts/location/"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
/v2/posts/location/ does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
39 | } |
||
40 | } |
||
41 | |||
42 | if(isset($_GET['lastPostId'])) |
||
43 | { |
||
44 | $lastPostId = htmlspecialchars($_GET['lastPostId']); |
||
45 | |||
46 | $posts = $viewTest->getPosts($lastPostId, $jodelAccountForView->accessToken, $url)['posts']; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
47 | $loops = 29; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
48 | $showCommentIcon = TRUE; |
||
49 | ?> |
||
50 | <div class="nextPosts"> |
||
51 | <?php |
||
52 | for($i = 0; $i<$loops; $i++) |
||
53 | { |
||
54 | if(isset($posts[$i])) |
||
55 | { |
||
56 | $lastPostId = $posts[$i]['post_id']; |
||
57 | $viewTest->jodelToHtml($posts[$i], $view); |
||
58 | } |
||
59 | } |
||
60 | ?> |
||
61 | </div> |
||
62 | <div class="lastPostId"> |
||
63 | <?php echo $lastPostId; ?> |
||
64 | </div> |
||
65 | <?php |
||
66 | } |
||
67 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.