c-harris /
phpquery
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 | require_once('../PhpQuery/PhpQuery.php'); |
||
| 3 | PhpQuery::$debug = true; |
||
|
0 ignored issues
–
show
The property
$debug was declared of type integer, but true is of type boolean. Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
Loading history...
|
|||
| 4 | |||
| 5 | |||
| 6 | $testName = 'Simple data insertion'; |
||
| 7 | $testResult = <<<EOF |
||
| 8 | <div class="articles"> |
||
| 9 | div.articles text node |
||
| 10 | <ul> |
||
| 11 | |||
| 12 | <li> |
||
| 13 | <p>This is paragraph of first LI</p> |
||
| 14 | <p class="title">News 1 title</p> |
||
| 15 | <p class="body">News 1 body</p> |
||
| 16 | </li> |
||
| 17 | |||
| 18 | <li> |
||
| 19 | <p>This is paragraph of first LI</p> |
||
| 20 | <p class="title">News 2 title</p> |
||
| 21 | <p class="body">News 2 body</p> |
||
| 22 | </li> |
||
| 23 | <li> |
||
| 24 | <p>This is paragraph of first LI</p> |
||
| 25 | <p class="title">News 3</p> |
||
| 26 | <p class="body">News 3 body</p> |
||
| 27 | </li> |
||
| 28 | </ul> |
||
| 29 | <p>paragraph after UL</p> |
||
| 30 | </div> |
||
| 31 | EOF; |
||
| 32 | $rows = array( |
||
| 33 | array( |
||
| 34 | 'title' => 'News 1 title', |
||
| 35 | 'body' => 'News 1 body', |
||
| 36 | ), |
||
| 37 | array( |
||
| 38 | 'title' => 'News 2 title', |
||
| 39 | 'body' => 'News 2 body', |
||
| 40 | ), |
||
| 41 | array( |
||
| 42 | 'title' => 'News 3', |
||
| 43 | 'body' => 'News 3 body', |
||
| 44 | ), |
||
| 45 | ); |
||
| 46 | PhpQuery::newDocumentFile('test.html'); |
||
|
0 ignored issues
–
show
The method
newDocumentFile() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 47 | $articles = pq('.articles ul'); |
||
| 48 | $rowSrc = $articles->find('li') |
||
| 49 | ->remove() |
||
| 50 | ->eq(0); |
||
| 51 | View Code Duplication | foreach( $rows as $r ) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 52 | $row = $rowSrc->_clone(); |
||
| 53 | foreach( $r as $field => $value ) { |
||
| 54 | $row->find(".{$field}") |
||
| 55 | ->html($value); |
||
| 56 | // die($row->htmlOuter()); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
80% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 57 | } |
||
| 58 | $row->appendTo($articles); |
||
| 59 | } |
||
| 60 | $result = pq('.articles')->htmlOuter(); |
||
| 61 | //print htmlspecialchars("<pre>{$result}</pre>").'<br />'; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 62 | $similarity = 0.0; |
||
| 63 | similar_text($testResult, $result, $similarity); |
||
| 64 | if ($similarity > 90) |
||
| 65 | print "Test '{$testName}' passed :)"; |
||
| 66 | else |
||
| 67 | print "Test '{$testName}' <strong>FAILED</strong> ($similarity) !!!"; |
||
| 68 | print "\n"; |
||
| 69 | |||
| 70 | |||
| 71 | $testName = 'Parent && children'; |
||
| 72 | $result = PhpQuery::newDocumentFile('test.html'); |
||
|
0 ignored issues
–
show
The method
newDocumentFile() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 73 | $parent = $result->find('ul:first'); |
||
| 74 | $children = $parent->find('li:first'); |
||
| 75 | $e = null; |
||
| 76 | try { |
||
| 77 | $children->before('<li>test</li>'); |
||
| 78 | } catch(Exception $e) { |
||
| 79 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
||
| 80 | } |
||
| 81 | if (! $e) { |
||
| 82 | print "Test '{$testName}' PASSED :)"; |
||
| 83 | } |
||
| 84 | print "\n"; |
||
| 85 | |||
| 86 | |||
| 87 | $testName = 'HTML insertion'; |
||
| 88 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
||
|
0 ignored issues
–
show
The method
newDocument() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 89 | $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre <b>0°C et 210°C</b>."; |
||
| 90 | $doc->find('p')->html($string); |
||
| 91 | View Code Duplication | if (pq('p')->length == 1) |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 92 | print "Test '{$testName}' PASSED :)"; |
||
| 93 | else { |
||
| 94 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
||
| 95 | print $doc->htmlOuter('htmlentities'); |
||
| 96 | } |
||
| 97 | print "\n"; |
||
| 98 | |||
| 99 | |||
| 100 | $testName = 'HTML insertion 2'; |
||
| 101 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
||
|
0 ignored issues
–
show
The method
newDocument() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 102 | $string = "<div>La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre <b>0°C et 210°C</b>.</div>"; |
||
| 103 | $doc->find('p')->html($string); |
||
| 104 | View Code Duplication | if (pq('div')->length == 2) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 105 | print "Test '{$testName}' PASSED :)"; |
||
| 106 | } else { |
||
| 107 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
||
| 108 | print $doc->htmlOuter('htmlentities'); |
||
| 109 | } |
||
| 110 | print "\n"; |
||
| 111 | |||
| 112 | |||
| 113 | $testName = 'HTML insertion 3'; |
||
| 114 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
||
|
0 ignored issues
–
show
The method
newDocument() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 115 | $string = 'Hors paragraphe. |
||
| 116 | <img align="right" src="http://www.stlouisstpierre.com/institution/images/plan.jpg"> |
||
| 117 | <p>Éditorial de l\'institution Saint-Pierre.</p> |
||
| 118 | Hors paragraphe.'; |
||
| 119 | $doc->find('p')->html($string); |
||
| 120 | View Code Duplication | if (pq('img')->length == 1) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 121 | print "Test '{$testName}' PASSED :)"; |
||
| 122 | print $doc->htmlOuter(); |
||
| 123 | } else { |
||
| 124 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
||
| 125 | print $doc->htmlOuter('htmlentities'); |
||
| 126 | } |
||
| 127 | print "\n"; |
||
| 128 | |||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | $testName = 'Text insertion'; |
||
| 133 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
||
|
0 ignored issues
–
show
The method
newDocument() does not seem to exist on object<PhpQuery>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 134 | $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie"; |
||
| 135 | $doc->find('p')->html($string); |
||
| 136 | if (trim(pq('p:first')->html()) == $string) |
||
| 137 | print "Test '{$testName}' PASSED :)"; |
||
| 138 | else { |
||
| 139 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
||
| 140 | print $doc->htmlOuter('htmlentities'); |
||
| 141 | } |
||
| 142 | print "\n"; |
||
| 143 | ?> |
||
|
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.