| 1 | <?php |
||
| 20 | class LogEntry |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Holds this log timestamp. |
||
| 25 | * @var integer |
||
| 26 | */ |
||
| 27 | public $timestamp; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Holds this log name. |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | public $name; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Holds this log level code. |
||
| 37 | * @var integer |
||
| 38 | */ |
||
| 39 | public $level_code; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Holds this log message. |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public $message; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Holds this log context. |
||
| 49 | * @var array |
||
| 50 | */ |
||
| 51 | public $context; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Holds this log formatter. |
||
| 55 | * @var LogFormatter |
||
| 56 | */ |
||
| 57 | public $formatter; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Constructor. |
||
| 61 | * |
||
| 62 | * @param string $name The level name. |
||
| 63 | * @param string $message The message for this log entry. |
||
| 64 | * @param array $context The contexts for this log entry. |
||
| 65 | */ |
||
| 66 | 728 | public function __construct($name, $message, array $context = array()) |
|
| 81 | |||
| 82 | 712 | public function setFormatter(LogFormatter $formatter) |
|
| 86 | |||
| 87 | /** |
||
| 88 | * Returns the formated string for this log entry. |
||
| 89 | * |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | 692 | public function __toString() |
|
| 96 | |||
| 97 | } |
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 mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.