| 1 | <?php |
||
| 24 | trait TPayloadLogger |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * Check if the logger has a method name 'getContext'. |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | protected function hasLogContext() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get an instance of the context class or null if not a valid logger. |
||
| 37 | * @return mixed | null |
||
| 38 | */ |
||
| 39 | protected function getLogContext() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Get context data from the logger if the logger has one. |
||
| 46 | * |
||
| 47 | * @param string |
||
| 48 | * @param array |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | protected function getLogContextData($class, array $logData=[]) |
||
| 56 | } |
||
| 57 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: