1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once(__DIR__ . '/../../src/PhpConsole/__autoload.php'); |
4
|
|
|
|
5
|
|
|
// Call debug from PhpConsole\Handler |
6
|
|
|
$handler = PhpConsole\Handler::getInstance(); |
7
|
|
|
$handler->start(); |
8
|
|
|
$handler->debug('called from handler debug', 'some.three.tags'); |
9
|
|
|
|
10
|
|
|
// Call debug from PhpConsole\Connector (if you don't use PhpConsole\Handler in your project) |
11
|
|
|
PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug('called from debug dispatcher without tags'); |
12
|
|
|
|
13
|
|
|
// Call debug from global PC class-helper (most short & easy way) |
14
|
|
|
PhpConsole\Helper::register(); // required to register PC class in global namespace, must be called only once |
15
|
|
|
PC::debug('called from PC::debug()', 'db'); |
16
|
|
|
PC::db('called from PC::__callStatic()'); // means "db" will be handled as debug tag |
17
|
|
|
|
18
|
|
|
// Debug some mixed variable |
19
|
|
|
|
20
|
|
|
class DebugExample { |
|
|
|
|
21
|
|
|
|
22
|
|
|
private $privateProperty = 1; |
23
|
|
|
protected $protectedProperty = 2; |
24
|
|
|
public $publicProperty = 3; |
25
|
|
|
public $selfProperty; |
26
|
|
|
|
27
|
|
|
public function __construct() { |
28
|
|
|
$this->selfProperty = $this; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function someMethod() { |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
PhpConsole\Connector::getInstance()->getDebugDispatcher()->setDumper( |
36
|
|
|
new PhpConsole\Dumper(2, 10, 40) // set new dumper with levelLimit=2, itemsCountLimit=10, itemSizeLimit=10 |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
$s = new stdClass(); |
40
|
|
|
$s->asd = array(array(123)); |
41
|
|
|
|
42
|
|
|
PC::debug(array( |
43
|
|
|
'null' => null, |
44
|
|
|
'boolean' => true, |
45
|
|
|
'longString' => '11111111112222222222333333333344444444445', |
46
|
|
|
'someObject' => new DebugExample(), |
47
|
|
|
'someCallback' => array(new DebugExample(), 'someMethod'), |
48
|
|
|
'someClosure' => function () { |
49
|
|
|
}, |
50
|
|
|
'someResource' => fopen(__FILE__, 'r'), |
51
|
|
|
'manyItemsArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), |
52
|
|
|
'deepLevelArray' => array(1 => array(2 => array(3))), |
53
|
|
|
)); |
54
|
|
|
|
55
|
|
|
// Trace debug call |
56
|
|
|
|
57
|
|
|
PC::getConnector()->getDebugDispatcher()->detectTraceAndSource = true; |
58
|
|
|
|
59
|
|
|
function a() { |
60
|
|
|
b(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
function b() { |
64
|
|
|
PC::debug('Message with source & trace detection'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
a(); |
68
|
|
|
|
69
|
|
|
echo 'See debug messages in JavaScript Console(Ctrl+Shift+J) and in Notification popups. Click on PHP Console icon in address bar to see configuration options.'; |
70
|
|
|
|
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.