1 | <?php |
||
8 | class PrefixedLogger implements LoggerInterface { |
||
9 | /** |
||
10 | * @var Logger |
||
11 | */ |
||
12 | private $logger; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $prefix; |
||
18 | |||
19 | /** |
||
20 | * PrefixedLogger constructor. |
||
21 | * |
||
22 | * @param LoggerInterface $logger |
||
23 | * @param prefix $prefix |
||
24 | */ |
||
25 | public function __construct(LoggerInterface $logger, $prefix = null) { |
||
29 | |||
30 | /** |
||
31 | * @param string $method |
||
32 | * @param array $args |
||
33 | * |
||
34 | * @return mixed |
||
35 | */ |
||
36 | public function __call($method, array $args) { |
||
39 | |||
40 | /** |
||
41 | * @return Logger |
||
42 | */ |
||
43 | public function getLogger() { |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | public function getPrefix() { |
||
53 | |||
54 | /** |
||
55 | * System is unusable. |
||
56 | * |
||
57 | * @param string $message |
||
58 | * @param array $context |
||
59 | * |
||
60 | * @return null |
||
61 | */ |
||
62 | public function emergency($message, array $context = []) { |
||
65 | |||
66 | /** |
||
67 | * Action must be taken immediately. |
||
68 | * |
||
69 | * Example: Entire website down, database unavailable, etc. This should |
||
70 | * trigger the SMS alerts and wake you up. |
||
71 | * |
||
72 | * @param string $message |
||
73 | * @param array $context |
||
74 | * |
||
75 | * @return null |
||
76 | */ |
||
77 | public function alert($message, array $context = []) { |
||
80 | |||
81 | /** |
||
82 | * Critical conditions. |
||
83 | * |
||
84 | * Example: Application component unavailable, unexpected exception. |
||
85 | * |
||
86 | * @param string $message |
||
87 | * @param array $context |
||
88 | * |
||
89 | * @return null |
||
90 | */ |
||
91 | public function critical($message, array $context = []) { |
||
94 | |||
95 | /** |
||
96 | * Runtime errors that do not require immediate action but should typically |
||
97 | * be logged and monitored. |
||
98 | * |
||
99 | * @param string $message |
||
100 | * @param array $context |
||
101 | * |
||
102 | * @return null |
||
103 | */ |
||
104 | public function error($message, array $context = []) { |
||
107 | |||
108 | /** |
||
109 | * Exceptional occurrences that are not errors. |
||
110 | * |
||
111 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
112 | * that are not necessarily wrong. |
||
113 | * |
||
114 | * @param string $message |
||
115 | * @param array $context |
||
116 | * |
||
117 | * @return null |
||
118 | */ |
||
119 | public function warning($message, array $context = []) { |
||
122 | |||
123 | /** |
||
124 | * Normal but significant events. |
||
125 | * |
||
126 | * @param string $message |
||
127 | * @param array $context |
||
128 | * |
||
129 | * @return null |
||
130 | */ |
||
131 | public function notice($message, array $context = []) { |
||
134 | |||
135 | /** |
||
136 | * Interesting events. |
||
137 | * |
||
138 | * Example: User logs in, SQL logs. |
||
139 | * |
||
140 | * @param string $message |
||
141 | * @param array $context |
||
142 | * |
||
143 | * @return null |
||
144 | */ |
||
145 | public function info($message, array $context = []) { |
||
148 | |||
149 | /** |
||
150 | * Detailed debug information. |
||
151 | * |
||
152 | * @param string $message |
||
153 | * @param array $context |
||
154 | * |
||
155 | * @return null |
||
156 | */ |
||
157 | public function debug($message, array $context = []) { |
||
160 | |||
161 | /** |
||
162 | * Logs with an arbitrary level. |
||
163 | * |
||
164 | * @param mixed $level |
||
165 | * @param string $message |
||
166 | * @param array $context |
||
167 | * |
||
168 | * @return null |
||
169 | */ |
||
170 | public function log($level, $message, array $context = []) { |
||
173 | |||
174 | /** |
||
175 | * @param string $message |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | protected function prefixMessage($message) { |
||
186 | |||
187 | /** |
||
188 | * @param string|object $prefix |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | protected function determinePrefix($prefix) { |
||
201 | } |
||
202 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.