1 | <?php |
||
21 | class FlashMessages |
||
22 | { |
||
23 | /** |
||
24 | * @var SessionDriverInterface |
||
25 | */ |
||
26 | private $sessionDriver; |
||
27 | |||
28 | /**#@+ |
||
29 | * @const string TYPE for message type constants |
||
30 | */ |
||
31 | const TYPE_SUCCESS = 0; |
||
32 | const TYPE_ERROR = 1; |
||
33 | const TYPE_WARNING = 2; |
||
34 | const TYPE_INFO = 3; |
||
35 | /**#@-*/ |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private static $messages = []; |
||
41 | |||
42 | /** |
||
43 | * Creates a flash messages service |
||
44 | * |
||
45 | * @param SessionDriverInterface $sessionDriver |
||
46 | */ |
||
47 | public function __construct(SessionDriverInterface $sessionDriver) |
||
51 | |||
52 | /** |
||
53 | * Set a flash message of a give type |
||
54 | * |
||
55 | * @param int $type |
||
56 | * @param string $message |
||
57 | * |
||
58 | * @return FlashMessages |
||
59 | */ |
||
60 | public function set($type, $message) |
||
70 | |||
71 | /** |
||
72 | * clears all messages |
||
73 | * |
||
74 | * @return FlashMessages |
||
75 | */ |
||
76 | public function flush() |
||
82 | |||
83 | /** |
||
84 | * Retrieve all messages and flushes them all |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function get() |
||
94 | |||
95 | /** |
||
96 | * Add an info flash message |
||
97 | * |
||
98 | * @param string $message |
||
99 | * @return self |
||
100 | */ |
||
101 | public function addInfoMessage($message) |
||
105 | /** |
||
106 | * Add a warning flash message |
||
107 | * |
||
108 | * @param string $message |
||
109 | * @return self |
||
110 | */ |
||
111 | public function addWarningMessage($message) |
||
115 | /** |
||
116 | * Add an error flash message |
||
117 | * |
||
118 | * @param string $message |
||
119 | * @return self |
||
120 | */ |
||
121 | public function addErrorMessage($message) |
||
125 | /** |
||
126 | * Add a success flash message |
||
127 | * |
||
128 | * @param string $message |
||
129 | * @return self |
||
130 | */ |
||
131 | public function addSuccessMessage($message) |
||
135 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: