Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
fail-fast: false
matrix:
phpVersion: [8.1, 8.2, 8.3]
symfonyVersion: ["5.4.*", "6.1.*"]
phpVersion: [8.2, 8.3, 8.4]
symfonyVersion: ["5.4.*", "6.4.*", "7.2.*"]

steps:
-
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
}
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-json": "*",
"keboola/common-exceptions": "^1.2",
"monolog/monolog": "^2.3",
"symfony/config": "^5.4|^6.0",
"symfony/filesystem": "^5.4|^6.0",
"symfony/finder": "^5.4|^6.0",
"symfony/property-access": "^5.4|^6.0",
"symfony/serializer": "^5.4|^6.0"
"monolog/monolog": "^3.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/filesystem": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0|^7.0",
"symfony/property-access": "^5.4|^6.0|^7.0",
"symfony/serializer": "^5.4|^6.0|^7.0"
},
"require-dev": {
"devedge/sami-github": "^1.0",
"keboola/coding-standard": "^15.0",
"keboola/php-temp": "^2.0",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5"
"devedge/sami-github": "^1.0.6",
"keboola/coding-standard": "^15.0.1",
"keboola/php-temp": "^2.0.1",
"phpstan/phpstan": "^1.12.24",
"phpunit/phpunit": "^9.6.22"
},
"scripts": {
"tests": "phpunit",
Expand Down
5 changes: 3 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
ignoreErrors:
-
identifier: missingType.iterableValue
- identifier: missingType.iterableValue
- '#Argument of an invalid type array\|object supplied for foreach, only iterables are supported.#'
- message: '#Class Keboola\\Component\\Logger extends @final class Monolog\\Logger.#'
reportUnmatched: false
Comment on lines +5 to +6
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deje se jen na novejsich verzich Monologu a je to delany pres @final v PHPdoc, ne final keyword pred class, takze nejjednodussi prozatim ignorovat.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, no to nám zatopili zase :)

2 changes: 1 addition & 1 deletion src/BaseComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function setEnvironment(): void
error_reporting(E_ALL);

