Fatal error on NoOperationMonologHandler::write()
KaspervdHeijden opened this issue · 2 comments
KaspervdHeijden commented
Problem synopsis
Got the following exception:
PHP Fatal error: Declaration of JiraRestApi\NoOperationMonologHandler::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void in vendor/lesstif/php-jira-rest-client/src/NoOperationMonologHandler.php on line 16
It seems the parent abstract class has the argument typehinted as LogRecord
, but the NoOperationMonologHandler::write()
method uses array
instead.
How to reproduce?
Switch off logging (E.g. by passing 'jiraLogEnabled' => false
)
KaspervdHeijden commented
Fixed the issue with this patch:
diff --git a/src/NoOperationMonologHandler.php b/src/NoOperationMonologHandler.php
index f319d76..5dc8a0e 100644
--- a/src/NoOperationMonologHandler.php
+++ b/src/NoOperationMonologHandler.php
@@ -3,17 +3,18 @@
namespace JiraRestApi;
use Monolog\Handler\AbstractProcessingHandler;
+use Monolog\LogRecord;
class NoOperationMonologHandler extends AbstractProcessingHandler
{
/**
* Writes the record down to the log of the implementing handler.
*
- * @param array $record
+ * @param LogRecord $record
*
* @return void
*/
- protected function write(array $record): void
+ protected function write(LogRecord $record): void
{
// do nothing
}
lesstif commented
Hi @KaspervdHeijden Thank you for your contribution.
Your code will be working well, however, Monolog has a broken change between 2.x and 3.x, so if I merge it then 2.x users will face the errors.
I will push new code instead of merging your suggestions.
Thanks!