CallbackTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A callback2() 0 3 1
A callback1() 0 3 1
A testExtend() 0 12 1
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 8 and the first side effect is on line 4.

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
//if (PHP_VERSION < 5.3)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
3
//	throw new \Exception("This test case is only for PHP 5.3 and above.");
4
require('/home/bob/Sources/php/simpletest/simpletest/trunk/autorun.php');
5
require_once('../PhpQuery/PhpQuery.php');
6
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...
7
8
class CallbackTest extends UnitTestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
	public function callback2() {
10
		return 'callback2';
11
	}
12
	public function callback1($self) {
13
		return $self;
14
	}	
15
	public function testExtend() {
16
		$newMethods = array(
17
			'newMethod1' => array($this, 'callback1'),
18
			'newMethod2' => array($this, 'callback2'),
19
		);
20
		PhpQuery::extend('PhpQueryObject', $newMethods);
0 ignored issues
show
Bug introduced by
The method extend() 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...
21
		$doc = PhpQuery::newDocumentXML("<div/>");
0 ignored issues
show
Bug introduced by
The method newDocumentXML() 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...
22
		$this->assertTrue($doc->newMethod1() == $doc,
23
			'$doc->newMethod1 == $doc');
24
		$this->assertTrue($doc->newMethod2() == "callback2",
25
			'$doc->newMethod1 == "callback2"');  
26
	}
27
}