set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline): bool {
if (!(error_reporting() & $errno) || $errno === E_USER_DEPRECATED) {
if (!(error_reporting() & $errno) || $errno === E_USER_DEPRECATED || $errno === E_DEPRECATED) {
// respect error_reporting() level
// libraries used in custom components may emit notices that cannot be fixed
return false;
Expand Down
15 changes: 8 additions & 7 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Keboola\Component\Config\BaseConfig;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger as MonologLogger;

class Logger extends MonologLogger implements Logger\SyncActionLogging, Logger\AsyncActionLogging
Expand All @@ -15,7 +16,7 @@ public static function getDefaultErrorHandler(): StreamHandler
{
$errorHandler = new StreamHandler('php://stderr');
$errorHandler->setBubble(false);
$errorHandler->setLevel(MonologLogger::WARNING);
$errorHandler->setLevel(Level::Warning);
$errorHandler->setFormatter(new LineFormatter("%message%\n"));
return $errorHandler;
}
Expand All @@ -24,7 +25,7 @@ public static function getDefaultLogHandler(): StreamHandler
{
$logHandler = new StreamHandler('php://stdout');
$logHandler->setBubble(false);
$logHandler->setLevel(MonologLogger::INFO);
$logHandler->setLevel(Level::Info);
$logHandler->setFormatter(new LineFormatter("%message%\n"));
return $logHandler;
}
Expand All @@ -33,7 +34,7 @@ public static function getDefaultCriticalHandler(): StreamHandler
{
$handler = new StreamHandler('php://stderr');
$handler->setBubble(false);
$handler->setLevel(MonologLogger::CRITICAL);
$handler->setLevel(Level::Critical);
$handler->setFormatter(new LineFormatter("[%datetime%] %level_name%: %message% %context% %extra%\n"));
return $handler;
}
Expand All @@ -42,7 +43,7 @@ public static function getDefaultDebugHandler(): StreamHandler
{
$handler = new StreamHandler('php://stdout');
$handler->setBubble(false);
$handler->setLevel(MonologLogger::DEBUG);
$handler->setLevel(Level::Debug);
$handler->setFormatter(new LineFormatter("[%datetime%] %level_name%: %message% %context% %extra%\n"));
return $handler;
}
Expand All @@ -51,7 +52,7 @@ public static function getSyncActionErrorHandler(): StreamHandler
{
$logHandler = new StreamHandler('php://stderr');
$logHandler->setBubble(false);
$logHandler->setLevel(MonologLogger::ERROR);
$logHandler->setLevel(Level::Error);
$logHandler->setFormatter(new LineFormatter("%message%\n"));
return $logHandler;
}
Expand All @@ -60,7 +61,7 @@ public static function getSyncActionCriticalHandler(): StreamHandler
{
$logHandler = new StreamHandler('php://stderr');
$logHandler->setBubble(false);
$logHandler->setLevel(MonologLogger::CRITICAL);
$logHandler->setLevel(Level::Critical);
$logHandler->setFormatter(new LineFormatter("%message% %context% %extra%\n", null, false, true));
return $logHandler;
}
Expand All @@ -69,7 +70,7 @@ public static function getSyncActionDebugHandler(): StreamHandler
{
$logHandler = new StreamHandler('php://stdout');
$logHandler->setBubble(false);
$logHandler->setLevel(MonologLogger::DEBUG);
$logHandler->setLevel(Level::Debug);
$logHandler->setFormatter(new LineFormatter("[%datetime%] %level_name%: %message% %context% %extra%\n"));
return $logHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

class LegacyManifestNormalizer implements NormalizerInterface, DenormalizerInterface
{
public function getSupportedTypes(?string $format): array
{
return [
'*' => true,
];
}

public function normalize($object, ?string $format = null, array $context = []): array
{
$data = [];
Expand Down Expand Up @@ -263,12 +270,12 @@ private function setMetadata(
}
}

public function supportsNormalization($data, $format = null): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof ManifestOptions;
}

public function supportsDenormalization($data, $type, $format = null): bool
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return $type === ManifestOptions::class;
}
Expand Down
50 changes: 25 additions & 25 deletions tests/Logger/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Keboola\Component\Config\BaseConfig;
use Keboola\Component\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\LogRecord;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;

Expand All @@ -25,7 +27,7 @@ public function testDefaultHandler(): void
/** @var StreamHandler $streamHandler */
$streamHandler = $handlers[0];
$this->assertSame('php://stderr', $streamHandler->getUrl());
$this->assertSame(Logger::DEBUG, $streamHandler->getLevel());
$this->assertSame(Level::Debug, $streamHandler->getLevel());
}

public function testSetupSyncActionLogging(): void
Expand All @@ -40,32 +42,30 @@ public function testSetupSyncActionLogging(): void
/** @var StreamHandler $streamHandler1 */
$streamHandler1 = $handlers[0];
$this->assertSame('php://stderr', $streamHandler1->getUrl());
$this->assertSame(Logger::CRITICAL, $streamHandler1->getLevel());
$this->assertSame(Level::Critical, $streamHandler1->getLevel());

/** @var StreamHandler $streamHandler2 */
$streamHandler2 = $handlers[1];
$this->assertSame('php://stderr', $streamHandler2->getUrl());
$this->assertSame(Logger::ERROR, $streamHandler2->getLevel());
$this->assertSame(Level::Error, $streamHandler2->getLevel());

// Init streams (stream is created with first message)
$streamHandler1->handle([
'level' => Logger::CRITICAL,
'message' => '',
'extra' => [],
'context' => [],
'datetime' => new DateTimeImmutable(),
'channel' => '',
'level_name' => Logger::getLevelName(Logger::CRITICAL),
]);
$streamHandler2->handle([
'level' => Logger::ERROR,
'message' => '',
'extra' => [],
'context' => [],
'datetime' => new DateTimeImmutable(),
'channel' => '',
'level_name' => Logger::getLevelName(Logger::ERROR),
]);
$streamHandler1->handle(new LogRecord(
datetime: new DateTimeImmutable(),
channel: '',
level: Level::Critical,
message: '',
context: [],
extra: [],
));
$streamHandler2->handle(new LogRecord(
datetime: new DateTimeImmutable(),
channel: '',
level: Level::Error,
message: '',
context: [],
extra: [],
));

// Connect tester (logger) to the streams
/** @var resource $stream1 */
Expand Down Expand Up @@ -143,10 +143,10 @@ public function testDebugLogging(): void
StreamTester::getContent(),
);

$this->assertSame(Logger::CRITICAL, $handlerCritical->getLevel());
$this->assertSame(Logger::WARNING, $handlerError->getLevel());
$this->assertSame(Logger::INFO, $handlerLog->getLevel());
$this->assertSame(Logger::DEBUG, $handlerDebug->getLevel());
$this->assertSame(Level::Critical, $handlerCritical->getLevel());
$this->assertSame(Level::Warning, $handlerError->getLevel());
$this->assertSame(Level::Info, $handlerLog->getLevel());
$this->assertSame(Level::Debug, $handlerDebug->getLevel());

$this->assertSame('php://stderr', $handlerCritical->getUrl());
$this->assertSame('php://stderr', $handlerError->getUrl());
Expand Down
1 change: 0 additions & 1 deletion tests/Logger/StreamTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static function getContent(): string
public function filter($in, $out, &$consumed, $closing): int
{
while ($bucket = stream_bucket_make_writeable($in)) {
/** @var \stdClass $bucket */
self::$content .= $bucket->data;
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
Expand Down