test_ajax.php ➔ jhdbg786213u8dsfg7y()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 54 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
//error_reporting(E_ALL);
3
set_include_path(
4
	get_include_path().PATH_SEPARATOR
5
	.'zend-framework/'
6
);
7
8
require_once('../PhpQuery/PhpQuery.php');
9
PhpQuery::$debug = true;
0 ignored issues
show
Bug introduced by
The property debug cannot be accessed from this context as it is declared private in class PhpQuery.

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.

Loading history...
Documentation Bug introduced by
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...
10
PhpQuery::$ajaxAllowedHosts[] = 'wikipedia.org';
11
PhpQuery::$ajaxAllowedHosts[] = 'google.com';
12
PhpQuery::$ajaxAllowedHosts[] = 'code.google.com';
13
PhpQuery::$ajaxAllowedHosts[] = 'www.google.com';
14
15
//$pq = PhpQuery::ajax(array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% 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...
16
//	'url' => 'http://wikipedia.org/',
17
//	'success' => 'v87shs79d8fhs9d'
18
//));
19
//function v87shs79d8fhs9d($html) {
20
//	$title = PhpQuery::newDocument($html)->find('title');
21
//	$testName = 'Simple AJAX';
22
//	if ( strpos(strtolower($title->html()), 'wikipedia') !== false )
23
//		print "Test '$testName' PASSED :)";
24
//	else {
25
//		print "Test '$testName' <strong>FAILED</strong> !!! ";
26
//		print "<pre>";
27
//		print_r($title->whois());
28
//		print "</pre>\n";
29
//	}
30
//	print "\n";
31
//}
32
33
34
$testName = 'Load';
35
$test = PhpQuery::newDocumentFile('test.html')
0 ignored issues
show
Bug introduced by
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...
36
	->find('div:first')
37
	->load('http://wikipedia.org/ div[lang]');
38
if (pq('div[lang]')->size())
39
	print "Test '$testName' PASSED :)";
40
else {
41
	print "Test '$testName' <strong>FAILED</strong> !!! ";
42
	print "<pre>";
43
	print "</pre>\n";
44
}
45
print "\n";
46
47
48
// http://code.google.com/p/phpquery/issues/detail?id=130
49
$pq = PhpQuery::ajax(array(
0 ignored issues
show
Bug introduced by
The method ajax() 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...
50
	'url' => 'http://'.$_SERVER['SERVER_NAME'].preg_replace('@/[^/]+$@', '/test_ajax_data_1', $_SERVER['REQUEST_URI']),
51
	'success' => 'a789fhasdui3124',
52
	'error' => 'jhdbg786213u8dsfg7y'
53
));
54
function a789fhasdui3124($html) {
55
	$testName = 'AJAX request text node';
56
	if ( $html == 'hello world' )
57
		print "Test '$testName' PASSED :)";
58
	else {
59
		print "Test '$testName' <strong>FAILED</strong> !!! ";
60
	}
61
	print "\n";
62
}
63
64
function jhdbg786213u8dsfg7y() {
65
	$testName = 'AJAX request text node';
66
	print "Test '$testName' <strong>FAILED</strong> !!! ";
67
}
68
69
70
//$testName = 'gdata plugin';
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
71
//PhpQuery::extend('gdata');
72
//$xhr = PhpQuery::$plugins->gdata('[email protected]', 'XXX');
73
//$url = 'http://code.google.com/p/phpquery/w/edit/Callbacks';
74
//PhpQuery::ajax(array('url' => $url, 'success' => 'ksjsdgh892jh23'), $xhr);
75
//function ksjsdgh892jh23($html) {
76
//	print $html;
77
//	print pq($html)->find('script')->remove()->end();
78
//	if (pq('div[lang]')->size())
79
//		print "Test '$testName' PASSED :)";
80
//	else {
81
//		print "Test '$testName' <strong>FAILED</strong> !!! ";
82
//		print "<pre>";
83
//		print "</pre>\n";
84
//	}
85
//	print "\n";
86
//}