99use Psr \Log \LogLevel ;
1010use SimpleSAML \Assert \Assert ;
1111use SimpleSAML \Logger as SspLogger ;
12+ use Stringable ;
13+
14+ use function var_export ;
1215
1316class Logger implements LoggerInterface
1417{
1518 /**
1619 * System is unusable.
1720 *
18- * @param string $message
21+ * @param string|\Stringable $message
1922 * @param array $context
20- *
21- * Type hint not possible due to upstream method signature
2223 */
23- public function emergency ($ message , array $ context = []): void
24+ public function emergency (string | Stringable $ message , array $ context = []): void
2425 {
2526 SspLogger::emergency ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
2627 }
@@ -32,12 +33,10 @@ public function emergency($message, array $context = []): void
3233 * Example: Entire website down, database unavailable, etc. This should
3334 * trigger the SMS alerts and wake you up.
3435 *
35- * @param string $message
36+ * @param string|\Stringable $message
3637 * @param array $context
37- *
38- * Type hint not possible due to upstream method signature
3938 */
40- public function alert ($ message , array $ context = []): void
39+ public function alert (string | Stringable $ message , array $ context = []): void
4140 {
4241 SspLogger::alert ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
4342 }
@@ -48,12 +47,10 @@ public function alert($message, array $context = []): void
4847 *
4948 * Example: Application component unavailable, unexpected exception.
5049 *
51- * @param string $message
50+ * @param string|\Stringable $message
5251 * @param array $context
53- *
54- * Type hint not possible due to upstream method signature
5552 */
56- public function critical ($ message , array $ context = []): void
53+ public function critical (string | Stringable $ message , array $ context = []): void
5754 {
5855 SspLogger::critical ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
5956 }
@@ -63,12 +60,10 @@ public function critical($message, array $context = []): void
6360 * Runtime errors that do not require immediate action but should typically
6461 * be logged and monitored.
6562 *
66- * @param string $message
63+ * @param string|\Stringable $message
6764 * @param array $context
68- *
69- * Type hint not possible due to upstream method signature
7065 */
71- public function error ($ message , array $ context = []): void
66+ public function error (string | Stringable $ message , array $ context = []): void
7267 {
7368 SspLogger::error ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
7469 }
@@ -80,12 +75,10 @@ public function error($message, array $context = []): void
8075 * Example: Use of deprecated APIs, poor use of an API, undesirable things
8176 * that are not necessarily wrong.
8277 *
83- * @param string $message
78+ * @param string|\Stringable $message
8479 * @param array $context
85- *
86- * Type hint not possible due to upstream method signature
8780 */
88- public function warning ($ message , array $ context = []): void
81+ public function warning (string | Stringable $ message , array $ context = []): void
8982 {
9083 SspLogger::warning ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
9184 }
@@ -94,12 +87,10 @@ public function warning($message, array $context = []): void
9487 /**
9588 * Normal but significant events.
9689 *
97- * @param string $message
90+ * @param string|\Stringable $message
9891 * @param array $context
99- *
100- * Type hint not possible due to upstream method signature
10192 */
102- public function notice ($ message , array $ context = []): void
93+ public function notice (string | Stringable $ message , array $ context = []): void
10394 {
10495 SspLogger::notice ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
10596 }
@@ -110,12 +101,10 @@ public function notice($message, array $context = []): void
110101 *
111102 * Example: User logs in, SQL logs.
112103 *
113- * @param string $message
104+ * @param string|\Stringable $message
114105 * @param array $context
115- *
116- * Type hint not possible due to upstream method signature
117106 */
118- public function info ($ message , array $ context = []): void
107+ public function info (string | Stringable $ message , array $ context = []): void
119108 {
120109 SspLogger::info ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
121110 }
@@ -124,12 +113,10 @@ public function info($message, array $context = []): void
124113 /**
125114 * Detailed debug information.
126115 *
127- * @param string $message
116+ * @param string|\Stringable $message
128117 * @param array $context
129- *
130- * Type hint not possible due to upstream method signature
131118 */
132- public function debug ($ message , array $ context = []): void
119+ public function debug (string | Stringable $ message , array $ context = []): void
133120 {
134121 SspLogger::debug ($ message . ($ context ? " " . var_export ($ context , true ) : "" ));
135122 }
@@ -139,19 +126,16 @@ public function debug($message, array $context = []): void
139126 * Logs with an arbitrary level.
140127 *
141128 * @param mixed $level
142- * @param string $message
129+ * @param string|\Stringable $message
143130 * @param array $context
144131 *
145132 * @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
146- *
147- * Type hint not possible due to upstream method signature
148133 */
149- public function log ($ level , $ message , array $ context = []): void
134+ public function log ($ level , string | Stringable $ message , array $ context = []): void
150135 {
151- Assert::string ($ message );
152-
153136 switch ($ level ) {
154- /* From PSR: Calling this method with one of the log level constants
137+ /**
138+ * From PSR: Calling this method with one of the log level constants
155139 * MUST have the same result as calling the level-specific method
156140 */
157141 case LogLevel::ALERT :
0 commit comments