1 | <?php |
||
21 | class Helper { |
||
22 | |||
23 | /** @var Connector|null */ |
||
24 | private static $connector; |
||
25 | /** @var Handler|null */ |
||
26 | private static $handler; |
||
27 | /** @var bool */ |
||
28 | protected static $isActive; |
||
29 | |||
30 | private function __construct() { |
||
32 | |||
33 | /** |
||
34 | * This method must be called to make class "PC" available |
||
35 | * @param Connector|null $connector |
||
36 | * @param Handler|null $handler |
||
37 | * @throws \Exception |
||
38 | * @return Connector |
||
39 | */ |
||
40 | 9 | public static function register(Connector $connector = null, Handler $handler = null) { |
|
49 | |||
50 | /** |
||
51 | * Check if method Helper::register() was called before |
||
52 | * @return bool |
||
53 | */ |
||
54 | 2 | public static function isRegistered() { |
|
57 | |||
58 | /** |
||
59 | * Get actual helper connector instance |
||
60 | * @return Connector |
||
61 | * @throws \Exception |
||
62 | */ |
||
63 | 3 | public static function getConnector() { |
|
69 | |||
70 | /** |
||
71 | * Get actual handler instance |
||
72 | * @return Handler |
||
73 | * @throws \Exception |
||
74 | */ |
||
75 | 3 | public static function getHandler() { |
|
84 | |||
85 | /** |
||
86 | * Analog of Handler::getInstance()->debug(...) method |
||
87 | * @param mixed $data |
||
88 | * @param string|null $tags Tags separated by dot, e.g. "low.db.billing" |
||
89 | * @param int|array $ignoreTraceCalls Ignore tracing classes by name prefix `array('PhpConsole')` or fixed number of calls to ignore |
||
90 | */ |
||
91 | 3 | public static function debug($data, $tags = null, $ignoreTraceCalls = 0) { |
|
96 | |||
97 | /** |
||
98 | * Short access to analog of Handler::getInstance()->debug(...) method |
||
99 | * You can access it like PC::tagName($debugData, $additionalTags = null) |
||
100 | * @param string $tags |
||
101 | * @param $args |
||
102 | */ |
||
103 | 1 | public static function __callStatic($tags, $args) { |
|
109 | } |
||
110 | } |
||
125 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: