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 = 'success'; |
||
32 | const TYPE_ERROR = 'danger'; |
||
33 | const TYPE_WARNING = 'warning'; |
||
34 | const TYPE_INFO = 'info'; |
||
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) |
||
73 | |||
74 | /** |
||
75 | * clears all messages |
||
76 | * |
||
77 | * @return FlashMessages |
||
78 | */ |
||
79 | public function flush() |
||
85 | |||
86 | /** |
||
87 | * Retrieve all messages and flushes them all |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function messages() |
||
97 | |||
98 | /** |
||
99 | * Add an info flash message |
||
100 | * |
||
101 | * @param string $message |
||
102 | * @return self |
||
103 | */ |
||
104 | public function addInfo($message) |
||
108 | /** |
||
109 | * Add a warning flash message |
||
110 | * |
||
111 | * @param string $message |
||
112 | * @return self |
||
113 | */ |
||
114 | public function addWarning($message) |
||
118 | /** |
||
119 | * Add an error flash message |
||
120 | * |
||
121 | * @param string $message |
||
122 | * @return self |
||
123 | */ |
||
124 | public function addError($message) |
||
128 | /** |
||
129 | * Add a success flash message |
||
130 | * |
||
131 | * @param string $message |
||
132 | * @return self |
||
133 | */ |
||
134 | public function addSuccess($message) |
||
138 | } |
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: